Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions src/api/task/get-task-detail.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
import instance from "@/utils/axios";
import { notFound } from "next/navigation";

export const fetchTaskDetail = async (
groupId: number,
taskListId: number,
taskId: number,
token: string
) => {
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/groups/${groupId}/task-lists/${taskListId}/tasks/${taskId}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
}
);

if (response.status === 404) notFound();

return response.json();
} catch (error) {
throw error;
}
};

/**
* @author hwitae
Expand Down
24 changes: 0 additions & 24 deletions src/api/task/get-task-list.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,6 @@
import { TaskList } from "@/types/taskList";
import instance from "@/utils/axios";

export const fetchTaskList = async (
groupId: number,
taskListId: number,
token: string
) => {
try {
const response = await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/groups/${groupId}/task-lists/${taskListId}`,
{
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
}
);

return response.json();
} catch (error) {
console.error(error);
throw error;
}
};

export const getTaskList = async (
groupId: number,
taskListId: number,
Expand Down
10 changes: 10 additions & 0 deletions src/app/[groupId]/tasklist/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { Metadata } from "next";
import { ReactNode } from "react";

export const metadata: Metadata = {
title: "할 일 목록",
description: "할 일을 확인할 수 있습니다.",
robots: {
index: false,
follow: false,
},
};

const Layout = ({
children,
task,
Expand Down
77 changes: 0 additions & 77 deletions src/app/[groupId]/tasklist/page.tsx
Original file line number Diff line number Diff line change
@@ -1,81 +1,4 @@
import { Metadata } from "next";
import TaskList from "./_components/task-list";
import { cookies } from "next/headers";
import { fetchTaskList } from "@/api/task/get-task-list";
import { fetchTaskDetail } from "@/api/task/get-task-detail";

export const generateMetadata = async ({
params,
searchParams,
}: {
params: Promise<{ groupId: string }>;
searchParams: Promise<{ list: string; task: string | undefined }>;
}): Promise<Metadata> => {
const { groupId } = await params;
const { list, task } = await searchParams;
const cookieStore = await cookies();
const token = cookieStore.get("accessToken")?.value;

if (!token) {
return {
title: "할 일 목록",
description: "할 일을 확인할 수 있습니다.",
};
}

if (task) {
const taskDetail = await fetchTaskDetail(
Number(groupId),
Number(list),
Number(task),
token
);

return {
title: `${taskDetail.name ? taskDetail.name : "페이지를 찾을 수 없습니다."} - 할 일 상세`,
description: `${taskDetail.name ? `${taskDetail.name}의 상세 정보를 확인할 수 있습니다.` : "페이지를 찾을 수 없습니다."}`,
openGraph: {
title: `${taskDetail.name ? taskDetail.name : "페이지를 찾을 수 없습니다."} - 할 일 상세 | Coworkers`,
description: `${taskDetail.name ? `${taskDetail.name}의 상세 정보를 확인할 수 있습니다.` : "페이지를 찾을 수 없습니다."}`,
type: "website",
url: `https://coworkers-pied.vercel.app/${groupId}/tasklist?list=${list}&task=${task}`,
locale: "ko_KR",
siteName: "Coworkers",
images: [
{
url: "https://sprint-fe-project.s3.ap-northeast-2.amazonaws.com/Coworkers/user/2449/open_graph.jpg",
width: 1200,
height: 630,
alt: "Coworkers",
},
],
},
};
}

const response = await fetchTaskList(Number(groupId), Number(list), token);

return {
title: `${response.name ? response.name : "할 일 목록 선택"} - 할 일 목록`,
description: `${response.name ? `${response.name}의 할 일을 확인할 수 있습니다.` : "페이지를 찾을 수 없습니다."}`,
openGraph: {
title: `${response.name ? response.name : "페이지를 찾을 수 없습니다."} - 할 일 목록 | Coworkers`,
description: `${response.name ? `${response.name}의 할 일을 확인할 수 있습니다.` : "페이지를 찾을 수 없습니다."}`,
type: "website",
url: `https://coworkers-pied.vercel.app/${groupId}/tasklist?list=${list}`,
locale: "ko_KR",
siteName: "Coworkers",
images: [
{
url: "https://sprint-fe-project.s3.ap-northeast-2.amazonaws.com/Coworkers/user/2449/open_graph.jpg",
width: 1200,
height: 630,
alt: "Coworkers",
},
],
},
};
};

const Page = () => {
return <TaskList />;
Expand Down
Loading