Skip to content

Commit

Permalink
🐛 fix kakao share
Browse files Browse the repository at this point in the history
  • Loading branch information
w00khyung committed Dec 16, 2023
1 parent 44009bc commit 4f1fa50
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 64 deletions.
28 changes: 16 additions & 12 deletions app/(route)/alarm/page.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { UserContextProvider } from '@/app/_components/providers/UserProvider'

import BackButton from './_components/BackButton'
import RequestAlarm from './_components/requestAlarm'

export default function AlarmPage() {
return (
<main className='flex flex-col gap-3'>
<header className='flex items-center justify-between px-3 py-1'>
<BackButton />
<h1 className='text-2xl'>알림</h1>
<div className='w-9' />
</header>
<UserContextProvider>
<main className='flex flex-col gap-3'>
<header className='flex items-center justify-between px-3 py-1'>
<BackButton />
<h1 className='text-2xl'>알림</h1>
<div className='w-9' />
</header>

<div className='flex flex-col gap-3 px-4 pb-6'>
<RequestAlarm />
<RequestAlarm />
<RequestAlarm />
</div>
</main>
<div className='flex flex-col gap-3 px-4 pb-6'>
<RequestAlarm />
<RequestAlarm />
<RequestAlarm />
</div>
</main>
</UserContextProvider>
)
}
3 changes: 1 addition & 2 deletions app/(route)/challenge/_components/ChallengeFormDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ export default function ChallengeFormDialog() {
},
{
onSuccess: ({ data: { challengeId } }) => {
console.log('challengeId', challengeId)
share.kakao({
title: `${user.nickname}님이 초대장을 보냈어요!`,
description: '1:1 목표 매칭 서비스',
imageUrl: 'https://dodals3.s3.ap-northeast-2.amazonaws.com/asset/dodaldodal_square.png',
link: `https://dodaldodal-frontend-vercel.app/challenge/${challengeId}`,
sendUrl: `https://dodaldodal-frontend-vercel.app/challenge/${challengeId}`,
})
},
}
Expand Down
12 changes: 6 additions & 6 deletions app/(route)/challenge/_utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ export const share = {
title,
description,
imageUrl,
link,
sendUrl,
}: {
title: string
description: string
imageUrl: string
link: string
sendUrl: string
}) => {
const { Kakao } = window
if (!Kakao.isInitialized()) {
Expand All @@ -22,16 +22,16 @@ export const share = {
description,
imageUrl,
link: {
mobileWebUrl: link,
webUrl: link,
mobileWebUrl: sendUrl,
webUrl: sendUrl,
},
},
buttons: [
{
title: '웹으로 보기',
link: {
mobileWebUrl: link,
webUrl: link,
mobileWebUrl: sendUrl,
webUrl: sendUrl,
},
},
],
Expand Down
39 changes: 21 additions & 18 deletions app/(route)/challenge/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@
import { useRouter } from 'next/navigation'
import Script from 'next/script'

import { UserContextProvider } from '@/app/_components/providers/UserProvider'
import BottomNavigation from '@/app/_components/shared/bottom-navigation'
import Header from '@/app/_components/shared/header'

export default function Layout({ children }: { children: React.ReactNode }) {
const router = useRouter()

return (
<main className='h-full bg-challenge-background bg-cover bg-center bg-no-repeat'>
<Header>
<Header.BackIcon
onClick={() => {
router.back()
}}
/>
<Header.Title>챌린지</Header.Title>
<div className='w-9' />
</Header>
{children}
<BottomNavigation selected='challenge' />
<Script
src='https://t1.kakaocdn.net/kakao_js_sdk/2.5.0/kakao.min.js'
integrity='sha384-kYPsUbBPlktXsY6/oNHSUDZoTX6+YI51f63jCPEIPFP09ttByAdxd2mEjKuhdqn4'
crossOrigin='anonymous'
></Script>
</main>
<UserContextProvider>
<main className='h-full bg-challenge-background bg-cover bg-center bg-no-repeat'>
<Header>
<Header.BackIcon
onClick={() => {
router.back()
}}
/>
<Header.Title>챌린지</Header.Title>
<div className='w-9' />
</Header>
{children}
<BottomNavigation selected='challenge' />
<Script
src='https://t1.kakaocdn.net/kakao_js_sdk/2.5.0/kakao.min.js'
integrity='sha384-kYPsUbBPlktXsY6/oNHSUDZoTX6+YI51f63jCPEIPFP09ttByAdxd2mEjKuhdqn4'
crossOrigin='anonymous'
></Script>
</main>
</UserContextProvider>
)
}
27 changes: 15 additions & 12 deletions app/(route)/invitation/[id]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
'use client'

import { UserContextProvider } from '@/app/_components/providers/UserProvider'
import Header from '@/app/_components/shared/header'

export default function layout({ children }: { children: React.ReactNode }) {
return (
<main className='h-full pt-20'>
<Header className='bg-dodal-main'>
<div className='w-9' />
<Header.Title>초대장 도착</Header.Title>
<Header.Close
onClick={() => {
window.close()
}}
/>
</Header>
{children}
</main>
<UserContextProvider>
<main className='h-full pt-20'>
<Header className='bg-dodal-main'>
<div className='w-9' />
<Header.Title>초대장 도착</Header.Title>
<Header.Close
onClick={() => {
window.close()
}}
/>
</Header>
{children}
</main>
</UserContextProvider>
)
}
21 changes: 12 additions & 9 deletions app/(route)/me/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { UserContextProvider } from '@/app/_components/providers/UserProvider'
import BottomNavigation from '@/app/_components/shared/bottom-navigation'
import Header from '@/app/_components/shared/header'

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<main className='h-full'>
<Header>
<div />
<Header.Title>MY</Header.Title>
<div />
</Header>
{children}
<BottomNavigation selected='me' />
</main>
<UserContextProvider>
<main className='h-full'>
<Header>
<div />
<Header.Title>MY</Header.Title>
<div />
</Header>
{children}
<BottomNavigation selected='me' />
</main>
</UserContextProvider>
)
}
5 changes: 1 addition & 4 deletions app/_components/providers/CoreProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ import { useAxiosInterceptor } from '@/app/_hooks/useAxiosInterceptor'

import AxiosProvider from './AxiosInterceptorProvider'
import QueryClientProvider from './QueryClientProvider'
import { UserContextProvider } from './UserProvider'

export default function CoreProvider({ children }: { children: React.ReactNode }) {
useAxiosInterceptor()

return (
<AxiosProvider>
<QueryClientProvider>
<UserContextProvider>{children}</UserContextProvider>
</QueryClientProvider>
<QueryClientProvider>{children}</QueryClientProvider>
</AxiosProvider>
)
}
28 changes: 28 additions & 0 deletions app/_service/challenge/challenge.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,31 @@ export interface CreateChallengeParams {
export interface CreateChallengeResponse {
challengeId: number
}

export interface GetUpcomingChallengeParams {
challengeId: number
}

export interface Challenge {
id: number
name: string
category: Category
authentication_method: string
reward: string
is_deleted: 0
created_at: '2023-12-16T13:59:18.000Z'
updated_at: '2023-12-16T13:59:18.000Z'
target_count: 10
challenge_status: 'WAITING'
}

export interface GetUpcomingChallengeResponse {
challengeId: number
name: string
category: Category
authenticationMethod: string
reward: string
champion: Champion
explorationCount: number
certificatedCount: number
}
12 changes: 11 additions & 1 deletion app/_service/challenge/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import api from '../core/api'

import { type CreateChallengeResponse, type CreateChallengeParams, type GetTodayStatus } from './challenge.types'
import {
type CreateChallengeResponse,
type CreateChallengeParams,
type GetTodayStatus,
type GetUpcomingChallengeParams,
type GetUpcomingChallengeResponse,
} from './challenge.types'

export const getTodayStatus = () => {
return api.get<GetTodayStatus>('/challenges/today')
Expand All @@ -14,3 +20,7 @@ export const createChallenge = ({ name, category, authenticationMethod, reward }
reward,
})
}

export const getUpcomingChallenge = ({ challengeId }: GetUpcomingChallengeParams) => {
return api.get<GetUpcomingChallengeResponse>(`/challenges/upcoming/${challengeId}`)
}

0 comments on commit 4f1fa50

Please sign in to comment.