diff --git a/submit-api/src/submit_api/resources/user.py b/submit-api/src/submit_api/resources/user.py index 655fbdae..85cda145 100644 --- a/submit-api/src/submit_api/resources/user.py +++ b/submit-api/src/submit_api/resources/user.py @@ -49,7 +49,6 @@ class User(Resource): def get(guid): """Fetch an account by id.""" user = UserService.get_by_auth_guid(guid) - print(UserSchema().dump(user)) if not user: return ResourceNotFoundError(f"User with guid {guid} not found") return UserSchema().dump(user), HTTPStatus.OK diff --git a/submit-web/src/components/App/Users/UserModal.tsx b/submit-web/src/components/App/Users/UserModal.tsx deleted file mode 100644 index 7ed09f20..00000000 --- a/submit-web/src/components/App/Users/UserModal.tsx +++ /dev/null @@ -1,152 +0,0 @@ -import { useModal } from "@/components/Shared/Modals/modalStore"; -import { useAddUser, useUpdateUser } from "@/hooks/api/useUsers"; -import { User } from "@/models/User"; -import { Save } from "@mui/icons-material"; -import { - Alert, - Button, - DialogActions, - DialogContent, - DialogTitle, - TextField, -} from "@mui/material"; -import { useEffect, useState } from "react"; - -type AddUserModalProps = { - onSubmit: () => void; - user: User | undefined; -}; - -const initFormData: Omit = { - first_name: "", - last_name: "", - username: "", - email_address: "", - contact_number: "", - description: "", -}; - -const UserModal: React.FC = ({ onSubmit, user }) => { - const [formData, setFormData] = useState>(initFormData); - const { setClose } = useModal(); - - useEffect(() => { - if (user) { - setFormData({ - first_name: user.first_name || "", - last_name: user.last_name || "", - username: user.username || "", - email_address: user.email_address || "", - contact_number: user.contact_number || "", - description: user.description || "", - }); - } else { - setFormData(initFormData); - } - }, [user]); - - const onSuccess = () => { - setFormData(initFormData); - onSubmit(); - }; - - const onError = (err: unknown) => { - // eslint-disable-next-line no-console - console.log(err); - }; - - const { - mutate: addUser, - isError, - error, - reset, - } = useAddUser(onSuccess, onError); - - const { mutate: updateUser } = useUpdateUser(onSuccess, onError); - - const handleChange = (e: React.ChangeEvent) => { - const { name, value } = e.target; - setFormData((prevFormData) => ({ - ...prevFormData, - [name]: value, - })); - }; - - const handleSubmit = (e: React.FormEvent) => { - e.preventDefault(); - if (user) { - updateUser({ ...user, ...formData }); - } else { - addUser(formData); - } - }; - - const handleClose = () => { - reset(); - setFormData(initFormData); - setClose(); - }; - - return ( - <> - Add New User -
- - {isError && Error: {error?.message}} - - - - - - - - - - -
- - ); -}; - -export default UserModal; diff --git a/submit-web/src/hooks/api/useAccounts.tsx b/submit-web/src/hooks/api/useAccounts.tsx index a88923aa..875c4888 100644 --- a/submit-web/src/hooks/api/useAccounts.tsx +++ b/submit-web/src/hooks/api/useAccounts.tsx @@ -1,6 +1,7 @@ import { OnErrorType, submitRequest } from "@/utils/axiosUtils"; import { queryOptions, useMutation, useQuery } from "@tanstack/react-query"; import { defaultUseQueryOptions, QUERY_KEY } from "./constants"; +import { User } from "@/models/User"; type CreateAccountRequest = { first_name: string; @@ -23,28 +24,8 @@ const createAccount = (account: CreateAccountRequest) => { }); }; -type GetUserResponse = { - id: number; - auth_guid: string; - type: string; - account_user: { - first_name: string; - last_name: string; - position: string; - work_contact_number: string; - work_email_address: string; - created_at: string; - updated_at: string; - account_id: number; - account: { - id: number; - proponent_id: number; - }; - }; -}; const getUserByGuid = (guid?: string) => { - console.log("guid", guid); - return submitRequest({ url: `/users/guid/${guid}` }); + return submitRequest({ url: `/users/guid/${guid}` }); }; type CreateAccountOptions = { diff --git a/submit-web/src/models/Account.ts b/submit-web/src/models/Account.ts index d75500cd..8ffd797e 100644 --- a/submit-web/src/models/Account.ts +++ b/submit-web/src/models/Account.ts @@ -1,10 +1,4 @@ -export interface User { - id: number; - first_name: string; - last_name: string; - username: string; - email_address: string; - contact_number: string; - description: string; - } - \ No newline at end of file +export type Account = { + id: number; + proponent_id: number; +}; diff --git a/submit-web/src/models/AccountUser.ts b/submit-web/src/models/AccountUser.ts index d4b1b61d..e047b329 100644 --- a/submit-web/src/models/AccountUser.ts +++ b/submit-web/src/models/AccountUser.ts @@ -1,3 +1,5 @@ +import { Account } from "./Account"; + export type AccountUser = { id: number; account_id: number; @@ -8,4 +10,5 @@ export type AccountUser = { work_email_address: string; work_contact_number: string; auth_guid: string; + account: Account; }; diff --git a/submit-web/src/models/Submission.ts b/submit-web/src/models/Submission.ts index 014fdb1a..3ceb33f2 100644 --- a/submit-web/src/models/Submission.ts +++ b/submit-web/src/models/Submission.ts @@ -1,5 +1,3 @@ -import { User } from "./User"; - export type SubmissionStatus = | "NEW_SUBMISSION" | "COMPLETED" diff --git a/submit-web/src/routeTree.gen.ts b/submit-web/src/routeTree.gen.ts index 5503259b..c4469152 100644 --- a/submit-web/src/routeTree.gen.ts +++ b/submit-web/src/routeTree.gen.ts @@ -14,6 +14,7 @@ import { createFileRoute } from '@tanstack/react-router' import { Route as rootRoute } from './routes/__root' import { Route as RegistrationImport } from './routes/registration' +import { Route as NotFoundImport } from './routes/not-found' import { Route as ErrorImport } from './routes/error' import { Route as AuthenticatedImport } from './routes/_authenticated' import { Route as IndexImport } from './routes/index' @@ -59,6 +60,11 @@ const RegistrationRoute = RegistrationImport.update({ getParentRoute: () => rootRoute, } as any) +const NotFoundRoute = NotFoundImport.update({ + path: '/not-found', + getParentRoute: () => rootRoute, +} as any) + const ErrorRoute = ErrorImport.update({ path: '/error', getParentRoute: () => rootRoute, @@ -222,6 +228,13 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof ErrorImport parentRoute: typeof rootRoute } + '/not-found': { + id: '/not-found' + path: '/not-found' + fullPath: '/not-found' + preLoaderRoute: typeof NotFoundImport + parentRoute: typeof rootRoute + } '/registration': { id: '/registration' path: '/registration' @@ -402,6 +415,7 @@ export const routeTree = rootRoute.addChildren({ AuthenticatedRegistrationCreateAccountRoute, }), ErrorRoute, + NotFoundRoute, RegistrationRoute, OidcCallbackStaffRoute, ProponentRoute: ProponentRoute.addChildren({}), @@ -419,6 +433,7 @@ export const routeTree = rootRoute.addChildren({ "/", "/_authenticated", "/error", + "/not-found", "/registration", "/oidc-callback/staff", "/proponent", @@ -440,6 +455,9 @@ export const routeTree = rootRoute.addChildren({ "/error": { "filePath": "error.tsx" }, + "/not-found": { + "filePath": "not-found.tsx" + }, "/registration": { "filePath": "registration.tsx" }, diff --git a/submit-web/src/routes/_authenticated.tsx b/submit-web/src/routes/_authenticated.tsx index 1032d55c..2f109d65 100644 --- a/submit-web/src/routes/_authenticated.tsx +++ b/submit-web/src/routes/_authenticated.tsx @@ -1,5 +1,6 @@ import { PageLoader } from "@/components/Shared/PageLoader"; import { useGetUserByGuid } from "@/hooks/api/useAccounts"; +import { USER_TYPE } from "@/models/User"; import { useAccount } from "@/store/accountStore"; import { createFileRoute, Navigate, Outlet } from "@tanstack/react-router"; import { useEffect } from "react"; @@ -48,7 +49,11 @@ function Auth() { } if (!isAuthenticated) { - return ; + return ; + } + + if (userData?.type !== USER_TYPE.PROPONENT) { + return ; } return ; diff --git a/submit-web/src/routes/_authenticated/_dashboard/projects/$projectId/_projectLayout/submission-packages/$submissionPackageId/_submissionLayout/index.tsx b/submit-web/src/routes/_authenticated/_dashboard/projects/$projectId/_projectLayout/submission-packages/$submissionPackageId/_submissionLayout/index.tsx index 97b55f60..159363ff 100644 --- a/submit-web/src/routes/_authenticated/_dashboard/projects/$projectId/_projectLayout/submission-packages/$submissionPackageId/_submissionLayout/index.tsx +++ b/submit-web/src/routes/_authenticated/_dashboard/projects/$projectId/_projectLayout/submission-packages/$submissionPackageId/_submissionLayout/index.tsx @@ -98,7 +98,6 @@ export default function SubmissionPage() { PACKAGE_STATUS.SUBMITTED.value, ); - console.log(accountProject?.project?.ea_certificate); return ( diff --git a/submit-web/src/routes/not-found.tsx b/submit-web/src/routes/not-found.tsx new file mode 100644 index 00000000..1ccef295 --- /dev/null +++ b/submit-web/src/routes/not-found.tsx @@ -0,0 +1,10 @@ +import PageNotFound from "@/components/Shared/PageNotFound"; +import { createFileRoute } from "@tanstack/react-router"; + +export const Route = createFileRoute("/not-found")({ + component: NotFound, +}); + +function NotFound() { + return ; +} diff --git a/submit-web/src/routes/oidc-callback/index.tsx b/submit-web/src/routes/oidc-callback/index.tsx index 010e17d8..f4cddb66 100644 --- a/submit-web/src/routes/oidc-callback/index.tsx +++ b/submit-web/src/routes/oidc-callback/index.tsx @@ -32,12 +32,9 @@ function OidcCallback() { }); if (getAuthError) { - console.log("auth error", getAuthError); return ; } - console.log(userData); - if (userData?.account_user.account_id) { return ; }