- {data.pages[0].filteredContents.empty ? (
- children
- ) : (
-
- {data.pages.map((page) => {
- const poseListData = 'filteredContents' in page ? page.filteredContents : page;
- return
;
- })}
-
- )}
- {data.pages[0]?.recommendation && (
- <>
-
이런 포즈는 어때요?
-
- {data.pages.map((page) => {
- const poseListData =
- 'recommendedContents' in page ? page.recommendedContents : page;
- return
;
- })}
-
- >
- )}
-
-
- );
+ // if ('filteredContents' in data.pages[0])
+ // return (
+ //
+ // {data.pages[0].filteredContents.empty ? (
+ // children
+ // ) : (
+ //
+ // {data.pages.map((page) => {
+ // const poseListData = 'filteredContents' in page ? page.filteredContents : page;
+ // return
;
+ // })}
+ //
+ // )}
+ // {data.pages[0]?.recommendation && (
+ // <>
+ //
이런 포즈는 어때요?
+ //
+ // {data.pages.map((page) => {
+ // const poseListData =
+ // 'recommendedContents' in page ? page.recommendedContents : page;
+ // return
;
+ // })}
+ //
+ // >
+ // )}
+ //
+ //
+ // );
return (
- {data.pages[0].empty ? (
+ {!data || data.contents.length === 0 ? (
children
) : (
- {data.pages.map(
- (page) => 'content' in page &&
- )}
+
)}
diff --git a/src/components/Feed/Photo.tsx b/src/components/Feed/Photo.tsx
index 71da91f..725bba7 100644
--- a/src/components/Feed/Photo.tsx
+++ b/src/components/Feed/Photo.tsx
@@ -5,22 +5,22 @@ import Link from 'next/link';
import { useState } from 'react';
import BookmarkButton from './BookmarkButton';
-import { PoseInfo } from '@/apis';
+import { PoseDataI } from '@/server/type';
interface PhotoI {
- data: PoseInfo;
+ data: PoseDataI;
}
export default function Photo({ data }: PhotoI) {
- const { imageKey, source, bookmarkCheck, poseId, width, height } = data;
+ const { people, cut, tags, source, sourceUrl, image, id } = data;
const [loaded, setLoaded] = useState(false);
return (
- {imageKey && (
+ {image && (
<>
-
+
- {loaded &&
}
- {loaded || (
-
- )}
+ {loaded &&
}
+ {loaded ||
}
>
)}
diff --git a/src/components/Feed/PhotoList.tsx b/src/components/Feed/PhotoList.tsx
index 6667310..5390494 100644
--- a/src/components/Feed/PhotoList.tsx
+++ b/src/components/Feed/PhotoList.tsx
@@ -1,16 +1,16 @@
+import { PoseDataI } from '@/server/type';
import Photo from './Photo';
-import { PoseFeedContents } from '@/apis';
interface PhotoList {
- data?: PoseFeedContents;
+ datas?: PoseDataI[];
}
-export default function PhotoList({ data }: PhotoList) {
- if (!data) return;
+export default function PhotoList({ datas }: PhotoList) {
+ if (!datas) return;
return (
<>
- {data.content.map((item) => (
-
+ {datas.map((data) => (
+
))}
>
);
diff --git a/src/components/Login/LoginModal.tsx b/src/components/Login/LoginModal.tsx
index 62b9fc3..97190d2 100644
--- a/src/components/Login/LoginModal.tsx
+++ b/src/components/Login/LoginModal.tsx
@@ -12,7 +12,8 @@ interface LoginModalProps {
export default function LoginModal({ onClose }: LoginModalProps) {
const router = useRouter();
const handleLogin = () => {
- router.push(KAKAO_AUTHORIZE);
+ alert('업데이트를 기다려주세요!');
+ // router.push(KAKAO_AUTHORIZE);
};
return (
@@ -21,9 +22,9 @@ export default function LoginModal({ onClose }: LoginModalProps) {
content={`로그인하면 북마크도 쓸 수 있어요!\n간편 로그인으로 3초만에 가입해요.`}
onClose={onClose}
>
-
+
-
window.open(URL.appstore)} />
+ {/* window.open(URL.appstore)} /> */}
);
diff --git a/src/database/index.ts b/src/database/index.ts
new file mode 100644
index 0000000..13e1577
--- /dev/null
+++ b/src/database/index.ts
@@ -0,0 +1,8 @@
+import { Client } from '@notionhq/client';
+
+export const notionClient = new Client({ auth: process.env.NOTION_API_KEY });
+
+export const NOTION_DATABASE = {
+ talk: process.env.NOTION_DATABASE_KEY_POSETALK || '',
+ data: process.env.NOTION_DATABASE_KEY_POSEDATA || '',
+} as const;
diff --git a/src/server/api.ts b/src/server/api.ts
new file mode 100644
index 0000000..cbc31f8
--- /dev/null
+++ b/src/server/api.ts
@@ -0,0 +1,18 @@
+import instance from './config';
+import { PoseDataI, PoseFeedResponseI, PosePickResponseI, PoseTalkResponseI } from './type';
+
+export const getPosePick = (peopleCount: number) =>
+ instance.get
(`/pose/pick/${peopleCount}`);
+
+export const getPoseTalk = () => instance.get('/pose/talk');
+
+export const getPoseFeed = (people: number, cut: number, tags: string) =>
+ instance.get(`/pose`, {
+ params: {
+ people,
+ cut,
+ tags,
+ },
+ });
+
+export const getPoseDetail = (id: string) => instance.get(`/pose/${id}`);
diff --git a/src/server/config.ts b/src/server/config.ts
new file mode 100644
index 0000000..fc8eaf6
--- /dev/null
+++ b/src/server/config.ts
@@ -0,0 +1,10 @@
+import axios from 'axios';
+
+import { BASE_SITE_URL } from '@/constants';
+
+const instance = axios.create({
+ baseURL: `${BASE_SITE_URL}/api`,
+ withCredentials: true,
+});
+
+export default instance;
diff --git a/src/server/type.ts b/src/server/type.ts
new file mode 100644
index 0000000..db7c435
--- /dev/null
+++ b/src/server/type.ts
@@ -0,0 +1,32 @@
+import { NextResponse } from 'next/server';
+
+// region response
+type ApiErrorT = {
+ error: string;
+};
+
+export type ApiResponse = NextResponse | NextResponse;
+
+// region interface
+export interface PoseTalkResponseI {
+ id: number;
+ keyword: string;
+}
+
+export interface PosePickResponseI {
+ imageUrl: string;
+}
+export interface PoseDataI {
+ id: string;
+ image: string;
+ people: number;
+ cut: number;
+ tags: string;
+ source: string | null;
+ sourceUrl: string | null;
+ bookmarkCheck?: boolean;
+}
+
+export interface PoseFeedResponseI {
+ contents: PoseDataI[];
+}
diff --git a/src/server/utils.ts b/src/server/utils.ts
new file mode 100644
index 0000000..849be5d
--- /dev/null
+++ b/src/server/utils.ts
@@ -0,0 +1,36 @@
+import {
+ FilesPropertyItemObjectResponse,
+ MultiSelectPropertyItemObjectResponse,
+ NumberPropertyItemObjectResponse,
+ PageObjectResponse,
+ UniqueIdPropertyItemObjectResponse,
+ UrlPropertyItemObjectResponse,
+} from '@notionhq/client/build/src/api-endpoints';
+import { PoseDataI } from './type';
+
+export function refinePoseDataFromPage(page: PageObjectResponse): PoseDataI | null {
+ const idProps = page.properties['id'] as UniqueIdPropertyItemObjectResponse;
+ const imageProps = page.properties['image'] as FilesPropertyItemObjectResponse;
+ const peopleProps = page.properties['people'] as NumberPropertyItemObjectResponse;
+ const cutProps = page.properties['cut'] as NumberPropertyItemObjectResponse;
+ const tagsProps = page.properties['tags'] as MultiSelectPropertyItemObjectResponse;
+ const sourceProps = page.properties['source'];
+ const sourceUrlProps = page.properties['source_url'] as UrlPropertyItemObjectResponse;
+
+ const imageFile = imageProps.files[0];
+
+ if (!(imageFile && 'file' in imageFile && 'url' in imageFile.file)) {
+ console.error(`No Image : ${idProps.unique_id.number}`);
+ return null;
+ }
+
+ return {
+ id: idProps.unique_id.number + '',
+ image: imageFile.file.url,
+ people: peopleProps.number ?? 0,
+ cut: cutProps.number ?? 0,
+ tags: tagsProps.multi_select.map((tag) => tag.name).join(','),
+ source: sourceProps.id,
+ sourceUrl: sourceUrlProps.url,
+ };
+}