Skip to content

Commit

Permalink
feat: 공고상세 편집완료 시 모달, 새로고침,
Browse files Browse the repository at this point in the history
  • Loading branch information
Woojiseok committed Jun 16, 2024
1 parent b2ff793 commit 7488921
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion api/notice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BASE_URL } from "@/constants/constants";
import { instance } from "@/utils/instance";
import axios from "axios";

export const getNoticeDetailedData = async (
Expand All @@ -19,7 +20,7 @@ export const getNoticeDetailedData = async (

export const getApplicantList = async (shopId: string, noticeId: string) => {
try {
const res = await axios.get(
const res = await instance.get(
`${BASE_URL}/shops/${shopId}/notices/${noticeId}/applications?limit=100`
);
return res;
Expand Down
12 changes: 9 additions & 3 deletions components/Shop/ShopView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const ShopView: React.FC<ShopViewProps> = ({ onEdit }) => {
const [showNoticeForm, setShowNoticeForm] = useState(false);

const shopValue = useRecoilValue(employerAtom);

useEffect(() => {
const fetchAndSetShopData = async () => {
if (shopValue) {
Expand Down Expand Up @@ -52,7 +51,10 @@ const ShopView: React.FC<ShopViewProps> = ({ onEdit }) => {
return (
<div className={cx("profile")}>
{showNoticeForm ? (
<ShopNoticeForm onClose={handleCloseNoticeForm} onSubmit={handleCloseNoticeForm} />
<ShopNoticeForm
onClose={handleCloseNoticeForm}
onSubmit={handleCloseNoticeForm}
/>
) : (
<>
<div className={cx("container")}>
Expand Down Expand Up @@ -88,7 +90,11 @@ const ShopView: React.FC<ShopViewProps> = ({ onEdit }) => {
<p className={cx("bio")}>{shopData.description}</p>
</div>
<div className={cx("button-wrapper")}>
<Button btnColorType="white" btnCustom="userNoticeDetailed" onClick={onEdit}>
<Button
btnColorType="white"
btnCustom="userNoticeDetailed"
onClick={onEdit}
>
편집하기
</Button>
<Button
Expand Down
6 changes: 2 additions & 4 deletions components/notice/NoticeDetailed/NoticeDetailedEdit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Input from "@/components/Input";
import styles from "@/components/Shop/ShopNotice/ShopNoticeForm/ShopNoticeForm.module.scss";
import { IModalProps } from "@/components/Modal/Modal.types";
import { instance } from "@/utils/instance";
import { useRecoilState, useRecoilValue } from "recoil";
import {
NoticeData,
NoticeFormData,
Expand All @@ -27,7 +26,6 @@ function NoticeDetailedEdit({
shopId,
}: NoticeFormProps & { noticeId: string; shopId: string }) {
const router = useRouter();
const shopValue = useRecoilValue(employerAtom);
const { register, handleSubmit, setValue } = useForm<NoticeFormData>();

const [showAlert, setShowAlert] = useState(false);
Expand Down Expand Up @@ -58,6 +56,7 @@ function NoticeDetailedEdit({
setShowAlert(false);
if (modalType === "confirm") {
onClose();
location.reload();
}
};

Expand All @@ -84,8 +83,7 @@ function NoticeDetailedEdit({
btnName: ["확인"],
});
setShowAlert(true);
onSubmit();
setModalType("alert");
setModalType("confirm");
} else {
setModalData({
modalType: "alert",
Expand Down
4 changes: 1 addition & 3 deletions components/notice/NoticeDetailed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ const NoticeDetailed = ({ shopData, onEditClick }: NoticeDetailedProps) => {

const router = useRouter();
const { noticeId, shopId } = router.query;
const shopIdString = Array.isArray(shopId) ? shopId[0] : shopId;
const noticeIdString = Array.isArray(shopId) ? shopId[0] : shopId;

const isClosed = shopData.closed;

const startTimeFormatted = startTime.format("YYYY-MM-DD HH:mm");
Expand All @@ -53,6 +50,7 @@ const NoticeDetailed = ({ shopData, onEditClick }: NoticeDetailedProps) => {
shopData.shop.originalHourlyPay,
shopData.hourlyPay
);
console.log("NoticeDetailed ShopId : ", shopId);

const handleApplyClick = async () => {
if (!applyValidation()) return;
Expand Down

0 comments on commit 7488921

Please sign in to comment.