diff --git a/apps/expo/app/(generated)/cv/[slug]/edit/index.tsx b/apps/expo/app/(generated)/cv/[slug]/edit/index.tsx new file mode 100644 index 00000000..9c0ee399 --- /dev/null +++ b/apps/expo/app/(generated)/cv/[slug]/edit/index.tsx @@ -0,0 +1,2 @@ +// -i- Automatically generated by 'yarn link-routes', do not modify manually +export { default } from 'cv-page/routes/cv/[slug]/edit/index' diff --git a/apps/next/app/(generated)/cv/[slug]/edit/page.tsx b/apps/next/app/(generated)/cv/[slug]/edit/page.tsx new file mode 100644 index 00000000..d13244a6 --- /dev/null +++ b/apps/next/app/(generated)/cv/[slug]/edit/page.tsx @@ -0,0 +1,2 @@ +'use client' +export { default, dynamic } from 'cv-page/routes/cv/[slug]/edit/index' diff --git a/features/cv-page/forms/useResumeDataForm.ts b/features/cv-page/forms/useResumeDataForm.ts new file mode 100644 index 00000000..1802fddf --- /dev/null +++ b/features/cv-page/forms/useResumeDataForm.ts @@ -0,0 +1,16 @@ +import { useFormState } from 'aetherspace/forms/useFormState' +import { ResumeData } from 'cv-page/schemas/ResumeData' + +/* --- useResumeDataForm() --------------------------------------------------------------------- */ + +const useResumeDataForm = (initialValues) => { + const formState = useFormState({ + stateSchema: ResumeData, + initialValues, + }) + return formState +} + +/* --- Exports --------------------------------------------------------------------------------- */ + +export default useResumeDataForm diff --git a/features/cv-page/resolvers/upsertResume.ts b/features/cv-page/resolvers/upsertResume.ts index 1d35ad92..87514ebe 100644 --- a/features/cv-page/resolvers/upsertResume.ts +++ b/features/cv-page/resolvers/upsertResume.ts @@ -1,13 +1,8 @@ import { aetherResolver } from 'aetherspace/utils/serverUtils' -// Types import { TMongoUpdateResult } from '@aetherspace/mongoose/schemas' -// Schemas import { UpsertResumeAPIConfig } from '../schemas/UpsertResumeResolver' -// Models import { ResumeDataModel } from '../schemas/models' -// Mocks import { dummyResumeData } from '../mocks/resumeData.mock' -// Utils import { dbConnect } from '@aetherspace/mongoose/utils' /* --- Constants ------------------------------------------------------------------------------- */ diff --git a/features/cv-page/routes/cv/[slug]/edit/index.tsx b/features/cv-page/routes/cv/[slug]/edit/index.tsx new file mode 100644 index 00000000..41e471ae --- /dev/null +++ b/features/cv-page/routes/cv/[slug]/edit/index.tsx @@ -0,0 +1,22 @@ +import React from 'react' +// Navigation +import { AetherPage } from 'aetherspace/navigation' +// Screens +import * as UpdateResumeScreen from '../../../../screens/UpdateResumeScreen' + +/* --- Config ---------------------------------------------------------------------------------- */ + +const ScreenComponent = UpdateResumeScreen.UpdateResumeScreen +const screenConfig = UpdateResumeScreen.screenConfig + +/* --- /cv/[slug]/edit ------------------------------------------------------------------------- */ + +const PageScreen = (props: UpdateResumeScreen.TUpdateResumeScreenProps) => ( + +) + +/* --- Exports --------------------------------------------------------------------------------- */ + +export const dynamic = screenConfig.dynamic + +export default PageScreen diff --git a/features/cv-page/screens/UpdateResumeScreen.tsx b/features/cv-page/screens/UpdateResumeScreen.tsx new file mode 100644 index 00000000..50e98289 --- /dev/null +++ b/features/cv-page/screens/UpdateResumeScreen.tsx @@ -0,0 +1,75 @@ +import React from 'react' +import { useAetherRoute } from 'aetherspace/navigation' +import { z, AetherProps, createDataBridge } from 'aetherspace/schemas' +import { GetResumeDataByUserSlugDataBridge } from '..//schemas/GetResumeDataByUserSlugDataBridge.ts' +import { View } from 'aetherspace/primitives' +import { H1, P } from 'aetherspace/html-elements' +import useResumeDataForm from '../forms/useResumeDataForm.ts' +import { dummyResumeData } from '../mocks/resumeData.mock.ts' + +/* --- Schemas & Types ------------------------------------------------------------------------- */ + +const UpdateResumeScreenParams = GetResumeDataByUserSlugDataBridge.argsSchema +const UpdateResumeScreenResponse = GetResumeDataByUserSlugDataBridge.responseSchema + +const UpdateResumeScreenProps = UpdateResumeScreenResponse.extendSchema('UpdateResumeScreenProps', { + params: UpdateResumeScreenParams.optional(), + segment: z.string().optional(), +}).example({ + params: { slug: 'codinsonn' }, + ...dummyResumeData, +}) + +export type TUpdateResumeScreenProps = AetherProps + +/* --- Data Fetching Bridge -------------------------------------------------------------------- */ + +export const screenConfig = createDataBridge({ + ...GetResumeDataByUserSlugDataBridge, + paramsSchema: UpdateResumeScreenParams, + propsSchema: UpdateResumeScreenProps, + dynamic: 'auto', // -i- https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config +}) + +/* --- ------------------------------------------------------------------- */ + +export const UpdateResumeScreen = (props: TUpdateResumeScreenProps) => { + // Data + const [screenData, { error }] = useAetherRoute(props, screenConfig) + + // Forms + const formState = useResumeDataForm(screenData) + + // -- Effects -- + + React.useEffect(() => { + formState.handleChange('slug', 'codinsonnn') + }, []) + + // -- Guards -- + + if (error) { + return ( + +

Error: {error.message}

+
+ ) + } + + // -- Render -- + + return ( + +

UpdateResumeScreen

+

{JSON.stringify(formState.values, null, 4)}

+
+ ) +} + +/* --- Documentation --------------------------------------------------------------------------- */ + +// export const getDocumentationProps = UpdateResumeScreenProps.introspect() + +/* --- Exports --------------------------------------------------------------------------------- */ + +export default UpdateResumeScreen diff --git a/features/cv-page/screens/index.ts b/features/cv-page/screens/index.ts index 75bfa219..97d6d9d5 100644 --- a/features/cv-page/screens/index.ts +++ b/features/cv-page/screens/index.ts @@ -1 +1,3 @@ export { ResumeScreen, TResumeScreenProps } from './ResumeScreen' +export { UpdateResumeScreen, TUpdateResumeScreenProps } from './UpdateResumeScreen' + diff --git a/packages/@registries/routeManifest.ts b/packages/@registries/routeManifest.ts index b8224ad5..0444f06c 100644 --- a/packages/@registries/routeManifest.ts +++ b/packages/@registries/routeManifest.ts @@ -5,6 +5,7 @@ export const routeManifest = { ['/']: 'BioScreen', ['/links']: 'BioScreen', ['/resume']: 'ResumeScreen', + ['/cv/[slug]/edit']: 'UpdateResumeScreen', ['/cv/[slug]']: 'ResumeScreen', ['/resume/[slug]']: 'ResumeScreen', } as const