-
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.
- Loading branch information
Showing
13 changed files
with
157 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import { ProfileLayout } from '@/components/profile/layout'; | ||
import { getServerSideTokens } from '@/features/server/serverSideTokens'; | ||
import { ServerFetchBoundary } from '@/store/query/ServerFetchBoundary'; | ||
import { bottlesQueryOptions } from '@/store/query/useBottlesQuery'; | ||
import { recommendationBottlesQueryOptions } from '@/store/query/useRecommendationBottlesQuery'; | ||
import { userInfoQueryOptions } from '@/store/query/useUserInfoQuery'; | ||
import { Suspense } from 'react'; | ||
import { HeaderArea } from './HeaderArea'; | ||
import { Recommendations } from './Recommendations'; | ||
|
||
export default function RecommendationsPage() { | ||
const tokens = getServerSideTokens(); | ||
const serverFetchOptions = [userInfoQueryOptions(tokens), bottlesQueryOptions(tokens)]; | ||
const serverFetchOptions = [userInfoQueryOptions(tokens), recommendationBottlesQueryOptions(tokens)]; | ||
|
||
return ( | ||
<ProfileLayout> | ||
<ProfileLayout hasCTAButton={false}> | ||
<HeaderArea /> | ||
<ServerFetchBoundary fetchOptions={serverFetchOptions}> | ||
<Recommendations /> | ||
</ServerFetchBoundary> | ||
<Suspense> | ||
<ServerFetchBoundary fetchOptions={serverFetchOptions}> | ||
<Recommendations /> | ||
</ServerFetchBoundary> | ||
</Suspense> | ||
</ProfileLayout> | ||
); | ||
} |
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 @@ | ||
'use client'; | ||
|
||
import { Header } from '@/components/common/header'; | ||
import { AppBridgeMessageType, useAppBridge } from '@/features/app-bridge'; | ||
|
||
export function HeaderArea() { | ||
const { send } = useAppBridge(); | ||
|
||
return ( | ||
<Header | ||
onGoBack={() => { | ||
send({ type: AppBridgeMessageType.WEB_VIEW_CLOSE }); | ||
}} | ||
/> | ||
); | ||
} |
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,35 @@ | ||
'use client'; | ||
|
||
import { BottleCard } from '@/components/common/bottle-card'; | ||
import { ProfileLayout } from '@/components/profile/layout'; | ||
import { useSentBottlesQuery } from '@/store/query/useSentBottlesQuery'; | ||
import { useUserInfoQuery } from '@/store/query/useUserInfoQuery'; | ||
import { spacings } from '@bottlesteam/ui'; | ||
import { pick } from 'es-toolkit'; | ||
|
||
export function Sents() { | ||
const { data: currentUser } = useUserInfoQuery(); | ||
const { data: sentBottlesData } = useSentBottlesQuery(); | ||
|
||
console.log('DATA', sentBottlesData.sentBottles); | ||
|
||
return ( | ||
<> | ||
<ProfileLayout.Title>{`${currentUser.name}님을 마음에\n들어한 분들이에요`}</ProfileLayout.Title> | ||
<ProfileLayout.Subtitle style={{ marginTop: spacings.sm }}> | ||
시간 내에 보틀을 열지 않으면 사라져요 | ||
</ProfileLayout.Subtitle> | ||
<section style={{ marginTop: spacings.xxl, display: 'flex', flexDirection: 'column', gap: spacings.md }}> | ||
{sentBottlesData.sentBottles.map(bottle => ( | ||
<BottleCard key={bottle.id}> | ||
<BottleCard.TimeTag>{bottle.expiredAt}</BottleCard.TimeTag> | ||
<BottleCard.Introduction>{bottle.introduction[0]?.answer}</BottleCard.Introduction> | ||
<BottleCard.UserInformation | ||
{...pick(bottle, ['userName', 'age', 'mbti', 'userImageUrl', 'likeEmoji', 'lastActivatedAt'])} | ||
/> | ||
</BottleCard> | ||
))} | ||
</section> | ||
</> | ||
); | ||
} |
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,24 @@ | ||
import { ProfileLayout } from '@/components/profile/layout'; | ||
import { getServerSideTokens } from '@/features/server/serverSideTokens'; | ||
import { ServerFetchBoundary } from '@/store/query/ServerFetchBoundary'; | ||
import { sentBottlesQueryOptions } from '@/store/query/useSentBottlesQuery'; | ||
import { userInfoQueryOptions } from '@/store/query/useUserInfoQuery'; | ||
import { Suspense } from 'react'; | ||
import { HeaderArea } from './HeaderArea'; | ||
import { Sents } from './Sents'; | ||
|
||
export default function SentBottlesPage() { | ||
const tokens = getServerSideTokens(); | ||
const serverFetchOptions = [userInfoQueryOptions(tokens), sentBottlesQueryOptions(tokens)]; | ||
|
||
return ( | ||
<ProfileLayout hasCTAButton={false}> | ||
<HeaderArea /> | ||
<Suspense> | ||
<ServerFetchBoundary fetchOptions={serverFetchOptions}> | ||
<Sents /> | ||
</ServerFetchBoundary> | ||
</Suspense> | ||
</ProfileLayout> | ||
); | ||
} |
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
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
15 changes: 3 additions & 12 deletions
15
apps/bottle/src/store/query/useRecommendationBottlesQuery.ts
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,20 @@ | ||
import { createInit, GET } from '@/features/server'; | ||
import { Tokens } from '@/features/server/auth'; | ||
import { getClientSideTokens } from '@/features/server/clientSideTokens'; | ||
import { SentBottlePreview } from '@/models/bottle'; | ||
import { useSuspenseQuery, UseSuspenseQueryOptions } from '@tanstack/react-query'; | ||
|
||
interface SentBottlesQuery { | ||
sentBottles: SentBottlePreview[]; | ||
} | ||
|
||
export const sentBottlesQueryOptions = (tokens: Tokens): UseSuspenseQueryOptions<SentBottlesQuery> => ({ | ||
queryKey: ['bottles', 'sent'], | ||
queryFn: () => GET<SentBottlesQuery>(`/api/v2/bottles/sent`, tokens, createInit(tokens.accessToken)), | ||
// NOTE: should ALWAYS be stale | ||
staleTime: 0, | ||
}); | ||
|
||
export function useSentBottlesQuery() { | ||
return useSuspenseQuery(sentBottlesQueryOptions(getClientSideTokens())); | ||
} |