Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api/landing): feat: add lading page api #122

Merged
merged 1 commit into from
Jan 28, 2024
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
4 changes: 4 additions & 0 deletions api/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import { HTTP_METHOD } from "../shared";

const authUserKey = process.env.NEXT_PUBLIC_AUTH_USER_KEY as string;

export interface RequestData {
message: string;
}

const handleRequest = (config: AxiosRequestConfig): AxiosRequestConfig => {
const localStorage = new LocalStorage();
const token = localStorage.get(authUserKey) ?? "unauthorized";
Expand Down
5 changes: 1 addition & 4 deletions api/detail/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import httpClient from "@/api/core";

export interface RequestData {
message: string;
}
import type { RequestData } from "@/api/core";

export interface DetailResponseData extends RequestData {
data: ArtInfo;
Expand Down
1 change: 1 addition & 0 deletions api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from "./auth";
export * from "./detail";
export * from "./comment";
export * from "./reserve";
export * from "./landing";
18 changes: 18 additions & 0 deletions api/landing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import httpClient from "@/api/core";
import type { RequestData } from "@/api/core";
import type { ArtInfo } from "@/api/detail";

export interface LandingArtListResponseData extends RequestData {
data: LandingList;
}

export interface LandingList {
hotRanking: ArtInfo[];
ticketOpen: ArtInfo[];
}

export const getLandingArtList = async () => {
const response = await httpClient.get<LandingArtListResponseData>(`/arts`);

return response.data;
};
110 changes: 27 additions & 83 deletions components/domains/landing-page/LandingPage.tsx
Original file line number Diff line number Diff line change
@@ -1,106 +1,50 @@
import styled, { css } from "styled-components";
import { Ticket } from "@/components/domains/landing-page/Ticket";
import mockImage from "@/fixture/ticket-poster.jpeg";
import { useGetLandingArtList } from "@/queries";
import { ListHeader } from "./ListHeader";

const tickets: any[] = [
{
id: 1,
image: mockImage,
genre: "장르",
title: "제목",
startDate: "2023-11-16T08:30:00Z",
endDate: "2023-11-29T08:30:00Z",
},
{
id: 2,
image: mockImage,
genre: "장르2",
title: "제목3",
startDate: "2023-11-16T08:30:00Z",
endDate: "2023-11-29T08:30:00Z",
},
{
id: 3,
image: mockImage,
genre: "장르3",
title: "제목34",
startDate: "2023-11-16T08:30:00Z",
endDate: "2023-11-29T08:30:00Z",
},
{
id: 4,
image: mockImage,
genre: "장르3",
title: "제목34",
startDate: "2023-11-16T08:30:00Z",
endDate: "2023-11-29T08:30:00Z",
},
];

const hotRankings: any[] = [
{
id: 1,
image: mockImage,
genre: "장르",
title: "제목",
startDate: "2023-11-16T08:30:00Z",
endDate: "2023-11-29T08:30:00Z",
},
{
id: 2,
image: mockImage,
genre: "장르2",
title: "제목3",
startDate: "2023-11-16T08:30:00Z",
endDate: "2023-11-29T08:30:00Z",
},
{
id: 3,
image: mockImage,
genre: "장르3",
title: "제목34",
startDate: "2023-11-16T08:30:00Z",
endDate: "2023-11-29T08:30:00Z",
},
];

// TODO: 진짜 이미지 테스트 필요!!
export function LandingPage() {
const { data } = useGetLandingArtList();

return (
<Container>
<ListHeader
title="HOT RANKING"
description="서울예술대학교의 인기있는 작품들을 모아놓은 섹션 중 하나입니다."
/>
<HotRankingWrapper>
{hotRankings.map((rank, index) => (
<Ticket
ranking={index + 1}
key={rank.id}
thumbnail={rank.image}
genre={rank.genre}
title={rank.title}
startDate={rank.startDate}
endDate={rank.endDate}
/>
))}
{data?.hotRanking &&
data.hotRanking.map((rank, index) => (
<Ticket
ranking={index + 1}
key={rank.id}
thumbnail={mockImage}
genre={rank.genre}
title={rank.title}
startDate={rank.startDate}
endDate={rank.endDate}
/>
))}
</HotRankingWrapper>

<ListHeader
title="TICKET"
description="현재 티켓 예매가 가능한 작품입니다."
/>
<TicketsWrapper>
{tickets.map((rank) => (
<Ticket
key={rank.id}
thumbnail={rank.image}
genre={rank.genre}
title={rank.title}
startDate={rank.startDate}
endDate={rank.endDate}
/>
))}
{data?.ticketOpen &&
data.ticketOpen.map((rank) => (
<Ticket
key={rank.id}
thumbnail={mockImage}
genre={rank.genre}
title={rank.title}
startDate={rank.startDate}
endDate={rank.endDate}
/>
))}
</TicketsWrapper>
<SeeMoreButton>더보기</SeeMoreButton>
<ListHeader
Expand Down
3 changes: 2 additions & 1 deletion components/domains/landing-page/Ticket.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useMemo } from "react";
import type { StaticImageData } from "next/image";
import Image from "next/image";
import dayjs from "dayjs";
import styled from "styled-components";
import Typography from "@/components/common/text/Typography";

interface TicketProps {
thumbnail: string;
thumbnail: string | StaticImageData;
genre: string;
title: string;
startDate: string;
Expand Down
1 change: 1 addition & 0 deletions queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from "./auth";
export * from "./detail";
export * from "./comment";
export * from "./reserve";
export * from "./landing";
9 changes: 9 additions & 0 deletions queries/landing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useQuery } from "@tanstack/react-query";
import { getLandingArtList } from "@/api";

export const useGetLandingArtList = () => {
return useQuery({
queryKey: ["landing"],
queryFn: () => getLandingArtList(),
});
};
Loading