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

Fix: 모집글 작성, 수정하기 페이지 공통 레이아웃 라디오 버튼 수정 #318

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
6 changes: 3 additions & 3 deletions co-kkiri/src/components/commons/RadioButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import styled from "styled-components";
interface RadioButtonProps {
children?: ReactNode;
value: string;
defaultChecked?: boolean;
onClick?: () => void;
checked: boolean;
}

export default function RadioButton({ children, value, defaultChecked, onClick }: RadioButtonProps) {
export default function RadioButton({ children, value, checked, onClick }: RadioButtonProps) {
return (
<Label>
<RadioInput onClick={onClick} type="radio" name="invite" value={value} defaultChecked={defaultChecked} />
<RadioInput onClick={onClick} type="radio" name="invite" value={value} checked={checked} />
{children}
</Label>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function StudyProjectRadioButton({ selectedValue, onChange }: Stu
<Container>
<RadioButtonBox>
<RadioButton
defaultChecked={selectedValue === "STUDY" ? true : false}
checked={selectedValue === "STUDY"}
value="STUDY"
onClick={() => {
onChange("STUDY");
Expand All @@ -22,7 +22,7 @@ export default function StudyProjectRadioButton({ selectedValue, onChange }: Stu
</RadioButtonBox>
<RadioButtonBox>
<RadioButton
defaultChecked={selectedValue === "PROJECT" ? true : false}
checked={selectedValue === "PROJECT"}
value="PROJECT"
onClick={() => {
onChange("PROJECT");
Expand Down
2 changes: 1 addition & 1 deletion co-kkiri/src/lib/api/post/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PageMeta, PaginationOptions } from "../pageMetaType";

/**스터디모집하기, 수정하기 (연락 링크 추가 예정)*/
export type RecruitApiRequestDto = {
type: CategoryList;
type: CategoryList | "";
recruitEndAt: string;
progressPeriod: string;
capacity: number;
Expand Down
24 changes: 14 additions & 10 deletions co-kkiri/src/pages/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import RecruitmentRequestLayout from "@/components/commons/RecruitmentRequestLay
import * as S from "@/pages/Recruit/styled";
import { RecruitApiRequestDto } from "@/lib/api/post/type";
import { useEffect, useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { getPostDetail } from "@/lib/api/post";
import { useNavigate, useParams } from "react-router-dom";
import usePostMutation from "@/hooks/useMutation/usePostMutation";
Expand All @@ -14,7 +14,7 @@ const { serverError, unauthorized } = TOAST;

export default function Edit() {
const [selectedOptions, setSelectedOptions] = useState<RecruitApiRequestDto>({
type: "STUDY",
type: "",
recruitEndAt: "",
progressPeriod: "",
capacity: 999,
Expand All @@ -32,6 +32,7 @@ export default function Edit() {
const postId = Number(id);
const { editMutation } = usePostMutation();
const pushToast = useToast();
const queryClient = useQueryClient();

// useQuery를 통해 데이터 가져오기
const { data } = useQuery({
Expand All @@ -47,6 +48,7 @@ export default function Edit() {
onSuccess: () => {
pushToast("포스트가 성공적으로 업로드되었습니다.", "success");
navigate(`/list/${postId}`);
queryClient.invalidateQueries();
},
onError: (error) => {
pushToast(serverError.message, serverError.type);
Expand Down Expand Up @@ -80,13 +82,15 @@ export default function Edit() {
}, [data]);

return (
<S.Container>
<RecruitmentRequestLayout
isLoading={editMutation.isPending}
selectedOptions={selectedOptions}
onSubmitClick={handleSubmit}
buttonText="수정하기"
/>
</S.Container>
data && (
<S.Container>
<RecruitmentRequestLayout
isLoading={editMutation.isPending}
selectedOptions={selectedOptions}
onSubmitClick={handleSubmit}
buttonText="수정하기"
/>
</S.Container>
)
);
}
Loading