diff --git a/backend/package-lock.json b/backend/package-lock.json new file mode 100644 index 0000000..dfb18f1 --- /dev/null +++ b/backend/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "backend", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/frontend/src/renderer/src/components/forms/new-asset-form.tsx b/frontend/src/renderer/src/components/forms/new-asset-form.tsx index 2e5ae0d..df7b987 100644 --- a/frontend/src/renderer/src/components/forms/new-asset-form.tsx +++ b/frontend/src/renderer/src/components/forms/new-asset-form.tsx @@ -1,15 +1,15 @@ import { Controller, SubmitHandler, useFieldArray, useForm } from 'react-hook-form'; +import { BiImageAdd } from 'react-icons/bi'; +import { MdCheck, MdDelete } from 'react-icons/md'; import { useAssetsSearchRefetch } from '@renderer/hooks/use-assets-search'; import useDownloads from '@renderer/hooks/use-downloads'; import fetchClient from '@renderer/lib/fetch-client'; import { encodeThumbnailImage } from '@renderer/lib/image-util'; import { Asset } from '@renderer/types'; -import TextInput from '../input/text-input'; import KeywordsInput from '../input/keywords-input'; import Label from '../input/label'; -import { BiImageAdd } from 'react-icons/bi'; -import { MdCheck, MdDelete } from 'react-icons/md'; +import TextInput from '../input/text-input'; export interface NewAssetFormData { assetName: string; diff --git a/frontend/src/renderer/src/components/forms/new-user-form.tsx b/frontend/src/renderer/src/components/forms/new-user-form.tsx new file mode 100644 index 0000000..2cc42ec --- /dev/null +++ b/frontend/src/renderer/src/components/forms/new-user-form.tsx @@ -0,0 +1,144 @@ +import { AnimatePresence, motion } from 'framer-motion'; +import { SubmitHandler, useForm, useWatch } from 'react-hook-form'; +import { Link } from 'react-router-dom'; + +// import { useSelectedAsset } from '@renderer/hooks/use-asset-select'; +// import useDownloads from '@renderer/hooks/use-downloads'; +import Label from '../input/label'; +import TextInput from '../input/text-input'; + +export interface NewUserFormData { + firstName: string; // first name + lastName: string; // last name + pennkey: string; // username + school: 'sas' | 'seas' | 'wharton'; + password: string; // password +} + +interface NewUserFormProps { + afterSubmit?: SubmitHandler; +} + +// POST to /api/v1/assets/{uuid}/versions - Upload new version for a given asset +export default function NewUserForm({ afterSubmit }: NewUserFormProps) { + // const { commitChanges } = useDownloads(); + // const { mutate: mutateSelectedAsset } = useSelectedAsset(); + + const { + register, + handleSubmit, + formState: { isSubmitting }, + control, + } = useForm({ + defaultValues: { + firstName: '', + lastName: '', + pennkey: '', + school: 'seas', + password: '', + }, + }); + + // -------------------------------------------- + + const submitHandler = async (data: NewUserFormData) => { + // const { versions: downloadedVersions } = await window.api.ipc('assets:list-downloaded', null); + // const downloaded = downloadedVersions.find(({ asset_id }) => asset_id === uuid); + + // if (!downloaded) { + // console.error('No downloaded version found for asset', uuid); + // return; + // } + + // // Calling fetchClient.POST() + // await commitChanges({ + // asset_id: uuid, + // semver: downloaded.semver, + // message: data.message, + // is_major: data.is_major, + // }); + + // // refetch selected asset in case it's the one we updated + // mutateSelectedAsset(); + + // Combine assetFiles from state with form data + if (afterSubmit) afterSubmit(data); // Call the onSubmit function provided by props + }; + + const [pennkey, school] = useWatch({ control, name: ['pennkey', 'school'] }); + const computedEmail = pennkey ? `${pennkey}@${school}.upenn.edu` : undefined; + + return ( +
+
+
+ + + +
+ +
+
+ + +
+ + {computedEmail && ( + +
+ Email: {computedEmail} +
+
+ )} +
+
+ + + +
+ +
+ + + Already have an account? Log in here. + +
+
+ ); +} diff --git a/frontend/src/renderer/src/components/forms/user-login-form.tsx b/frontend/src/renderer/src/components/forms/user-login-form.tsx new file mode 100644 index 0000000..d1f8743 --- /dev/null +++ b/frontend/src/renderer/src/components/forms/user-login-form.tsx @@ -0,0 +1,91 @@ +import { SubmitHandler, useForm } from 'react-hook-form'; +import { Link } from 'react-router-dom'; + +// import { useSelectedAsset } from '@renderer/hooks/use-asset-select'; +// import useDownloads from '@renderer/hooks/use-downloads'; +import TextInput from '../input/text-input'; + +export interface UserLoginFormData { + username: string; // username + password: string; // password +} + +interface UserLoginFormProps { + afterSubmit?: SubmitHandler; +} + +// POST to /api/v1/assets/{uuid}/versions - Upload new version for a given asset +export default function UserLoginForm({ afterSubmit }: UserLoginFormProps) { + // const { commitChanges } = useDownloads(); + // const { mutate: mutateSelectedAsset } = useSelectedAsset(); + + const { + register, + handleSubmit, + formState: { isSubmitting }, + } = useForm({ + defaultValues: { + username: '', + password: '', + }, + }); + + // -------------------------------------------- + + const submitHandler = async (data: UserLoginFormData) => { + // const { versions: downloadedVersions } = await window.api.ipc('assets:list-downloaded', null); + // const downloaded = downloadedVersions.find(({ asset_id }) => asset_id === uuid); + + // if (!downloaded) { + // console.error('No downloaded version found for asset', uuid); + // return; + // } + + // // Calling fetchClient.POST() + // await commitChanges({ + // asset_id: uuid, + // semver: downloaded.semver, + // message: data.message, + // is_major: data.is_major, + // }); + + // // refetch selected asset in case it's the one we updated + // mutateSelectedAsset(); + + // Combine assetFiles from state with form data + if (afterSubmit) afterSubmit(data); // Call the onSubmit function provided by props + }; + + return ( +
+
+ + + + +
+ +
+ + + Don't have a Griddle account? Create one here. + +
+
+ ); +} diff --git a/frontend/src/renderer/src/components/layout/form-popup.tsx b/frontend/src/renderer/src/components/layout/form-popup.tsx index 60d8cf2..b7f6877 100644 --- a/frontend/src/renderer/src/components/layout/form-popup.tsx +++ b/frontend/src/renderer/src/components/layout/form-popup.tsx @@ -12,16 +12,17 @@ export default function FormPopup({ return ( <>
{ const [selectedTheme, setSelectedTheme] = useState('light'); // default theme @@ -35,11 +36,6 @@ const Navbar = () => { + New Asset - {/* Update Asset Button */} - {/* - + Update Asset - */} - {/* Search Bar */}
@@ -58,6 +54,9 @@ const Navbar = () => { + {/* User info (login, signup, settings) */} + + {/* Placeholder for Right-Side Content */}
{/* Content such as profile menu or additional buttons could go here */}
diff --git a/frontend/src/renderer/src/components/layout/theme-selector.tsx b/frontend/src/renderer/src/components/layout/theme-selector.tsx index 554f519..a38f147 100644 --- a/frontend/src/renderer/src/components/layout/theme-selector.tsx +++ b/frontend/src/renderer/src/components/layout/theme-selector.tsx @@ -22,9 +22,8 @@ const ThemeSelector = ({ selectedTheme, setSelectedTheme }) => { return (
-