Skip to content

Commit

Permalink
Merge pull request #166 from jadmsaadaot/SUBMIT-task#175
Browse files Browse the repository at this point in the history
Add internal staff documents table to Consultation Record page
  • Loading branch information
djnunez-aot authored Nov 15, 2024
2 parents 042181b + 91c8645 commit 2d12ada
Show file tree
Hide file tree
Showing 25 changed files with 604 additions and 106 deletions.
2 changes: 2 additions & 0 deletions submit-api/src/submit_api/models/internal_staff_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ class InternalStaffDocuments(BaseModel):
url = Column(db.String(), nullable=False)
type = Column(db.Enum(InternalStaffDocumentType), nullable=False)
item_id = Column(db.Integer, db.ForeignKey('items.id'), nullable=False)
created_by = Column(db.String, db.ForeignKey('users.auth_guid'), nullable=True)
created_by_user = db.relationship('User', foreign_keys=[created_by], lazy='joined')
7 changes: 7 additions & 0 deletions submit-api/src/submit_api/schemas/internal_staff_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@ class Meta: # pylint: disable=too-few-public-methods
url = fields.Str(data_key="url")
type = fields.Enum(data_key="type", enum=InternalStaffDocumentType)
submission_item_id = fields.Int(data_key="submission_item_id")
created_date = fields.DateTime(data_key="created_date")
created_by = fields.Method('get_created_by')

@classmethod
def get_created_by(cls, obj):
"""Get created by."""
return obj.created_by_user.full_name if obj.created_by_user else None
257 changes: 257 additions & 0 deletions submit-web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions submit-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"sass": "^1.77.6",
"typescript": "^4.9.5",
"vite": "^5.2.0",
"vite-plugin-checker": "^0.8.0",
"vite-plugin-env-compatible": "^2.0.1",
"vite-plugin-istanbul": "^6.0.2",
"vite-tsconfig-paths": "^4.3.2"
Expand Down
4 changes: 2 additions & 2 deletions submit-web/src/components/DocumentUpload/DocumentTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import DocumentTableRow, {
StyledHeadTableCell,
DocumentHeadTableRow,
} from "./DocumentTableRow";
import { Document } from "@/store/documentUploadStore";
import { UploadObject } from "@/store/documentUploadStore";
import PendingDocumentRow from "./PendingDocumentRow";

type DocumentTableProps = {
header: string;
documents?: Array<Submission>;
pendingDocuments: Array<Document>;
pendingDocuments: Array<UploadObject>;
folder?: string;
};
export default function DocumentTable({
Expand Down
13 changes: 8 additions & 5 deletions submit-web/src/components/DocumentUpload/PendingDocumentRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { QUERY_KEY } from "@/hooks/api/constants";
import { notify } from "../Shared/Snackbar/snackbarStore";
import { useEffect } from "react";
import { saveObject } from "@/hooks/api/useObjectStorage";
import { useDocumentUploadStore } from "@/store/documentUploadStore";
import { useObjectUploadStore } from "@/store/documentUploadStore";
import { useQueryClient } from "@tanstack/react-query";
import { useParams } from "@tanstack/react-router";
import { Document } from "@/store/documentUploadStore";
import { UploadObject } from "@/store/documentUploadStore";

type DocumentTableRowProps = {
documentItem: Document;
documentItem: UploadObject;
error?: boolean;
folder?: string;
};
Expand All @@ -28,8 +28,11 @@ export default function PendingDocumentRow({

const queryClient = useQueryClient();

const { triggerPending, completeDocument, removeDocument } =
useDocumentUploadStore();
const {
triggerPending,
completeObject: completeDocument,
removeObject: removeDocument,
} = useObjectUploadStore();

useEffect(() => {
triggerPending(documentItem.id);
Expand Down
4 changes: 2 additions & 2 deletions submit-web/src/components/Submission/ItemsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { usePackageTableStore } from "./packageTableStore";
import { useAccount } from "@/store/accountStore";
import { USER_TYPE } from "@/models/User";
import { When } from "react-if";
import InternalDocuments from "./InternalDocuments";
import InternalDocumentsRows from "../SubmissionItem/InternalDocuments/Rows";

export default function ItemsTable({
submissionItems,
Expand Down Expand Up @@ -117,7 +117,7 @@ export default function ItemsTable({
/>
))}
<When condition={userType === USER_TYPE.STAFF}>
<InternalDocuments
<InternalDocumentsRows
internalStaffDocuments={internalStaffDocuments}
/>
</When>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from "react";
import { Box, Divider, Grid, Typography } from "@mui/material";
import { BCDesignTokens, EAOColors } from "epic.theme";
import { useDocumentUploadStore } from "@/store/documentUploadStore";
import { useObjectUploadStore } from "@/store/documentUploadStore";
import { When } from "react-if";
import { Navigate, useParams } from "@tanstack/react-router";
import { notify } from "@/components/Shared/Snackbar/snackbarStore";
Expand Down Expand Up @@ -32,7 +32,11 @@ export const DocumentUploadSection = () => {
getAccountProjectQueryOptions(Number(projectId)).queryKey,
);

const { reset, handleAddDocuments, documents } = useDocumentUploadStore();
const {
reset,
handleAddObjects: handleAddDocuments,
uploadObjects: documents,
} = useObjectUploadStore();

useEffect(() => {
return () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { When } from "react-if";
import ControlledRadioGroup from "@/components/Shared/controlled/ControlledRadioGroup";
import { YesNoRadioOptions } from "@/components/Shared/YesNoRadioOptions";
import { FieldErrors, useFieldArray, UseFormReturn } from "react-hook-form";
import { ConsultationRecordForm } from ".";
import { ConsultationRecordForm } from "../constants";

interface FormFieldSectionProps {
methods: UseFormReturn<ConsultationRecordForm>; // Replace FormValues with your actual form schema interface
Expand Down
Loading

0 comments on commit 2d12ada

Please sign in to comment.