Skip to content

Commit

Permalink
[#90] Feat: 업로드한 짤 페이지 추천 태그 api 구현 및 적용 (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-Jaemin420 authored Mar 5, 2024
1 parent 383ea90 commit 39fbba5
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 17 deletions.
11 changes: 10 additions & 1 deletion src/apis/tag.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import http from "@/apis/core";
import { GetTagsResponse, GetTopTagsFromLikedResponse } from "@/types/tag.dto";
import {
GetTagsResponse,
GetTopTagsFromUploadedResponse,
GetTopTagsFromLikedResponse,
} from "@/types/tag.dto";

export const getSearchTag = (tag: string) =>
http.get<GetTagsResponse>({
Expand All @@ -9,6 +13,11 @@ export const getSearchTag = (tag: string) =>
},
});

export const getTopTagsFromUploaded = () =>
http.get<GetTopTagsFromUploadedResponse>({
url: "/v1/tag/me/upload",
});

export const getTopTagsFromLiked = () =>
http.get<GetTopTagsFromLikedResponse>({
url: "/v1/tag/me/like",
Expand Down
16 changes: 16 additions & 0 deletions src/hooks/api/tag/useGetTopTagsFromUploaded.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { useSuspenseQuery } from "@tanstack/react-query";
import { getTopTagsFromUploaded } from "@/apis/tag";

const useGetTopTagsFromUploaded = () => {
const { data, ...rest } = useSuspenseQuery({
queryKey: ["topTagsFromUploaded"],
queryFn: getTopTagsFromUploaded,
});

return {
topTags: data,
...rest,
};
};

export default useGetTopTagsFromUploaded;
28 changes: 16 additions & 12 deletions src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { Route as rootRoute } from "./routes/__root"
import { Route as LayoutWithChatImport } from "./routes/_layout-with-chat"
import { Route as UploadZzalIndexImport } from "./routes/upload-zzal/index"
import { Route as LayoutWithChatIndexImport } from "./routes/_layout-with-chat/index"
import { Route as LayoutWithChatMyUploadedZzalsRouteImport } from "./routes/_layout-with-chat/my-uploaded-zzals/route"
import { Route as LayoutWithChatMyLikedZzalsRouteImport } from "./routes/_layout-with-chat/my-liked-zzals/route"
import { Route as AdminReportsIndexImport } from "./routes/admin/reports/index"
import { Route as LayoutWithChatMyUploadedZzalIndexImport } from "./routes/_layout-with-chat/my-uploaded-zzal/index"
import { Route as AdminReportsImageIdIndexImport } from "./routes/admin/reports/$imageId/index"

// Create Virtual Routes
Expand All @@ -44,6 +44,16 @@ const LayoutWithChatIndexRoute = LayoutWithChatIndexImport.update({
getParentRoute: () => LayoutWithChatRoute,
} as any)

const LayoutWithChatMyUploadedZzalsRouteRoute =
LayoutWithChatMyUploadedZzalsRouteImport.update({
path: "/my-uploaded-zzals",
getParentRoute: () => LayoutWithChatRoute,
} as any).lazy(() =>
import("./routes/_layout-with-chat/my-uploaded-zzals/route.lazy").then(
(d) => d.Route,
),
)

const LayoutWithChatMyLikedZzalsRouteRoute =
LayoutWithChatMyLikedZzalsRouteImport.update({
path: "/my-liked-zzals",
Expand All @@ -59,12 +69,6 @@ const AdminReportsIndexRoute = AdminReportsIndexImport.update({
getParentRoute: () => rootRoute,
} as any)

const LayoutWithChatMyUploadedZzalIndexRoute =
LayoutWithChatMyUploadedZzalIndexImport.update({
path: "/my-uploaded-zzal/",
getParentRoute: () => LayoutWithChatRoute,
} as any)

const AdminReportsAdminReportsPendingComponentRoute =
AdminReportsAdminReportsPendingComponentImport.update({
path: "/admin/reports/AdminReports",
Expand Down Expand Up @@ -93,6 +97,10 @@ declare module "@tanstack/react-router" {
preLoaderRoute: typeof LayoutWithChatMyLikedZzalsRouteImport
parentRoute: typeof LayoutWithChatImport
}
"/_layout-with-chat/my-uploaded-zzals": {
preLoaderRoute: typeof LayoutWithChatMyUploadedZzalsRouteImport
parentRoute: typeof LayoutWithChatImport
}
"/_layout-with-chat/": {
preLoaderRoute: typeof LayoutWithChatIndexImport
parentRoute: typeof LayoutWithChatImport
Expand All @@ -105,10 +113,6 @@ declare module "@tanstack/react-router" {
preLoaderRoute: typeof AdminReportsAdminReportsPendingComponentImport
parentRoute: typeof rootRoute
}
"/_layout-with-chat/my-uploaded-zzal/": {
preLoaderRoute: typeof LayoutWithChatMyUploadedZzalIndexImport
parentRoute: typeof LayoutWithChatImport
}
"/admin/reports/": {
preLoaderRoute: typeof AdminReportsIndexImport
parentRoute: typeof rootRoute
Expand All @@ -125,8 +129,8 @@ declare module "@tanstack/react-router" {
export const routeTree = rootRoute.addChildren([
LayoutWithChatRoute.addChildren([
LayoutWithChatMyLikedZzalsRouteRoute,
LayoutWithChatMyUploadedZzalsRouteRoute,
LayoutWithChatIndexRoute,
LayoutWithChatMyUploadedZzalIndexRoute,
]),
UploadZzalIndexRoute,
AdminReportsAdminReportsPendingComponentRoute,
Expand Down
24 changes: 24 additions & 0 deletions src/routes/_layout-with-chat/my-uploaded-zzals/route.lazy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { createLazyFileRoute } from "@tanstack/react-router";
import TagSearchForm from "@/components/common/SearchTag/TagSearchForm";
import TagBadge from "@/components/common/TagBadge";
import useGetTopTagsFromUploaded from "@/hooks/api/tag/useGetTopTagsFromUploaded";

const MyUploadedZzals = () => {
const { topTags } = useGetTopTagsFromUploaded();

return (
<div className="flex w-full flex-col items-center">
<div className="mb-10pxr min-w-650pxr pl-10pxr">
<div className="mb-8pxr font-semibold">내가 가장 많이 사용한 태그</div>
{topTags.map(({ tagId, tagName }) => (
<TagBadge key={tagId} content={tagName} isClickable className="mr-5pxr" />
))}
</div>
<TagSearchForm />
</div>
);
};

export const Route = createLazyFileRoute("/_layout-with-chat/my-uploaded-zzals")({
component: MyUploadedZzals,
});
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createFileRoute } from "@tanstack/react-router";

const MyUploadedZzal = () => {
return <div>업로드 한 짤 페이지</div>;
const PendingComponent = () => {
return <div>pending</div>;
};

export const Route = createFileRoute("/_layout-with-chat/my-uploaded-zzal/")({
component: MyUploadedZzal,
export const Route = createFileRoute("/_layout-with-chat/my-uploaded-zzals")({
pendingComponent: PendingComponent,
});
2 changes: 2 additions & 0 deletions src/types/tag.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ import { Tag } from "./tag";

export type GetTagsResponse = Tag[];

export type GetTopTagsFromUploadedResponse = Tag[];

export type GetTopTagsFromLikedResponse = Tag[];

0 comments on commit 39fbba5

Please sign in to comment.