diff --git a/public/favicon.svg b/public/favicon.svg
index e7b8dfb..aeb97e2 100644
--- a/public/favicon.svg
+++ b/public/favicon.svg
@@ -1 +1,9 @@
-
\ No newline at end of file
+
diff --git a/src/app/api.ts b/src/app/api.ts
index 9207500..7d72435 100644
--- a/src/app/api.ts
+++ b/src/app/api.ts
@@ -52,13 +52,13 @@ const baseQueryWithReauth = async (
}
);
- if (refreshResult.body.token) {
+ if (refreshResult.body?.token) {
const newAccessToken = refreshResult.body.token;
api.dispatch(setAccessToken(newAccessToken));
result = await baseQuery(args, api, extraOptions);
}
- if (refreshResult.header.code !== 200) {
+ if (refreshResult.header?.code === 400) {
window.location.href = "/auth";
}
}
@@ -119,8 +119,11 @@ export const api = createApi({
providesTags: [{ type: "LikedProjectIds", id: "LIST" }],
}),
- getMyAppliedProjects: build.query<{ projectIds: number[] }, null>({
+ getMyAppliedProjects: build.query({
query: () => "/applies/me",
+ transformResponse: (response: {
+ body: { "me applied projects": number[] };
+ }) => response.body["me applied projects"],
providesTags: [{ type: "AppliedProjectId", id: "LIST" }],
}),
@@ -379,6 +382,8 @@ export const api = createApi({
getProject: build.query({
query: ({ id }) => `/projects/${id}`,
+ transformResponse: (response: { body: { "project get": Project } }) =>
+ response.body["project get"],
providesTags: (result) =>
result
? [{ type: "Project", id: String(result.projectId) }]
diff --git a/src/assets/logo.svg b/src/assets/logo.svg
index e7b8dfb..aeb97e2 100644
--- a/src/assets/logo.svg
+++ b/src/assets/logo.svg
@@ -1 +1,9 @@
-
\ No newline at end of file
+
diff --git "a/src/assets/\343\205\220\343\205\243\343\205\207logo.svg" "b/src/assets/\343\205\220\343\205\243\343\205\207logo.svg"
new file mode 100644
index 0000000..e7b8dfb
--- /dev/null
+++ "b/src/assets/\343\205\220\343\205\243\343\205\207logo.svg"
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/components/post/PostCard.tsx b/src/components/post/PostCard.tsx
index a85c64d..79a8a8a 100644
--- a/src/components/post/PostCard.tsx
+++ b/src/components/post/PostCard.tsx
@@ -54,6 +54,8 @@ export default function PostCard({
const setDeletePost = api.useDeletePostMutation()[0];
const spoilerControlRef = useRef(null);
+ const { data: author } = api.useGetUserQuery(post.userId);
+
const closeSpoilerText = "숨기기";
const openSpoiler = () => {
if (
@@ -81,7 +83,7 @@ export default function PostCard({
-
+
{post.authorName}
diff --git a/src/components/post/TrendingPosts.tsx b/src/components/post/TrendingPosts.tsx
new file mode 100644
index 0000000..73f5b09
--- /dev/null
+++ b/src/components/post/TrendingPosts.tsx
@@ -0,0 +1,84 @@
+import {
+ Card,
+ Title,
+ Text,
+ Badge,
+ ScrollArea,
+ Group,
+ Center,
+ Button,
+ useMantineTheme,
+ createStyles,
+ Box,
+} from "@mantine/core";
+import { useMediaQuery } from "@mantine/hooks";
+import { IconHeart } from "@tabler/icons-react";
+import { api } from "app/api";
+import { useEffect, useState } from "react";
+import { Link } from "react-router-dom";
+
+const useStyles = createStyles((theme) => ({
+ card: {
+ backgroundColor: theme.colors.gray[0],
+ marginTop: theme.spacing.xs,
+ marginBottom: theme.spacing.xs,
+ "&:hover": {
+ backgroundColor: theme.colors.gray[2],
+ },
+ },
+}));
+
+const TrendingPosts = () => {
+ const {
+ data: posts,
+ isLoading,
+ isSuccess,
+ isError,
+ error,
+ } = api.useGetRecentPostsQuery("");
+
+ const theme = useMantineTheme();
+
+ const { classes } = useStyles();
+ const mediaQuery = useMediaQuery("(max-width: 1200px)");
+
+ const titleLength = mediaQuery ? 18 : 28;
+
+ return (
+
+ Trending
+
+ {isLoading ? (
+ Loading...
+ ) : (
+ posts?.content.slice(0, 5).map((post, i) => (
+
+
+
+ {post.title
+ ? post.title.slice(0, titleLength) +
+ (post.title.length > titleLength ? "..." : "")
+ : post.content.slice(0, titleLength) +
+ (post.content.length > titleLength ? "..." : "")}
+
+
+
+
+ {post.authorName}
+
+
+
+
+ {post.likes || Math.floor((10 / (i + 1)) * 10)}
+
+
+
+
+
+ ))
+ )}
+
+ );
+};
+
+export default TrendingPosts;
diff --git a/src/components/ui/AsideContent.tsx b/src/components/ui/AsideContent.tsx
index 0deeee0..846925d 100644
--- a/src/components/ui/AsideContent.tsx
+++ b/src/components/ui/AsideContent.tsx
@@ -1,5 +1,11 @@
+import TrendingPosts from "components/post/TrendingPosts";
+
function AsideContent() {
- return <>>;
+ return (
+ <>
+
+ >
+ );
}
export default AsideContent;
diff --git a/src/pages/ProjectDetail.tsx b/src/pages/ProjectDetail.tsx
index 0484729..69ec422 100644
--- a/src/pages/ProjectDetail.tsx
+++ b/src/pages/ProjectDetail.tsx
@@ -44,10 +44,10 @@ export default function ProjectDetail() {
const { data: appliedProjectIds } = api.useGetMyAppliedProjectsQuery(null);
const applyProject = api.useApplyProjectMutation()[0];
- const isApplied = appliedProjectIds?.projectIds.includes(id);
+ const isApplied = appliedProjectIds?.includes(id);
const isLeader = project?.leaderId === myId;
- const isTeamMember = project?.teamUserIds.includes(myId || "");
+ const isTeamMember = project?.teamUserIds?.includes(myId || "");
const applicantsIdsQuery = api.useGetApplicantsIdsQuery(
project?.projectId || 0
);
diff --git a/src/types/index.ts b/src/types/index.ts
index 8483e13..4dd769b 100644
--- a/src/types/index.ts
+++ b/src/types/index.ts
@@ -3,7 +3,7 @@ interface Post {
title: string;
content: string;
authorName: string;
- userId: number;
+ userId: string;
authorAvatar: string;
imagesUrl: string[];
likes: number;