Skip to content

Commit

Permalink
feat: implemented user pronouns in frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
dhj03 committed Sep 20, 2023
1 parent 09111ca commit b228401
Show file tree
Hide file tree
Showing 5 changed files with 193 additions and 2 deletions.
4 changes: 3 additions & 1 deletion backend/seed_data/src/seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,9 @@ pub fn seed() {
.expect(&format!("Failed to insert org {}.", org.name));
}

assert!(Organisation::get_all(&connection).len() == 2);
let x = Organisation::get_all(&connection);
println!("{:?}", x);
assert!(x.len() == 2);

println!("... Added {} organizations\n", orgs.len());
// make giuliana the admin of csesoc
Expand Down
2 changes: 1 addition & 1 deletion backend/server/src/database/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl NewUser {
}
}

#[derive(Queryable, Serialize, Deserialize)]
#[derive(Queryable, Serialize, Deserialize, Debug)]
pub struct Organisation {
pub id: i32,
pub name: String,
Expand Down
174 changes: 174 additions & 0 deletions backend/server/src/src/database/schema.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
// @generated automatically by Diesel CLI.

pub mod sql_types {
#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "admin_level"))]
pub struct AdminLevel;

#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "application_status"))]
pub struct ApplicationStatus;

#[derive(diesel::sql_types::SqlType)]
#[diesel(postgres_type(name = "user_gender"))]
pub struct UserGender;
}

diesel::table! {
answers (id) {
id -> Int4,
application_id -> Int4,
question_id -> Int4,
description -> Text,
created_at -> Timestamp,
updated_at -> Timestamp,
}
}

diesel::table! {
use diesel::sql_types::*;
use super::sql_types::ApplicationStatus;

applications (id) {
id -> Int4,
user_id -> Int4,
role_id -> Int4,
status -> ApplicationStatus,
created_at -> Timestamp,
updated_at -> Timestamp,
private_status -> Nullable<ApplicationStatus>,
}
}

diesel::table! {
campaigns (id) {
id -> Int4,
organisation_id -> Int4,
name -> Text,
cover_image -> Nullable<Text>,
description -> Text,
starts_at -> Timestamp,
ends_at -> Timestamp,
published -> Bool,
created_at -> Timestamp,
updated_at -> Timestamp,
}
}

diesel::table! {
comments (id) {
id -> Int4,
application_id -> Int4,
commenter_user_id -> Int4,
description -> Text,
created_at -> Timestamp,
updated_at -> Timestamp,
}
}

diesel::table! {
use diesel::sql_types::*;
use super::sql_types::AdminLevel;

organisation_users (id) {
id -> Int4,
user_id -> Int4,
organisation_id -> Int4,
admin_level -> AdminLevel,
created_at -> Timestamp,
updated_at -> Timestamp,
}
}

diesel::table! {
organisations (id) {
id -> Int4,
name -> Text,
logo -> Nullable<Text>,
created_at -> Timestamp,
updated_at -> Timestamp,
}
}

diesel::table! {
questions (id) {
id -> Int4,
role_ids -> Array<Nullable<Int4>>,
title -> Text,
description -> Nullable<Text>,
max_bytes -> Int4,
required -> Bool,
created_at -> Timestamp,
updated_at -> Timestamp,
}
}

diesel::table! {
ratings (id) {
id -> Int4,
application_id -> Int4,
rater_user_id -> Int4,
rating -> Int4,
created_at -> Timestamp,
updated_at -> Timestamp,
}
}

diesel::table! {
roles (id) {
id -> Int4,
campaign_id -> Int4,
name -> Text,
description -> Nullable<Text>,
min_available -> Int4,
max_available -> Int4,
finalised -> Bool,
created_at -> Timestamp,
updated_at -> Timestamp,
}
}

diesel::table! {
use diesel::sql_types::*;
use super::sql_types::UserGender;

users (id) {
id -> Int4,
email -> Text,
zid -> Text,
display_name -> Text,
degree_name -> Text,
degree_starting_year -> Int4,
superuser -> Bool,
created_at -> Timestamp,
updated_at -> Timestamp,
gender -> UserGender,
pronouns -> Text,
}
}

diesel::joinable!(answers -> applications (application_id));
diesel::joinable!(answers -> questions (question_id));
diesel::joinable!(applications -> roles (role_id));
diesel::joinable!(applications -> users (user_id));
diesel::joinable!(campaigns -> organisations (organisation_id));
diesel::joinable!(comments -> applications (application_id));
diesel::joinable!(comments -> users (commenter_user_id));
diesel::joinable!(organisation_users -> organisations (organisation_id));
diesel::joinable!(organisation_users -> users (user_id));
diesel::joinable!(ratings -> applications (application_id));
diesel::joinable!(ratings -> users (rater_user_id));
diesel::joinable!(roles -> campaigns (campaign_id));

diesel::allow_tables_to_appear_in_same_query!(
answers,
applications,
campaigns,
comments,
organisation_users,
organisations,
questions,
ratings,
roles,
users,
);
3 changes: 3 additions & 0 deletions frontend/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ export const doSignup = async ({
zid,
starting_year,
gender,
pronouns,
}: {
name: string;
degree_name: string;
zid: string;
starting_year: number;
gender: UserGender;
pronouns: string;
}) =>
API.request<{ token: string }>({
method: "POST",
Expand All @@ -58,6 +60,7 @@ export const doSignup = async ({
degree_starting_year: starting_year,
degree_name,
gender,
pronouns,
},
});

Expand Down
12 changes: 12 additions & 0 deletions frontend/src/pages/signup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type TFormData = {
degree_name: string;
starting_year: number;
gender: UserGender;
pronouns: string;
};
/* eslint-enable @typescript-eslint/naming-convention */

Expand All @@ -33,6 +34,7 @@ const Signup = () => {
degree_name: "",
starting_year: new Date().getFullYear(),
gender: "Unspecified",
pronouns: "",
});

const navigate = useNavigate();
Expand Down Expand Up @@ -132,6 +134,16 @@ const Signup = () => {
<option value="Unspecified">Other / Prefer not to say</option>
</Select>
</Select.Label>

<Input.Label>
<Input.LabelText>Pronouns</Input.LabelText>
<Input
value={formData.pronouns}
onChange={(e) =>
setFormData({ ...formData, pronouns: e.target.value })
}
/>
</Input.Label>
</div>

<Button tw="justify-center font-medium" type="submit">
Expand Down

0 comments on commit b228401

Please sign in to comment.