Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Onboarding] - #2786 created model for checklist #2787

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
-- CreateTable
CREATE TABLE "Checklist" (
"checklistId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"teamTypeId" TEXT,
"dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"dateDeleted" TIMESTAMP(3),
"userCreatedId" TEXT NOT NULL,
"userDeletedId" TEXT,
"organizationId" TEXT NOT NULL,

CONSTRAINT "Checklist_pkey" PRIMARY KEY ("checklistId")
);

-- CreateTable
CREATE TABLE "ChecklistItem" (
"checklistItemId" TEXT NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
"parentChecklistItemId" TEXT,
"checklistId" TEXT NOT NULL,
"dateCreated" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"dateDeleted" TIMESTAMP(3),
"userCreatedId" TEXT NOT NULL,
"userDeletedId" TEXT,
"organizationId" TEXT NOT NULL,

CONSTRAINT "ChecklistItem_pkey" PRIMARY KEY ("checklistItemId")
);

-- CreateTable
CREATE TABLE "_onboardingChecklists" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);

-- CreateTable
CREATE TABLE "_checkedChecklistItems" (
"A" TEXT NOT NULL,
"B" TEXT NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "_onboardingChecklists_AB_unique" ON "_onboardingChecklists"("A", "B");

-- CreateIndex
CREATE INDEX "_onboardingChecklists_B_index" ON "_onboardingChecklists"("B");

-- CreateIndex
CREATE UNIQUE INDEX "_checkedChecklistItems_AB_unique" ON "_checkedChecklistItems"("A", "B");

-- CreateIndex
CREATE INDEX "_checkedChecklistItems_B_index" ON "_checkedChecklistItems"("B");

-- AddForeignKey
ALTER TABLE "Checklist" ADD CONSTRAINT "Checklist_teamTypeId_fkey" FOREIGN KEY ("teamTypeId") REFERENCES "Team_Type"("teamTypeId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Checklist" ADD CONSTRAINT "Checklist_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Checklist" ADD CONSTRAINT "Checklist_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Checklist" ADD CONSTRAINT "Checklist_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ChecklistItem" ADD CONSTRAINT "ChecklistItem_parentChecklistItemId_fkey" FOREIGN KEY ("parentChecklistItemId") REFERENCES "ChecklistItem"("checklistItemId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ChecklistItem" ADD CONSTRAINT "ChecklistItem_checklistId_fkey" FOREIGN KEY ("checklistId") REFERENCES "Checklist"("checklistId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ChecklistItem" ADD CONSTRAINT "ChecklistItem_userCreatedId_fkey" FOREIGN KEY ("userCreatedId") REFERENCES "User"("userId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ChecklistItem" ADD CONSTRAINT "ChecklistItem_userDeletedId_fkey" FOREIGN KEY ("userDeletedId") REFERENCES "User"("userId") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "ChecklistItem" ADD CONSTRAINT "ChecklistItem_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("organizationId") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_onboardingChecklists" ADD CONSTRAINT "_onboardingChecklists_A_fkey" FOREIGN KEY ("A") REFERENCES "Checklist"("checklistId") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_onboardingChecklists" ADD CONSTRAINT "_onboardingChecklists_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_checkedChecklistItems" ADD CONSTRAINT "_checkedChecklistItems_A_fkey" FOREIGN KEY ("A") REFERENCES "ChecklistItem"("checklistItemId") ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "_checkedChecklistItems" ADD CONSTRAINT "_checkedChecklistItems_B_fkey" FOREIGN KEY ("B") REFERENCES "User"("userId") ON DELETE CASCADE ON UPDATE CASCADE;
73 changes: 59 additions & 14 deletions src/backend/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,17 @@ model User {
deletedFrequentlyAskedQuestions FrequentlyAskedQuestion[] @relation(name: "frequentlyAskedQuestionDeleter")
createdMilestones Milestone[] @relation(name: "milestoneCreator")
deletedMilestones Milestone[] @relation(name: "milestoneDeleter")
createdChecklists Checklist[] @relation(name: "ChecklistCreator")
deletedChecklists Checklist[] @relation(name: "ChecklistDeleter")
createdChecklistItems ChecklistItem[] @relation(name: "ChecklistItemCreator")
deletedChecklistItems ChecklistItem[] @relation(name: "ChecklistItemDeleter")
onboardingChecklists Checklist[] @relation(name: "onboardingChecklists")
checkedChecklistItems ChecklistItem[] @relation(name: "checkedChecklistItems")
}

model Role {
roleId String @id @default(uuid())
roleType Role_Type

roleId String @id @default(uuid())
roleType Role_Type
userId String
user User @relation(fields: [userId], references: [userId])
organizationId String
Expand Down Expand Up @@ -713,6 +718,7 @@ model Team_Type {
organizationId String
organization Organization @relation(fields: [organizationId], references: [organizationId])
calendarId String?
checklists Checklist[]

@@unique([name, organizationId], name: "uniqueTeamType")
}
Expand Down Expand Up @@ -893,20 +899,22 @@ model Organization {
usefulLinks Link[]
FrequentlyAskedQuestions FrequentlyAskedQuestion[]
Milestone Milestone[]
checklists Checklist[]
checklistItems ChecklistItem[]
}

model FrequentlyAskedQuestion {
faqId String @id @default(uuid())
question String
answer String
userCreated User @relation(fields: [userCreatedId], references: [userId], name: "frequentlyAskedQuestionCreator")
userCreatedId String
userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "frequentlyAskedQuestionDeleter")
userDeletedId String?
dateCreated DateTime @default(now())
dateDeleted DateTime?
organizationId String
organization Organization @relation(fields: [organizationId], references: [organizationId])
faqId String @id @default(uuid())
question String
answer String
userCreated User @relation(fields: [userCreatedId], references: [userId], name: "frequentlyAskedQuestionCreator")
userCreatedId String
userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "frequentlyAskedQuestionDeleter")
userDeletedId String?
dateCreated DateTime @default(now())
dateDeleted DateTime?
organizationId String
organization Organization @relation(fields: [organizationId], references: [organizationId])
}

model Milestone {
Expand All @@ -923,3 +931,40 @@ model Milestone {
organizationId String
organization Organization @relation(fields: [organizationId], references: [organizationId])
}

model Checklist {
checklistId String @id @default(uuid())
name String
checklistItems ChecklistItem[]
teamType Team_Type? @relation(fields: [teamTypeId], references: [teamTypeId])
teamTypeId String?
users User[] @relation(name: "onboardingChecklists")
dateCreated DateTime @default(now())
dateDeleted DateTime?
userCreated User @relation(fields: [userCreatedId], references: [userId], name: "ChecklistCreator")
userCreatedId String
userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "ChecklistDeleter")
userDeletedId String?
organization Organization @relation(fields: [organizationId], references: [organizationId])
organizationId String
}

model ChecklistItem {
checklistItemId String @id @default(uuid())
name String
subtasks ChecklistItem[] @relation("Subtasks")
description String?
parentChecklistItem ChecklistItem? @relation("Subtasks", fields: [parentChecklistItemId], references: [checklistItemId])
parentChecklistItemId String?
Checklist Checklist @relation(fields: [checklistId], references: [checklistId])
checklistId String
usersChecked User[] @relation(name: "checkedChecklistItems")
dateCreated DateTime @default(now())
dateDeleted DateTime?
userCreated User @relation(fields: [userCreatedId], references: [userId], name: "ChecklistItemCreator")
userCreatedId String
userDeleted User? @relation(fields: [userDeletedId], references: [userId], name: "ChecklistItemDeleter")
userDeletedId String?
organizationId String
organization Organization @relation(fields: [organizationId], references: [organizationId])
}
4 changes: 2 additions & 2 deletions src/frontend/src/apis/recruitment.api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from '../utils/axios';
import { MilestonePayload, FaqPayload } from '../hooks/recruitment.hooks';
import { apiUrls } from '../utils/urls';
import { Milestone } from 'shared/src/types/milestone-types';
import { FrequentlyAskedQuestion } from 'shared/src/types/frequently-asked-questions-types';
import { Milestone } from 'shared';
import { FrequentlyAskedQuestion } from 'shared';

export const getAllMilestones = () => {
return axios.get<Milestone[]>(apiUrls.allMilestones(), {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ErrorPage from '../../ErrorPage';
import LoadingIndicator from '../../../components/LoadingIndicator';
import { FrequentlyAskedQuestion } from 'shared/src/types/frequently-asked-questions-types';
import { FrequentlyAskedQuestion } from 'shared';
import { useEditFaq } from '../../../hooks/recruitment.hooks';
import FaqFormModal from './FaqFormModal';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ErrorPage from '../../ErrorPage';
import LoadingIndicator from '../../../components/LoadingIndicator';
import { useEditMilestone } from '../../../hooks/recruitment.hooks';
import { Milestone } from 'shared/src/types/milestone-types';
import { Milestone } from 'shared';
import MilestoneFormModal from './MilestoneFormModal';

interface EditMilestoneFormModalProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { TableRow, TableCell, Box, Table as MuiTable, TableHead, TableBody, Typography, Button } from '@mui/material';
import EditIcon from '@mui/icons-material/Edit';
import DeleteIcon from '@mui/icons-material/Delete';
import { FrequentlyAskedQuestion } from 'shared/src/types/frequently-asked-questions-types';
import { FrequentlyAskedQuestion } from 'shared';
import { NERButton } from '../../../components/NERButton';
import { useAllFaqs, useDeleteFAQ } from '../../../hooks/recruitment.hooks';
import LoadingIndicator from '../../../components/LoadingIndicator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Box } from '@mui/system';
import useFormPersist from 'react-hook-form-persist';
import { FormStorageKey } from '../../../utils/form';
import { FaqPayload } from '../../../hooks/recruitment.hooks';
import { FrequentlyAskedQuestion } from 'shared/src/types/frequently-asked-questions-types';
import { FrequentlyAskedQuestion } from 'shared';
import { useEffect } from 'react';

interface FaqFormModalProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { yupResolver } from '@hookform/resolvers/yup';
import { Box } from '@mui/system';
import useFormPersist from 'react-hook-form-persist';
import { FormStorageKey } from '../../../utils/form';
import { Milestone } from 'shared/src/types/milestone-types';
import { Milestone } from 'shared';
import { MilestonePayload } from '../../../hooks/recruitment.hooks';
import { useState, useEffect } from 'react';
import { DatePicker } from '@mui/x-date-pickers';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TableRow, TableCell, Box, Table as MuiTable, TableHead, TableBody, Typography, Button } from '@mui/material';
import EditIcon from '@mui/icons-material/Edit';
import DeleteIcon from '@mui/icons-material/Delete';
import { Milestone } from 'shared/src/types/milestone-types';
import { Milestone } from 'shared';
import CreateMilestoneFormModal from './CreateMilestoneFormModal';
import EditMilestoneFormModal from './EditMilestoneFormModal';
import LoadingIndicator from '../../../components/LoadingIndicator';
Expand Down
3 changes: 3 additions & 0 deletions src/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export * from './src/types/team-types';
export * from './src/types/task-types';
export * from './src/types/reimbursement-requests-types';
export * from './src/types/design-review-types';
export * from './src/types/frequently-asked-questions-types';
export * from './src/types/milestone-types';
export * from './src/types/checklist-types';

export * from './src/validate-wbs';
export * from './src/date-utils';
Expand Down
30 changes: 30 additions & 0 deletions src/shared/src/types/checklist-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
* See the LICENSE file in the repository root folder for details.
*/

import { TeamType } from './design-review-types';
import { User } from './user-types';

export interface Checklist {
checklistId: string;
name: string;
checklistItems: ChecklistItem[];
teamType?: TeamType;
userCreated: User;
userDeleted?: User;
dateCreated: Date;
dateDeleted?: Date;
}

export interface ChecklistItem {
checklistItemId: string;
name: string;
subtasks: ChecklistItem[];
description: string[];
parentChecklistItem: ChecklistItem[];
userCreated: User;
userDeleted?: User;
dateCreated: Date;
dateDeleted?: Date;
}
Loading