Skip to content

Commit

Permalink
assigning teams (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
armintalaie authored Sep 14, 2024
1 parent 51f8c8e commit 2376e30
Show file tree
Hide file tree
Showing 11 changed files with 433 additions and 144 deletions.
113 changes: 85 additions & 28 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ model mfa_factors {
created_at DateTime @db.Timestamptz(6)
updated_at DateTime @db.Timestamptz(6)
secret String?
phone String? @unique
phone String?
last_challenged_at DateTime? @unique @db.Timestamptz(6)
mfa_challenges mfa_challenges[]
users users @relation(fields: [user_id], references: [id], onDelete: Cascade, onUpdate: NoAction)
@@unique([user_id, phone], map: "unique_verified_phone_factor")
@@unique([user_id, phone], map: "unique_phone_factor_per_user")
@@index([user_id, created_at], map: "factor_id_created_at_idx")
@@index([user_id])
@@schema("auth")
Expand Down Expand Up @@ -319,7 +319,8 @@ model users {
one_time_tokens one_time_tokens[]
sessions sessions[]
applications_applications_interviewer_idTousers applications[] @relation("applications_interviewer_idTousers")
applications applications[]
applications_applications_reviewer_idTousers applications[] @relation("applications_reviewer_idTousers")
members members?
roles roles?
submissions submissions[]
Expand All @@ -328,14 +329,23 @@ model users {
@@schema("auth")
}

/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
model form_status {
label String
form_id BigInt
forms forms @relation(fields: [form_id], references: [id], onDelete: Cascade)
model applications {
id String @id @db.Uuid
status String?
reviewer_id String? @db.Uuid
notes String?
created_at DateTime? @default(now()) @db.Timestamptz(6)
meta Json?
level String? @default("unassigned")
interviewer_id String? @db.Uuid
team_id BigInt?
submissions submissions @relation(fields: [id], references: [id], onDelete: Cascade)
users_applications_interviewer_idTousers users? @relation("applications_interviewer_idTousers", fields: [interviewer_id], references: [id])
users_applications_reviewer_idTousers users? @relation("applications_reviewer_idTousers", fields: [reviewer_id], references: [id], onUpdate: Restrict)
teams teams? @relation(fields: [team_id], references: [id])
pending_members pending_members[]
@@id([label, form_id])
@@schema("public")
}

Expand All @@ -350,12 +360,51 @@ model forms {
close_at DateTime? @db.Timestamptz(6)
created_at DateTime @default(now()) @db.Timestamptz(6)
type form_type? @default(survey)
form_status form_status[]
submissions submissions[]
@@schema("public")
}

/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
model members {
id String @id @db.Uuid
first_name String
last_name String
grad_year Int @db.SmallInt
faculty String?
specialization String?
year_level Int? @db.SmallInt
users users @relation(fields: [id], references: [id])
team_members team_members[]
@@schema("public")
}

/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
model pending_members {
user_id String @db.Uuid
status String?
meta Json?
created_at DateTime? @default(now()) @db.Timestamptz(6)
team_id BigInt
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
applications applications @relation(fields: [user_id], references: [id], onDelete: Cascade, map: "pending_member_id_fkey")
teams teams @relation(fields: [team_id], references: [id], onDelete: Cascade, map: "pending_member_team_id_fkey")
@@schema("public")
}

/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
model roles {
id String @id @db.Uuid
roles String?
created_at DateTime @default(now()) @db.Timestamptz(6)
display_name String?
users users @relation(fields: [id], references: [id], onDelete: Cascade)
@@schema("public")
}

/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
model submissions {
Expand All @@ -375,29 +424,37 @@ model submissions {
}

/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
model applications {
id String @id @db.Uuid
status String?
reviewer_id String? @db.Uuid
notes String?
created_at DateTime? @default(now()) @db.Timestamptz(6)
meta Json?
level String? @default("unassigned")
interviewer_id String? @db.Uuid
submissions submissions @relation(fields: [id], references: [id], onDelete: Cascade)
users_applications_interviewer_idTousers users? @relation("applications_interviewer_idTousers", fields: [interviewer_id], references: [id])
users users? @relation(fields: [reviewer_id], references: [id], onUpdate: Restrict)
model team_members {
member_id String @db.Uuid
team_id BigInt
joined_on DateTime? @default(now()) @db.Timestamptz(6)
role String?
members members @relation(fields: [member_id], references: [id], onDelete: Cascade)
team_role team_role? @relation(fields: [role], references: [name])
teams teams @relation(fields: [team_id], references: [id], onDelete: Cascade)
@@id([member_id, team_id])
@@schema("public")
}

/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
model team_role {
id BigInt @id @default(autoincrement())
name String @unique
team_members team_members[]
@@schema("public")
}

/// This model contains row level security and requires additional setup for migrations. Visit https://pris.ly/d/row-level-security for more info.
model roles {
id String @id @db.Uuid
roles String?
created_at DateTime @default(now()) @db.Timestamptz(6)
display_name String?
users users @relation(fields: [id], references: [id], onDelete: Cascade)
model teams {
id BigInt @id @default(autoincrement())
name String @unique
started_at DateTime? @default(now()) @db.Timestamptz(6)
ended_at DateTime? @db.Timestamptz(6)
applications applications[]
pending_members pending_members[]
team_members team_members[]
@@schema("public")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function AnalyticsPage({
}) {
const columns = [
"status",
"team_id",
"level",
"role",
"reviewer_id",
Expand Down
72 changes: 44 additions & 28 deletions src/app/portal/admin/forms/[id]/submissions/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export function createColumns<TData>(
return {
meta: { field: field, id: key },
accessorKey: key as keyof TData,
size: 250,
header: (body: any) => {
if (!body) {
return <span>{field.label}</span>;
Expand Down Expand Up @@ -245,22 +246,35 @@ export function createColumns<TData>(
return [
{
accessorKey: "popover",
header: "",
header: "Actions",
enableColumnFilter: false,
size: 100,
maxSize: 100,
size: 300,
maxSize: 300,
cell: ({ row }) => {
return (
<button
onClick={() => {
setAndOpen({ applicant: row });
}}
className={
"text-lp-300 font-bold rounded-lg p-4 py-7 w-fit flex flex-1 border border-transparent hover:border-background-500 items-center justify-center gap-2 "
}
>
View
</button>
<div className="flex gap-2 flex-1 justify-start items-center rounded-lg ">
<button
onClick={() => {
setAndOpen({ applicant: row });
}}
className={
" h-fit bg-background-500 rounded-md p-2 w-fit flex border border-transparent hover:border-background-500 items-center justify-center gap-2 "
}
>
View
</button>
<button
disabled={true}
onClick={() => {
setAndOpen({ applicant: row });
}}
className={
"opacity-55 rounded-md p-2 bg-background-500 h-fit w-fit flex border border-transparent hover:border-background-500 items-center justify-center gap-2 "
}
>
Offer Role
</button>
</div>
);
},
},
Expand Down Expand Up @@ -360,21 +374,23 @@ export function SelectField({
};

return (
<MultiSelect
className={
"w-full bg-transparent border-none hover:bg-lp-500 duration-300"
}
onChange={(e) => updateField(e[0])}
allowMultiple={false}
emptyText={nullLabel?.toString() || "None"}
value={Array.isArray(selected) ? selected : [selected]}
options={
selectOptions?.map((op) => ({
label: op.label,
value: op.id,
})) || []
}
></MultiSelect>
<>
<MultiSelect
className={
"w-full bg-transparent border-none hover:bg-lp-500 duration-300"
}
onChange={(e) => updateField(e[0])}
allowMultiple={false}
emptyText={nullLabel?.toString() || "None"}
value={Array.isArray(selected) ? selected : [selected]}
options={
selectOptions?.map((op) => ({
label: op.label,
value: op.id,
})) || []
}
></MultiSelect>
</>
);
}

Expand Down
5 changes: 3 additions & 2 deletions src/app/portal/admin/forms/[id]/submissions/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ const getCommonPinningStyles = (column: Column<any>): CSSProperties => {
right: isPinned === "right" ? `${column.getAfter("right")}px` : undefined,
opacity: isPinned ? 0.95 : 1,
position: isPinned ? "sticky" : "relative",
width: column.getSize() ? column.getSize() : "300px",
width: column.getSize() ? column.getSize() : "500px",
// zIndex: isPinned ? 1 : 0,
maxWidth: column.getSize() ? column.getSize() : "300px",
maxWidth: column.getSize() ? column.getSize() : "500px",
};
};

Expand Down Expand Up @@ -88,6 +88,7 @@ export function DataTable<TData, TValue>({
columnOrder: [
"popover",
"status",
"team_id",
"level",
"reviewer_id",
"interviewer_id",
Expand Down
Loading

0 comments on commit 2376e30

Please sign in to comment.