Skip to content

Commit

Permalink
feat/#49/myprojects에서 작성자 이름 설정 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmj12 committed Jan 15, 2025
1 parent cd0ce6e commit de60e25
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/components/Mypage/MyProjects/MyProjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { useSearchProject } from "@/stores/searchProjectStore";
import { useQuery } from "@apollo/client";
import { useEffect, useRef, useState } from "react";
import MypageProjectCard from "@/components/ProjectCard/Mypage/MypageProjectCard";
import { useAuthStore } from "@/stores/authStore";

export default function MyProjectComponents() {
const { page, hasNext, projects, setPage, setHasNext, setProjects, reset } =
useSearchProject();
const { user } = useAuthStore();

const SIZE = 5;
const [isLoading, setIsLoading] = useState(true);
Expand All @@ -19,6 +21,7 @@ export default function MyProjectComponents() {
title: "",
stackNames: [],
categories: [],
authorName: user?.username,
},
});

Expand Down
2 changes: 1 addition & 1 deletion src/components/Project/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function ProjectLikeShare({ project }: IProjectProps) {
<button>
<FaShare style={{ width: "26px", height: "26px" }} />
</button>
{user?.data?.email === project.authorName ? (
{user?.email === project.authorName ? (
<Link style={{ width: "100%" }} href={`/project/edit/${project.id}`}>
<FaEdit style={{ width: "26px", height: "26px" }} />
</Link>
Expand Down
15 changes: 11 additions & 4 deletions src/pages/mypage/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { useAuthStore } from "@/stores/authStore";
import { useRouter } from "next/router";
import { useEffect } from "react";
import { useEffect, useRef } from "react";

export default function Mypage() {
const router = useRouter();
const { isLoggedIn } = useAuthStore();
const hasAlerted = useRef(false);

useEffect(() => {
if (isLoggedIn) {
router.replace("/mypage/myprojects");
console.log(isLoggedIn);
if (!hasAlerted.current) {
hasAlerted.current = true;

if (isLoggedIn) {
router.replace("/mypage/myprojects");
} else {
alert("로그인이 필요합니다");
router.replace("/");
}
}
}, [isLoggedIn, router]);

Expand Down
2 changes: 2 additions & 0 deletions src/services/gql/searchProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const SEARCH_PROJECT = gql`
$title: String
$stackNames: [String]
$categories: [ProjectCategory]
$authorName: String
) {
searchProject(
projectSearchRequest: {
Expand All @@ -15,6 +16,7 @@ export const SEARCH_PROJECT = gql`
title: $title
stackNames: $stackNames
categories: $categories
authorName: $authorName
}
) {
count
Expand Down

0 comments on commit de60e25

Please sign in to comment.