-
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(bottle, ui): user self introduction (#63)
* fix(bottle): removed deprecated code * fix(bottle): removed deprecated code * feat(bottle): funnel setup * refactor(bottle, ui): change texfield component name to input * feat(ui): textarea 컴포넌트 구현 * feat(ui): add maxLength prop for textarea * refactor(bottle): make SelectedProfile component customizable * feat(bottle): create introduction * feat(bottle): introduction create mutation * feat(ui): plus icon asset * feat(bottle): edit introduction
- Loading branch information
Showing
41 changed files
with
570 additions
and
140 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
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
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,10 @@ | ||
import { getServerSideTokens } from '@/features/server/serverSideTokens'; | ||
import { ServerFetchBoundary } from '@/store/query/ServerFetchBoundary'; | ||
import { currentUserProfileQueryOptions } from '@/store/query/useCurrentUserProfileQuery'; | ||
import type { ReactNode } from 'react'; | ||
|
||
export default async function CreateIntroLayout({ children }: { children: ReactNode }) { | ||
const tokens = getServerSideTokens(); | ||
|
||
return <ServerFetchBoundary fetchOptions={currentUserProfileQueryOptions(tokens)}>{children}</ServerFetchBoundary>; | ||
} |
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,58 @@ | ||
'use client'; | ||
|
||
import { Header } from '@/components/common/header'; | ||
import { Stepper } from '@/components/common/stepper'; | ||
import { Images } from '@/components/intro/images'; | ||
import { Introduction } from '@/components/intro/introduction'; | ||
import { ProfileLayout } from '@/components/profile/layout'; | ||
import { AppBridgeMessageType, useAppBridge } from '@/features/app-bridge'; | ||
import { useFunnel } from '@/features/funnel'; | ||
import { Introduction as IntroductionType } from '@/models/introduction'; | ||
import { useIntroductionMutation } from '@/store/mutation/useIntroductionMutation'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
const MAX_STEPS = 2; | ||
|
||
type CreateIntroFunnelValues = { | ||
introduction: IntroductionType; | ||
// FIXME: depends on server API | ||
imageUrl: string; | ||
}; | ||
|
||
export default function CreateIntroPage() { | ||
const { send } = useAppBridge(); | ||
const { mutateAsync } = useIntroductionMutation({ type: 'create' }); | ||
const router = useRouter(); | ||
|
||
const { onNextStep, currentStep, getValue } = useFunnel<CreateIntroFunnelValues>('/intro/create'); | ||
|
||
const steps = [ | ||
<ProfileLayout key={1}> | ||
<Header | ||
onGoBack={() => { | ||
send({ type: AppBridgeMessageType.WEB_VIEW_CLOSE }); | ||
}} | ||
/> | ||
<Stepper current={1} max={MAX_STEPS} /> | ||
<Introduction | ||
initialValue={getValue('introduction')} | ||
onNext={async introduction => { | ||
try { | ||
await mutateAsync(introduction); | ||
onNextStep('introduction', introduction); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}} | ||
ctaButtonText="다음" | ||
/> | ||
</ProfileLayout>, | ||
<ProfileLayout key={1}> | ||
<Header onGoBack={router.back} /> | ||
<Stepper current={2} max={MAX_STEPS} /> | ||
<Images initialValue={getValue('imageUrl')} onNext={() => {}} ctaButtonText="완료" /> | ||
</ProfileLayout>, | ||
]; | ||
|
||
return <>{steps[currentStep - 1]}</>; | ||
} |
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
10 changes: 0 additions & 10 deletions
10
apps/bottle/src/app/profile/create/CreateProfileProvider.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,22 +1,13 @@ | ||
import { getServerSideTokens } from '@/features/server/serverSideTokens'; | ||
import { StepProvider } from '@/features/steps/StepProvider'; | ||
import { ServerFetchBoundary } from '@/store/query/ServerFetchBoundary'; | ||
import { regionsQueryOptions } from '@/store/query/useRegionsQuery'; | ||
import { userInfoQueryOptions } from '@/store/query/useUserInfoQuery'; | ||
import { ReactNode, Suspense } from 'react'; | ||
import type { ReactNode } from 'react'; | ||
|
||
export default async function CreateProfileLayout({ children }: { children: ReactNode }) { | ||
const tokens = getServerSideTokens(); | ||
|
||
const serverFetchOptions = [regionsQueryOptions(tokens), userInfoQueryOptions(tokens)]; | ||
|
||
return ( | ||
<Suspense> | ||
<ServerFetchBoundary fetchOptions={serverFetchOptions}> | ||
<StepProvider maxStep={10} uri="/profile/create"> | ||
{children} | ||
</StepProvider> | ||
</ServerFetchBoundary> | ||
</Suspense> | ||
); | ||
return <ServerFetchBoundary fetchOptions={serverFetchOptions}>{children}</ServerFetchBoundary>; | ||
} |
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
31 changes: 31 additions & 0 deletions
31
apps/bottle/src/app/profile/edit/(items)/introduction/page.tsx
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,31 @@ | ||
'use client'; | ||
|
||
import { Introduction } from '@/components/intro/introduction'; | ||
import { useIntroductionMutation } from '@/store/mutation/useIntroductionMutation'; | ||
import { useCurrentUserProfileQuery } from '@/store/query/useCurrentUserProfileQuery'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
export default function IntroductionEditPage() { | ||
const { | ||
data: { introduction }, | ||
} = useCurrentUserProfileQuery(); | ||
const router = useRouter(); | ||
|
||
const { mutate } = useIntroductionMutation({ type: 'edit' }); | ||
|
||
const initialAnswer = introduction[0]?.answer ?? ''; | ||
|
||
return ( | ||
<Introduction | ||
initialValue={introduction} | ||
onNext={introduction => { | ||
if (introduction[0]?.answer === initialAnswer) { | ||
router.back(); | ||
return; | ||
} | ||
mutate(introduction); | ||
}} | ||
ctaButtonText="완료" | ||
/> | ||
); | ||
} |
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
Oops, something went wrong.