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

Refactor/#339/application submit edit #342

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5a01f76
πŸ”¨ Refactor(#338): μ‹ μ²­μ„œ 제좜 νŽ˜μ΄μ§€ λ¦¬νŒ©ν„°λ§
JIY00N2 Dec 16, 2023
0462ffc
πŸ”¨ Refactor(#339): μ‹ μ²­μ„œ μˆ˜μ •νŽ˜μ΄μ§€ λ¦¬νŒ©ν„°λ§
JIY00N2 Dec 16, 2023
5fbfb9a
πŸ”¨ Refactor(#337): 승인, 거절 μ‹ μ²­μž 관리 ν›…μœΌλ‘œ 뢄리
JIY00N2 Dec 16, 2023
a368af4
πŸ“ Chore(#337): interface μ‚­μ œ
JIY00N2 Dec 16, 2023
69314bf
πŸ”¨ Refactor(#337): μ‹ μ²­μž 승락 거절 λ²„νŠΌ μ»΄ν¬λ„ŒνŠΈν™”
JIY00N2 Dec 16, 2023
686c08b
🚨 Fix(#326): ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€ QA
JeongWuk Dec 13, 2023
ea100cc
🚨 Fix(#326): ν…œν”Œλ¦Ώ 였λ₯˜ μˆ˜μ •
JeongWuk Dec 16, 2023
ac4ea44
🚨 Fix(#333): ν¬μ§€μ…˜κ³Ό μŠ€νƒ μ΅œμ†Œ 1개 이상 ν¬ν•¨ν•˜λ„λ‘ μˆ˜μ •
sscoderati Dec 15, 2023
5c6ae41
🚨 Fix(#332): queryClient의 clear둜 μ—λŸ¬νŽ˜μ΄μ§€ reset 였λ₯˜ ν•΄κ²°
JIY00N2 Dec 16, 2023
165dd5b
πŸ“ Chore(#332): application μ»΄ν¬λ„ŒνŠΈ containersν΄λ”λ‘œ 이동
JIY00N2 Dec 16, 2023
58fdfb6
✨ Feat(#332): Title 곡톡 μ»΄ν¬λ„ŒνŠΈ
JIY00N2 Dec 16, 2023
e1f79de
πŸ“ Chore(#332): λ‚΄μŠ€ν…Œλ”” νŽ˜μ΄μ§€ ν•„ν„° μ»΄ν¬λ„ŒνŠΈν™”
JIY00N2 Dec 16, 2023
0114057
πŸ”¨ Refactor(#332): λΉˆλ©”μ‹œμ§€ utils ν•¨μˆ˜ν™”
JIY00N2 Dec 16, 2023
4dc3d49
πŸ”¨ Refactor(#332): λ‚΄μŠ€ν…Œλ”” λͺ©λ‘ μžˆλŠ” κ²½μš°μ™€ μ—†λŠ” 경우 μ»΄ν¬λ„ŒνŠΈν™”
JIY00N2 Dec 16, 2023
832d5e4
πŸ’„ Style(#332): hoverμ‹œ scale 적용
JIY00N2 Dec 16, 2023
0a537d2
🚨 Fix(#337): import 였λ₯˜ μˆ˜μ •
JIY00N2 Dec 20, 2023
d52d4ec
πŸ”¨ Refactor(#338): λ‚΄κ°€ 받은 리뷰 νŽ˜μ΄μ§€ 받은 μΉ΄λ“œ, ν•œ 쀄 평 μ»΄ν¬λ„ŒνŠΈν™”
JIY00N2 Dec 16, 2023
7e3f644
πŸ”¨ Refactor(#338): μ‹ μ²­μ„œ 제좜 νŽ˜μ΄μ§€ λ¦¬νŒ©ν„°λ§
JIY00N2 Dec 16, 2023
54482c0
πŸ“ Chore(#332): application μ»΄ν¬λ„ŒνŠΈ containersν΄λ”λ‘œ 이동
JIY00N2 Dec 16, 2023
05f78fa
πŸ”¨ Refactor(#339): μ‹ μ²­μ„œ μˆ˜μ •νŽ˜μ΄μ§€ λ¦¬νŒ©ν„°λ§
JIY00N2 Dec 16, 2023
1ec29ad
πŸ“ Chore(#332): application μ»΄ν¬λ„ŒνŠΈ containersν΄λ”λ‘œ 이동
JIY00N2 Dec 16, 2023
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
3 changes: 3 additions & 0 deletions src/app/(auth)/logout/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import { useRouter } from "next/navigation";
import useAuthStore from "@/stores/isAuth";
import useLoginStepsStore from "@/stores/loginSteps";
import { useQueryClient } from "@tanstack/react-query";
import { deleteCookie } from "cookies-next";

const Logout = () => {
const router = useRouter();
const { setIsAuth } = useAuthStore();
const { setSteps } = useLoginStepsStore();
const queryClient = useQueryClient();
// useEffect(() => {
// axios.get("https://steady-client.vercel.app/api/logout").then(() => {
// deleteCookie("access_token", {
Expand All @@ -33,6 +35,7 @@ const Logout = () => {
});
setSteps(0);
setIsAuth(false);
queryClient.clear();
router.replace("/");
return null;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";

import { usePathname, useRouter } from "next/navigation";
import { Question, Title } from "@/components/application";
import { useSuspenseQuery } from "@tanstack/react-query";
import getApplicationDetails from "@/services/application/getApplicationDetails";
import getSteadyDetails from "@/services/steady/getSteadyDetails";
import Button, { buttonSize } from "@/components/_common/Button";
import { Question, Title } from "@/components/containers/application";
import useApplicationListQuery from "@/hooks/query/useApplicationListQuery";
import {
getApplicationDetailsKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import type { ChangeEvent } from "react";
import { useState } from "react";
import { usePathname, useRouter } from "next/navigation";
import { Question, Title } from "@/components/application";
import { useToast } from "@/components/ui/use-toast";
import { usePathname } from "next/navigation";
import { TextArea } from "@radix-ui/themes";
import { useSuspenseQuery } from "@tanstack/react-query";
import editApplication from "@/services/application/editApplication";
import getApplicationDetails from "@/services/application/getApplicationDetails";
import getSteadyDetails from "@/services/steady/getSteadyDetails";
import Button, { buttonSize } from "@/components/_common/Button";
import { Question, Title } from "@/components/containers/application";
import EditButtons from "@/components/containers/applicationEdit/EditButtons";
import {
getApplicationDetailsKey,
getSteadyDetailsKey,
Expand All @@ -23,15 +21,12 @@ const ApplicationEditPage = ({
}) => {
const applicationId = params.application_id;
const steadyId = params.steady_id;
const router = useRouter();
const pathname = usePathname();
const pageType = pathname.split("/")[2];
const { toast } = useToast();
const { data: applicationData, refetch: applicationRefetch } =
useSuspenseQuery({
queryKey: getApplicationDetailsKey(applicationId),
queryFn: () => getApplicationDetails(applicationId),
});
const { data: applicationData } = useSuspenseQuery({
queryKey: getApplicationDetailsKey(applicationId),
queryFn: () => getApplicationDetails(applicationId),
});

const { data: steadyDetailsData } = useSuspenseQuery({
queryKey: getSteadyDetailsKey(steadyId),
Expand All @@ -46,33 +41,6 @@ const ApplicationEditPage = ({
})),
);

const handleClickEdit = async () => {
const checkInvalidAnswers = survey.some((item) => !item.answer.length);
if (checkInvalidAnswers) {
toast({
description: "μž…λ ₯λ˜μ§€ μ•Šμ€ ν•­λͺ©μ΄ μžˆμŠ΅λ‹ˆλ‹€.",
variant: "red",
});
} else {
try {
await editApplication(applicationId, {
answers: survey.map((item) => item.answer),
});
toast({
description: "μŠ€ν…Œλ”” μ‹ μ²­μ„œ μˆ˜μ • 성곡!",
variant: "green",
});
await applicationRefetch();
router.replace(`/steady/detail/${steadyId}`);
} catch (error) {
toast({
description: "μŠ€ν…Œλ”” μ‹ μ²­μ„œ μˆ˜μ • μ‹€νŒ¨!",
variant: "red",
});
}
}
};

const handleChangeAnswer = (
event: ChangeEvent<HTMLTextAreaElement>,
index: number,
Expand Down Expand Up @@ -113,18 +81,11 @@ const ApplicationEditPage = ({
))}
</Title>
<div className="flex items-center justify-end gap-20">
<Button
className={`${buttonSize.sm} bg-st-white`}
onClick={() => router.back()}
>
μ·¨μ†Œ
</Button>
<Button
onClick={handleClickEdit}
className={`${buttonSize.sm} bg-st-primary text-st-white`}
>
μˆ˜μ • μ™„λ£Œ
</Button>
<EditButtons
survey={survey}
applicationId={applicationId}
steadyId={steadyId}
/>
</div>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import type { ChangeEvent } from "react";
import { useEffect, useState } from "react";
import { usePathname, useRouter } from "next/navigation";
import { Question, Title } from "@/components/application";
import { useToast } from "@/components/ui/use-toast";
import { TextArea } from "@radix-ui/themes";
import { useSuspenseQuery } from "@tanstack/react-query";
import submitApplication from "@/services/application/submitApplication";
import getSteadyDetails from "@/services/steady/getSteadyDetails";
import getSteadyQuestions from "@/services/steady/getSteadyQuestions";
import Button, { buttonSize } from "@/components/_common/Button";
import { Question, Title } from "@/components/containers/application";
import {
getSteadyDetailsKey,
getSteadyQuestionsKey,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
"use client";

import { useRouter } from "next/navigation";
import { Question } from "@/components/application";
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
import changeApplicationStatus from "@/services/application/changeApplicationStatus";
import { useSuspenseQuery } from "@tanstack/react-query";
import getApplicationDetails from "@/services/application/getApplicationDetails";
import Button, { buttonSize } from "@/components/_common/Button";
import { AlertModal } from "@/components/_common/Modal";
import {
getApplicantListKey,
getApplicationDetailsKey,
} from "@/constants/queryKeys";
import ApplicantButtons from "@/components/containers/applicant/ApplicantButtons";
import { Question } from "@/components/containers/application";
import { getApplicationDetailsKey } from "@/constants/queryKeys";

const UserApplicantPage = ({
params,
Expand All @@ -19,32 +13,11 @@ const UserApplicantPage = ({
}) => {
const applicationId = params.application_id;
const steadyId = params.steady_id;
const queryClient = useQueryClient();

const { data: applicationDetailsData } = useSuspenseQuery({
queryKey: getApplicationDetailsKey(applicationId),
queryFn: () => getApplicationDetails(applicationId),
});
const router = useRouter();

const handleClickAccept = async () => {
await changeApplicationStatus(applicationId, {
status: "ACCEPTED",
});
await queryClient.invalidateQueries({
queryKey: getApplicantListKey(steadyId),
});
router.replace(`/steady/applicant/${steadyId}`);
};

const handleClickReject = async () => {
await changeApplicationStatus(applicationId, {
status: "REJECTED",
});
await queryClient.invalidateQueries({
queryKey: getApplicantListKey(steadyId),
});
router.replace(`/steady/applicant/${steadyId}`);
};

return (
<div className="flex w-full flex-col gap-10 overflow-y-scroll pr-30">
Expand All @@ -60,42 +33,13 @@ const UserApplicantPage = ({
</Question>
))}
<div className="mt-auto flex justify-end gap-20">
<AlertModal
trigger={
<Button className={`${buttonSize.sm} bg-st-red text-st-white`}>
거절
</Button>
}
actionButton={
<Button
className={`${buttonSize.sm} bg-st-red text-st-white`}
onClick={handleClickReject}
>
거절
</Button>
}
>
<div className="text-18 font-bold">거절 ν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?</div>
</AlertModal>
<AlertModal
trigger={
<Button className={`${buttonSize.sm} bg-st-green text-st-white`}>
승인
</Button>
}
actionButton={
<Button
className={`${buttonSize.sm} bg-st-green text-st-white`}
onClick={handleClickAccept}
>
승인
</Button>
}
>
<div className="text-18 font-bold">승인 ν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?</div>
</AlertModal>
<ApplicantButtons
applicationId={applicationId}
steadyId={steadyId}
/>
</div>
</div>
);
};

export default UserApplicantPage;
105 changes: 11 additions & 94 deletions src/app/(user-menu)/mypage/reviews/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
"use client";

import { useState } from "react";
import Image from "next/image";
import { cn } from "@/lib/utils";
import { Tooltip } from "@radix-ui/themes";
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
import changeReviewStatus from "@/services/review/changeReviewStatus";
import { useSuspenseQuery } from "@tanstack/react-query";
import getMyReviews from "@/services/review/getMyReviews";
import Icon from "@/components/_common/Icon";
import { SingleSelector } from "@/components/_common/Selector";
import { CardTooltip } from "@/constants/cardTooltip";
import { subBoxStyles, subMyPageTextStyles } from "@/constants/commonStyle";
import MyCardReview from "@/components/containers/myReviews/MyCardReview";
import MyCommentReview from "@/components/containers/myReviews/MyCommentReview";
import { MyReviewKey } from "@/constants/queryKeys";

const MyReviewsPage = () => {
Expand All @@ -19,96 +12,20 @@ const MyReviewsPage = () => {
queryFn: () => getMyReviews(),
staleTime: 10000,
});
const [selectedId, setSelectedId] = useState<string | null>(null);
const queryClient = useQueryClient();

const selectedReviews = myReviewData.reviews.find(
(review) => review.steadyId === Number(selectedId),
);

const handlePublicReview = async (reviewId: number) => {
await changeReviewStatus(reviewId.toString());
queryClient.invalidateQueries({ queryKey: MyReviewKey });
};

return (
<div className="flex h-full flex-col gap-50 max-sm:w-400 sm:w-500 md:w-400 lg:w-600 xl:w-750">
<div className="font-bold max-sm:text-22 sm:text-22 md:text-25 lg:text-28 xl:text-30">
λ‚΄κ°€ 받은 리뷰
</div>
<div className={cn("flex flex-col gap-30")}>
<div className={cn(subMyPageTextStyles.title)}>받은 μΉ΄λ“œ</div>
<div className={cn(subBoxStyles, "justify-evenly")}>
{myReviewData.userCards.map((card, index) => (
<div
key={card.cardId}
className={cn(
subMyPageTextStyles.content,
"flex h-full flex-col items-center justify-center gap-5",
)}
>
<Tooltip content={CardTooltip[index]}>
<Image
src={card.imageUrl}
alt="μΉ΄λ“œ 이미지"
width={40}
height={80}
/>
</Tooltip>

<div className={cn(subMyPageTextStyles.content)}>
{`( ${card.count} )`}
</div>
</div>
))}
</div>
</div>
<div className={cn("flex w-full flex-col gap-30")}>
<div className={cn(subMyPageTextStyles.title)}>ν•œ 쀄 평</div>
<SingleSelector
items={myReviewData.reviews.map((review) => ({
value: review.steadyId.toString(),
label: review.steadyName,
}))}
initialLabel="전체"
onSelectedChange={(value) => setSelectedId(value)}
className="h-60"
/>
<div
className={`${
selectedReviews
? "border-2 border-st-gray-100"
: "items-center justify-center"
} flex h-230 flex-col gap-20 overflow-auto px-10 py-5`}
>
{selectedReviews &&
selectedReviews.reviews.map((review) => (
<div
key={review.reviewId}
className="flex items-center justify-between"
>
<div className="text-ellipsis text-15 font-bold">
{review.comment}
</div>
<button onClick={() => handlePublicReview(review.reviewId)}>
{review.isPublic ? (
<Icon
name="eye"
size={25}
color="text-black"
/>
) : (
<Icon
name="eye-none"
size={25}
color="text-black"
/>
)}
</button>
</div>
))}
</div>
</div>
<MyCardReview
title={"받은 μΉ΄λ“œ"}
myReviewData={myReviewData}
/>
<MyCommentReview
title={"ν•œ 쀄 평"}
myReviewData={myReviewData}
/>
</div>
);
};
Expand Down
Loading