-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add Temporary WIP UpdateResumeScreen & formState
- Loading branch information
Showing
8 changed files
with
120 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
'use client' | ||
export { default, dynamic } from 'cv-page/routes/cv/[slug]/edit/index' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) => ( | ||
<AetherPage {...props} screen={ScreenComponent} screenConfig={screenConfig} /> | ||
) | ||
|
||
/* --- Exports --------------------------------------------------------------------------------- */ | ||
|
||
export const dynamic = screenConfig.dynamic | ||
|
||
export default PageScreen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<typeof UpdateResumeScreenProps> | ||
|
||
/* --- 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 | ||
}) | ||
|
||
/* --- <UpdateResumeScreen/> ------------------------------------------------------------------- */ | ||
|
||
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 ( | ||
<View tw="w-full h-full items-center justify-center"> | ||
<H1 tw="text-red-500">Error: {error.message}</H1> | ||
</View> | ||
) | ||
} | ||
|
||
// -- Render -- | ||
|
||
return ( | ||
<View tw="w-full h-full items-center justify-center"> | ||
<H1 tw="text-xl text-black">UpdateResumeScreen</H1> | ||
<P>{JSON.stringify(formState.values, null, 4)}</P> | ||
</View> | ||
) | ||
} | ||
|
||
/* --- Documentation --------------------------------------------------------------------------- */ | ||
|
||
// export const getDocumentationProps = UpdateResumeScreenProps.introspect() | ||
|
||
/* --- Exports --------------------------------------------------------------------------------- */ | ||
|
||
export default UpdateResumeScreen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
export { ResumeScreen, TResumeScreenProps } from './ResumeScreen' | ||
export { UpdateResumeScreen, TUpdateResumeScreenProps } from './UpdateResumeScreen' | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters