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: mutate 함수 alias 변수명 통일 #267

Merged
merged 4 commits into from
Jan 11, 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
8 changes: 4 additions & 4 deletions src/components/molecules/FeedbackView/FeedbackView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const FeedbackView = ({
const [isEdit, setIsEdit] = useState<boolean>(false);
const [value, setValue] = useState<string | undefined>(content);
const { resumeId = '', eventId = '' } = useParams();
const { mutate: patchCommentMutate } = usePatchFeedbackComment(resumeId, eventId);
const { mutate: deleteCommentMutate } = useDeleteFeedbackComment(resumeId, eventId);
const { mutate: patchComment } = usePatchFeedbackComment(resumeId, eventId);
const { mutate: deleteComment } = useDeleteFeedbackComment(resumeId, eventId);

Comment on lines -41 to 43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오오 좋네요!

const { isOpen, onOpen, onClose } = useDisclosure();

Expand All @@ -62,7 +62,7 @@ const FeedbackView = ({
const body = {
content: value,
};
patchCommentMutate(
patchComment(
{ resumeId, eventId, commentId, body },
{
onSuccess: () => {
Expand All @@ -76,7 +76,7 @@ const FeedbackView = ({

const handleRemove = () => {
if (resumeId && eventId && commentId) {
deleteCommentMutate({ resumeId, eventId, commentId });
deleteComment({ resumeId, eventId, commentId });
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/molecules/MentorProfile/MentorProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const MentorProfile = ({
};
const { data: followData } = useGetMentorFollow({ mentorId, role: user?.role });
const { mutate: deleteMentorFollow } = useDeleteMentorFollow();
const { mutate: mentorFollow } = usePostMentorFollow();
const { mutate: postMentorFollow } = usePostMentorFollow();

return (
<>
Expand Down Expand Up @@ -159,7 +159,7 @@ const MentorProfile = ({
onClick={
followData?.id
? () => deleteMentorFollow({ followId: Number(followData?.id) })
: () => mentorFollow({ mentorId })
: () => postMentorFollow({ mentorId })
}
_hover={{
bg: 'gray.300',
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const Navigation = ({ user }: { user: User | null }) => {

const Header = () => {
const { user } = useUser();
const { mutate: signOut } = usePostSignOut();
const { mutate: postSignOut } = usePostSignOut();

const navigate = useNavigate();

Expand All @@ -111,14 +111,14 @@ const Header = () => {
onClick: () => navigate(appPaths.eventCreate()),
},
{ text: TEXT_CONTENTS.EDIT_PROFILE, onClick: () => navigate(appPaths.userEditInfo()) },
{ text: TEXT_CONTENTS.SIGN_OUT, onClick: signOut },
{ text: TEXT_CONTENTS.SIGN_OUT, onClick: postSignOut },
];

const menteeOptions: Option[] = [
{ text: TEXT_CONTENTS.MY_PAGE, onClick: () => navigate(appPaths.myPage()) },
{ text: TEXT_CONTENTS.RESUME, onClick: () => navigate(appPaths.managementResume()) },
{ text: TEXT_CONTENTS.EDIT_PROFILE, onClick: () => navigate(appPaths.userEditInfo()) },
{ text: TEXT_CONTENTS.SIGN_OUT, onClick: signOut },
{ text: TEXT_CONTENTS.SIGN_OUT, onClick: postSignOut },
];

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type RejectionModalContentProps = {
};

const RejectionModalContent = ({ onClose, eventId, menteeId }: RejectionModalContentProps) => {
const { mutate } = usePatchFeedbackReject();
const { mutate: patchFeedbackReject } = usePatchFeedbackReject();

const {
register,
Expand All @@ -23,7 +23,7 @@ const RejectionModalContent = ({ onClose, eventId, menteeId }: RejectionModalCon
const onSubmit = (value: EventReject) => {
value.menteeId = menteeId;

mutate({ eventId, body: value });
patchFeedbackReject({ eventId, body: value });

if (onClose) {
onClose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const RemoteControlPannel = () => {
const { eventId = '', resumeId = '' } = useParams();
const { data } = useGetResumeBasic({ resumeId });
const menteeId = data?.ownerInfo?.id as number;
const { mutate } = usePatchFeedbackComplete();
const { mutate: patchFeedbackComplete } = usePatchFeedbackComplete();
const navigate = useNavigate();

const {
Expand All @@ -28,7 +28,7 @@ const RemoteControlPannel = () => {
if (eventId !== '' && resumeId !== '') {
value.resumeId = Number(resumeId);

mutate(
patchFeedbackComplete(
{ eventId, body: value },
{
onSuccess: () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ type ReferenceLinkFormProps = {
};

const ReferenceLinkForm = ({ defaultValue, resumeId }: ReferenceLinkFormProps) => {
const { mutate: postReferenceLinkMutate } = usePostResumeLink(resumeId);
const { mutate: deleteReferenceLinkMutate } = useDeleteReferenceLink(resumeId);
const { mutate: postReferenceLink } = usePostResumeLink(resumeId);
const { mutate: deleteReferenceLink } = useDeleteReferenceLink(resumeId);
const {
register,
handleSubmit,
Expand All @@ -33,12 +33,12 @@ const ReferenceLinkForm = ({ defaultValue, resumeId }: ReferenceLinkFormProps) =
return;
}

postReferenceLinkMutate({ resumeId, body });
postReferenceLink({ resumeId, body });
reset();
});

const handleRemoveLink = (componentId: number) => {
deleteReferenceLinkMutate({ resumeId, linkId: componentId });
deleteReferenceLink({ resumeId, linkId: componentId });
};
return (
<>
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/ResumeBasicInput/TitleInputForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type TitleInputFormProps = {

const TitleInputForm = ({ defaultValue }: TitleInputFormProps) => {
const { resumeId } = useParams();
const { mutate, isPending, isSuccess, isError } = usePatchResumeTitle();
const { mutate: patchResumeTitle, isPending, isSuccess, isError } = usePatchResumeTitle();
const navigate = useNavigate();
const [empty, setEmpty] = useState(false);

Expand Down Expand Up @@ -87,7 +87,7 @@ const TitleInputForm = ({ defaultValue }: TitleInputFormProps) => {
} else {
setEmpty(false);
}
mutate({ resumeId, resumeTitle });
patchResumeTitle({ resumeId, resumeTitle });
}, 1000);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ const ActivityForm = ({
const { isOpen, onClose, showForm, setShowForm, handleCancel, handleDeleteForm } =
useHandleFormState(isDirty, reset);

const { mutate: postActivityMutate } = useOptimisticPostCategory({
const { mutate: postActivity } = useOptimisticPostCategory({
mutationFn: postResumeActivity,
TARGET_QUERY_KEY: categoryKeys.activity(resumeId),
onMutateSuccess: handleDeleteForm,
});
const { mutate: patchResumeActivityMutate } = useOptimisticPatchCategory({
const { mutate: patchActivity } = useOptimisticPatchCategory({
mutationFn: patchResumeActivity,
TARGET_QUERY_KEY: categoryKeys.activity(resumeId),
onMutateSuccess: quitEdit,
Expand All @@ -58,9 +58,9 @@ const ActivityForm = ({
return;
}
if (!isEdit) {
postActivityMutate({ resumeId, body });
postActivity({ resumeId, body });
} else if (isEdit && blockId) {
patchResumeActivityMutate({ resumeId, blockId, body });
patchActivity({ resumeId, blockId, body });
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/components/organisms/ResumeCategoryAwards/AwardForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ const AwardForm = ({
const { isOpen, onClose, showForm, setShowForm, handleCancel, handleDeleteForm } =
useHandleFormState(isDirty, reset);

const { mutate: postAwardMutate } = useOptimisticPostCategory({
const { mutate: postAward } = useOptimisticPostCategory({
mutationFn: postResumeAward,
TARGET_QUERY_KEY: categoryKeys.award(resumeId),
onMutateSuccess: handleDeleteForm,
});
const { mutate: patchResumeAwardMutate } = useOptimisticPatchCategory({
const { mutate: patchAward } = useOptimisticPatchCategory({
mutationFn: patchResumeAward,
TARGET_QUERY_KEY: categoryKeys.award(resumeId),
onMutateSuccess: quitEdit,
Expand All @@ -55,9 +55,9 @@ const AwardForm = ({
return;
}
if (!isEdit) {
postAwardMutate({ resumeId, body });
postAward({ resumeId, body });
} else if (isEdit && blockId) {
patchResumeAwardMutate({ resumeId, blockId, body });
patchAward({ resumeId, blockId, body });
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/components/organisms/ResumeCategoryCareer/CareerForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ const CareerForm = ({
const { isOpen, onClose, showForm, setShowForm, handleCancel, handleDeleteForm } =
useHandleFormState(isDirty, reset);

const { mutate: postCareerMutate } = useOptimisticPostCategory({
const { mutate: postCareer } = useOptimisticPostCategory({
mutationFn: postResumeCareer,
TARGET_QUERY_KEY: categoryKeys.career(resumeId),
onMutateSuccess: handleDeleteForm,
});
const { mutate: patchCareerMutate } = useOptimisticPatchCategory({
const { mutate: patchCareer } = useOptimisticPatchCategory({
mutationFn: patchResumeCareer,
TARGET_QUERY_KEY: categoryKeys.career(resumeId),
onMutateSuccess: quitEdit,
Expand Down Expand Up @@ -102,14 +102,14 @@ const CareerForm = ({
removeDuties();
};
if (!isEdit) {
postCareerMutate(
postCareer(
{ resumeId, body },
{
onSuccess: initializeForm,
},
);
} else if (isEdit && blockId) {
patchCareerMutate(
patchCareer(
{ resumeId, blockId, body },
{
onSuccess: initializeForm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ const LanguageForm = ({
const { isOpen, onClose, showForm, setShowForm, handleCancel, handleDeleteForm } =
useHandleFormState(isDirty, reset);

const { mutate: postLanguageMutate } = useOptimisticPostCategory({
const { mutate: postLanguage } = useOptimisticPostCategory({
mutationFn: postResumeLanguage,
TARGET_QUERY_KEY: categoryKeys.language(resumeId),
onMutateSuccess: handleDeleteForm,
});
const { mutate: patchResumeLanguageMutate } = useOptimisticPatchCategory({
const { mutate: patchLanguage } = useOptimisticPatchCategory({
mutationFn: patchResumeLanguage,
TARGET_QUERY_KEY: categoryKeys.language(resumeId),
onMutateSuccess: quitEdit,
Expand All @@ -52,9 +52,9 @@ const LanguageForm = ({
return;
}
if (!isEdit) {
postLanguageMutate({ resumeId, body });
postLanguage({ resumeId, body });
} else if (isEdit && blockId) {
patchResumeLanguageMutate({ resumeId, blockId, body });
patchLanguage({ resumeId, blockId, body });
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ const ProjectForm = ({
const { isOpen, onClose, showForm, setShowForm, handleCancel, handleDeleteForm } =
useHandleFormState(isDirty, reset);

const { mutate: postProjectMutate } = useOptimisticPostCategory({
const { mutate: postProject } = useOptimisticPostCategory({
mutationFn: postResumeProject,
TARGET_QUERY_KEY: categoryKeys.project(resumeId),
onMutateSuccess: handleDeleteForm,
});
const { mutate: patchResumeProjectMutate } = useOptimisticPatchCategory({
const { mutate: patchProject } = useOptimisticPatchCategory({
mutationFn: patchResumeProject,
TARGET_QUERY_KEY: categoryKeys.project(resumeId),
onMutateSuccess: quitEdit,
Expand All @@ -65,14 +65,14 @@ const ProjectForm = ({
body.skills = skills;
body.team = Boolean(body.team);
if (!isEdit) {
postProjectMutate(
postProject(
{ resumeId, body },
{
onSuccess: initializeSkills,
},
);
} else if (isEdit && blockId) {
patchResumeProjectMutate(
patchProject(
{ resumeId, blockId, body },
{
onSuccess: initializeSkills,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ const TrainingForm = ({
const { isOpen, onClose, showForm, setShowForm, handleCancel, handleDeleteForm } =
useHandleFormState(isDirty, reset);

const { mutate: postTrainingMutate } = useOptimisticPostCategory({
const { mutate: postTraining } = useOptimisticPostCategory({
mutationFn: postResumeTraining,
TARGET_QUERY_KEY: categoryKeys.training(resumeId),
onMutateSuccess: handleDeleteForm,
});
const { mutate: patchResumeTrainingMutate } = useOptimisticPatchCategory({
const { mutate: patchTraining } = useOptimisticPatchCategory({
mutationFn: patchResumeTraining,
TARGET_QUERY_KEY: categoryKeys.training(resumeId),
onMutateSuccess: quitEdit,
Expand All @@ -55,9 +55,9 @@ const TrainingForm = ({
return;
}
if (!isEdit) {
postTrainingMutate({ resumeId, body });
postTraining({ resumeId, body });
} else if (isEdit && blockId) {
patchResumeTrainingMutate({ resumeId, blockId, body });
patchTraining({ resumeId, blockId, body });
}
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/ResumeDetails/ActivityDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ActivityDetails = ({
}: DetailsComponentProps<ReadActivity>) => {
const { resumeId = '' } = useParams();
const blockId = componentId;
const { mutate: deleteMutate } = useOptimisticDeleteCategory<Activity, ReadActivity>({
const { mutate: deleteCategory } = useOptimisticDeleteCategory<Activity, ReadActivity>({
mutationFn: deleteResumeCategoryBlock,
TARGET_QUERY_KEY: categoryKeys.activity(resumeId),
});
Expand Down Expand Up @@ -95,7 +95,7 @@ const ActivityDetails = ({
{isCurrentUser && (
<EditDeleteOptionsButton
onEdit={onEdit}
onDelete={() => deleteMutate({ resumeId, blockId })}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오호 이렇게 적힌게 있었군요

onDelete={() => deleteCategory({ resumeId, blockId })}
/>
)}
</Flex>
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/ResumeDetails/CareerDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const CareerDetails = ({
}: DetailsComponentProps<ReadCareer>) => {
const { resumeId = '' } = useParams();
const blockId = componentId;
const { mutate: deleteMutate } = useOptimisticDeleteCategory<Career, ReadCareer>({
const { mutate: deleteCategory } = useOptimisticDeleteCategory<Career, ReadCareer>({
mutationFn: deleteResumeCategoryBlock,
TARGET_QUERY_KEY: categoryKeys.career(resumeId),
});
Expand Down Expand Up @@ -149,7 +149,7 @@ const CareerDetails = ({
{isCurrentUser && (
<EditDeleteOptionsButton
onEdit={onEdit}
onDelete={() => deleteMutate({ resumeId, blockId })}
onDelete={() => deleteCategory({ resumeId, blockId })}
/>
)}
</Flex>
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/ResumeDetails/LanguageDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const LanguageDetails = ({
}: DetailsComponentProps<ReadLanguage>) => {
const { resumeId = '' } = useParams();
const blockId = componentId;
const { mutate: deleteMutate } = useOptimisticDeleteCategory<Language, ReadLanguage>({
const { mutate: deleteCategory } = useOptimisticDeleteCategory<Language, ReadLanguage>({
mutationFn: deleteResumeCategoryBlock,
TARGET_QUERY_KEY: categoryKeys.language(resumeId),
});
Expand Down Expand Up @@ -62,7 +62,7 @@ const LanguageDetails = ({
{isCurrentUser && (
<EditDeleteOptionsButton
onEdit={onEdit}
onDelete={() => deleteMutate({ resumeId, blockId })}
onDelete={() => deleteCategory({ resumeId, blockId })}
/>
)}
</Flex>
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/ResumeDetails/ProjectDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ProjectDetails = ({
}: DetailsComponentProps<ReadProject>) => {
const { resumeId = '' } = useParams();
const blockId = componentId;
const { mutate: deleteMutate } = useOptimisticDeleteCategory<Project, ReadProject>({
const { mutate: deleteCategory } = useOptimisticDeleteCategory<Project, ReadProject>({
mutationFn: deleteResumeCategoryBlock,
TARGET_QUERY_KEY: categoryKeys.project(resumeId),
});
Expand Down Expand Up @@ -133,7 +133,7 @@ const ProjectDetails = ({
{isCurrentUser && (
<EditDeleteOptionsButton
onEdit={onEdit}
onDelete={() => deleteMutate({ resumeId, blockId })}
onDelete={() => deleteCategory({ resumeId, blockId })}
/>
)}
</Flex>
Expand Down
Loading