From 112a874ea47f82a752ebb88cc5da4d11bc5dfd33 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:05:04 +0900 Subject: [PATCH 01/16] =?UTF-8?q?=E2=9C=A8=20feat:=20Table=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=EC=97=90=20modal=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8/state=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/Table.tsx | 137 ++++++++++++++------------ 1 file changed, 76 insertions(+), 61 deletions(-) diff --git a/src/components/common/table/Table.tsx b/src/components/common/table/Table.tsx index d6537526..e673dec0 100644 --- a/src/components/common/table/Table.tsx +++ b/src/components/common/table/Table.tsx @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'; import TableStatus from './TableStatus'; import TableButtons from './TableButtons'; import Pagination from '../Pagination'; +import Modal from '../Modal'; import formatWorkTime from '@/utils/formatWorkTime'; import { getNoticeApplications, @@ -32,6 +33,13 @@ export default function Table(props: UserProps | NoticeProps) { ); const [page, setPage] = useState(1); const [totalPage, setTotalPage] = useState(1); + const [modal, setModal] = useState<{ + isOpen: boolean; + status: 'accepted' | 'rejected'; + }>({ + isOpen: false, + status: 'accepted', + }); useEffect(() => { (async () => { @@ -97,68 +105,75 @@ export default function Table(props: UserProps | NoticeProps) { }, [mode, page]); return ( -
- - - - - - - - - - - {datas.map((data, index) => ( - - - - - + <> +
+
- {headers[0]} - - {headers[1]} - - {headers[2]} - - {headers[3]} -
-
- {data[0]} -
-
-
- {data[1]} -
-
-
- {data[2]} -
-
-
- {mode === 'notice' && data[3] === 'pending' ? ( - - ) : ( - - )} -
-
+ + + + + + - ))} - -
+ {headers[0]} + + {headers[1]} + + {headers[2]} + + {headers[3]} +
-
- + + + {datas.map((data, index) => ( + + +
+ {data[0]} +
+ + +
+ {data[1]} +
+ + +
+ {data[2]} +
+ + +
+ {mode === 'notice' && data[3] === 'pending' ? ( + + ) : ( + + )} +
+ + + ))} + + +
+ +
-
+ {modal.isOpen && ( + + 신청을 {modal.status === 'accepted' ? '승인' : '거절'}하시겠어요? + + )} + ); } From 47f549146ee787ff2759c19aea2f1918d4d7e8a1 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:07:05 +0900 Subject: [PATCH 02/16] =?UTF-8?q?=E2=9C=A8=20feat:=20Table=20=EC=BB=B4?= =?UTF-8?q?=ED=8F=AC=EB=84=8C=ED=8A=B8=EC=97=90=20closeModal=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/Table.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/common/table/Table.tsx b/src/components/common/table/Table.tsx index e673dec0..1660eff3 100644 --- a/src/components/common/table/Table.tsx +++ b/src/components/common/table/Table.tsx @@ -41,6 +41,11 @@ export default function Table(props: UserProps | NoticeProps) { status: 'accepted', }); + const closeModal = () => + setModal((prev) => { + return { ...prev, isOpen: false }; + }); + useEffect(() => { (async () => { try { @@ -170,7 +175,12 @@ export default function Table(props: UserProps | NoticeProps) { {modal.isOpen && ( - + 신청을 {modal.status === 'accepted' ? '승인' : '거절'}하시겠어요? )} From 78d91406032af1606dd1ab04de2c037c09119f2e Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:22:02 +0900 Subject: [PATCH 03/16] =?UTF-8?q?=E2=9C=A8=20feat:=20modal.dataIndex=20sta?= =?UTF-8?q?te=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/Table.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/common/table/Table.tsx b/src/components/common/table/Table.tsx index 1660eff3..36edb8be 100644 --- a/src/components/common/table/Table.tsx +++ b/src/components/common/table/Table.tsx @@ -36,9 +36,11 @@ export default function Table(props: UserProps | NoticeProps) { const [modal, setModal] = useState<{ isOpen: boolean; status: 'accepted' | 'rejected'; + dataIndex: number; }>({ isOpen: false, status: 'accepted', + dataIndex: 0, }); const closeModal = () => From 945dfb2e9eea3bcb544082a0c9e2db2bde47a802 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:27:14 +0900 Subject: [PATCH 04/16] =?UTF-8?q?=E2=9C=A8=20feat:=20clickButton=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/Table.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/common/table/Table.tsx b/src/components/common/table/Table.tsx index 36edb8be..67c87e41 100644 --- a/src/components/common/table/Table.tsx +++ b/src/components/common/table/Table.tsx @@ -48,6 +48,14 @@ export default function Table(props: UserProps | NoticeProps) { return { ...prev, isOpen: false }; }); + const clickButton = (dataIndex: number, status: 'accepted' | 'rejected') => { + setModal({ + isOpen: true, + status, + dataIndex, + }); + }; + useEffect(() => { (async () => { try { From 2e50b7670678a4bd9a0ea23d122fcfb6d4d306e1 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:29:38 +0900 Subject: [PATCH 05/16] =?UTF-8?q?=F0=9F=94=A5=20remove:=20TableButtons?= =?UTF-8?q?=EC=97=90=EC=84=9C=20modal=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/TableButtons.tsx | 61 ++++++++------------ 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/src/components/common/table/TableButtons.tsx b/src/components/common/table/TableButtons.tsx index 8a6f241c..240bd4ce 100644 --- a/src/components/common/table/TableButtons.tsx +++ b/src/components/common/table/TableButtons.tsx @@ -60,43 +60,30 @@ export default function TableButtons({ }, []); return status === 'pending' ? ( - <> -
- - -
- {modal.isOpen && ( - - 신청을 {modal.status === 'accepted' ? '승인' : '거절'}하시겠어요? - - )} - +
+ + +
) : ( ); From 72014beab8be4a7af61c442f5c8a6019294691a8 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:30:59 +0900 Subject: [PATCH 06/16] =?UTF-8?q?=F0=9F=94=A5=20remove:=20TableButtons?= =?UTF-8?q?=EC=97=90=EC=84=9C=20modal=20import=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/TableButtons.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/common/table/TableButtons.tsx b/src/components/common/table/TableButtons.tsx index 240bd4ce..268ab72f 100644 --- a/src/components/common/table/TableButtons.tsx +++ b/src/components/common/table/TableButtons.tsx @@ -2,7 +2,6 @@ import { useEffect, useState, type MouseEvent } from 'react'; import Button from '../Button'; import TableStatus from './TableStatus'; import { putNoticeApplications } from '@/api/applicationApi'; -import Modal from '../Modal'; interface Props { shopId: string; From dd4e25faa2069fd357fc4fc9b060de3a751cc2fe Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:37:37 +0900 Subject: [PATCH 07/16] =?UTF-8?q?=F0=9F=90=9B=20fix:=20TableButtons=20prop?= =?UTF-8?q?s=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/TableButtons.tsx | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/common/table/TableButtons.tsx b/src/components/common/table/TableButtons.tsx index 268ab72f..8824d4e1 100644 --- a/src/components/common/table/TableButtons.tsx +++ b/src/components/common/table/TableButtons.tsx @@ -4,16 +4,10 @@ import TableStatus from './TableStatus'; import { putNoticeApplications } from '@/api/applicationApi'; interface Props { - shopId: string; - noticeId: string; - applicaitonId: string; + click: (dataIndex: number, status: 'accepted' | 'rejected') => void; } -export default function TableButtons({ - shopId, - noticeId, - applicaitonId, -}: Props) { +export default function TableButtons({ click }: Props) { const [status, setStatus] = useState<'pending' | 'accepted' | 'rejected'>( 'pending', ); From 72d9ddd65dfbd7e12a1ecdd155c8afc2c554da61 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:38:46 +0900 Subject: [PATCH 08/16] =?UTF-8?q?=E2=9C=A8=20feat:=20Table=20Buttons=20ind?= =?UTF-8?q?ex=20prop=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/TableButtons.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/common/table/TableButtons.tsx b/src/components/common/table/TableButtons.tsx index 8824d4e1..b61f929c 100644 --- a/src/components/common/table/TableButtons.tsx +++ b/src/components/common/table/TableButtons.tsx @@ -4,10 +4,11 @@ import TableStatus from './TableStatus'; import { putNoticeApplications } from '@/api/applicationApi'; interface Props { + index: number; click: (dataIndex: number, status: 'accepted' | 'rejected') => void; } -export default function TableButtons({ click }: Props) { +export default function TableButtons({ index, click }: Props) { const [status, setStatus] = useState<'pending' | 'accepted' | 'rejected'>( 'pending', ); From 526769150acaa0332c07cbcd70ca2cb498fd8869 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:39:42 +0900 Subject: [PATCH 09/16] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Table=20=EB=82=B4?= =?UTF-8?q?=EB=B6=80=20TableButtons=20props=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/Table.tsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/components/common/table/Table.tsx b/src/components/common/table/Table.tsx index 67c87e41..cb4036c0 100644 --- a/src/components/common/table/Table.tsx +++ b/src/components/common/table/Table.tsx @@ -162,11 +162,7 @@ export default function Table(props: UserProps | NoticeProps) {
{mode === 'notice' && data[3] === 'pending' ? ( - + ) : ( )} From 4986fe5bdb06669571b184f2119ed46b3c91c947 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:43:15 +0900 Subject: [PATCH 10/16] =?UTF-8?q?=F0=9F=94=A5=20remove:=20TableButtons=20m?= =?UTF-8?q?odal=20state=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/TableButtons.tsx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/components/common/table/TableButtons.tsx b/src/components/common/table/TableButtons.tsx index b61f929c..01d9bb00 100644 --- a/src/components/common/table/TableButtons.tsx +++ b/src/components/common/table/TableButtons.tsx @@ -12,13 +12,6 @@ export default function TableButtons({ index, click }: Props) { const [status, setStatus] = useState<'pending' | 'accepted' | 'rejected'>( 'pending', ); - const [modal, setModal] = useState<{ - isOpen: boolean; - status: 'accepted' | 'rejected'; - }>({ - isOpen: false, - status: 'accepted', - }); const [isMobile, setIsMobile] = useState(window.innerWidth < 768); const closeModal = () => From ed3210f4b310050ef40e915078841b188fdb4352 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:44:09 +0900 Subject: [PATCH 11/16] =?UTF-8?q?=F0=9F=94=A5=20remove:=20TableButtons=20c?= =?UTF-8?q?loseModal=20=ED=95=A8=EC=88=98=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/TableButtons.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/components/common/table/TableButtons.tsx b/src/components/common/table/TableButtons.tsx index 01d9bb00..9acc1df8 100644 --- a/src/components/common/table/TableButtons.tsx +++ b/src/components/common/table/TableButtons.tsx @@ -14,11 +14,6 @@ export default function TableButtons({ index, click }: Props) { ); const [isMobile, setIsMobile] = useState(window.innerWidth < 768); - const closeModal = () => - setModal((prev) => { - return { ...prev, isOpen: false }; - }); - const handleModalClick = async () => { closeModal(); setStatus(modal.status); From ea7b48e4b3e449b0f61d5a04c305d875e4f74868 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:45:01 +0900 Subject: [PATCH 12/16] =?UTF-8?q?=F0=9F=94=A5=20remove:=20TableButtons=20h?= =?UTF-8?q?andleClick=20=ED=95=A8=EC=88=98=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/TableButtons.tsx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/components/common/table/TableButtons.tsx b/src/components/common/table/TableButtons.tsx index 9acc1df8..bfcb6284 100644 --- a/src/components/common/table/TableButtons.tsx +++ b/src/components/common/table/TableButtons.tsx @@ -26,13 +26,6 @@ export default function TableButtons({ index, click }: Props) { } }; - const handleClick = (e: MouseEvent) => { - setModal({ - isOpen: true, - status: e.currentTarget.value as 'accepted' | 'rejected', - }); - }; - useEffect(() => { const handleResize = () => { setIsMobile(window.innerWidth < 768); From 93d1edabb12321fcd6d2e308c3c1d9c1186b2961 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:46:57 +0900 Subject: [PATCH 13/16] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20TableBut?= =?UTF-8?q?tons=20=EB=82=B4=EB=B6=80=20Button=20onClick=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/TableButtons.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/common/table/TableButtons.tsx b/src/components/common/table/TableButtons.tsx index bfcb6284..d9427e0b 100644 --- a/src/components/common/table/TableButtons.tsx +++ b/src/components/common/table/TableButtons.tsx @@ -41,7 +41,7 @@ export default function TableButtons({ index, click }: Props) { size={isMobile ? 'small' : 'medium'} className="w-69 md:w-92" value="rejected" - onClick={handleClick} + onClick={() => click(index, 'rejected')} > 거절하기 @@ -54,7 +54,7 @@ export default function TableButtons({ index, click }: Props) { borderColor: 'var(--color-blue-20)', }} value="accepted" - onClick={handleClick} + onClick={() => click(index, 'accepted')} > 승인하기 From 43d32b5e04ba965d96aa329a184107e6f3dceb07 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:55:41 +0900 Subject: [PATCH 14/16] =?UTF-8?q?=E2=9C=A8=20feat:=20Table=20handleModalCl?= =?UTF-8?q?ick=20=ED=95=A8=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/Table.tsx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/components/common/table/Table.tsx b/src/components/common/table/Table.tsx index cb4036c0..a41c8df7 100644 --- a/src/components/common/table/Table.tsx +++ b/src/components/common/table/Table.tsx @@ -7,6 +7,7 @@ import formatWorkTime from '@/utils/formatWorkTime'; import { getNoticeApplications, getUserApplications, + putNoticeApplications, } from '@/api/applicationApi'; interface UserProps { @@ -56,6 +57,31 @@ export default function Table(props: UserProps | NoticeProps) { }); }; + const handleModalClick = async () => { + closeModal(); + if (mode === 'user') return; + + setDatas((prev) => { + prev[modal.dataIndex][3] = modal.status; + return prev; + }); + try { + await putNoticeApplications( + props.shopId, + props.noticeId, + datas[modal.dataIndex][4] ?? '', + { + status: modal.status, + }, + ); + } catch { + setDatas((prev) => { + prev[modal.dataIndex][3] = 'pending'; + return prev; + }); + } + }; + useEffect(() => { (async () => { try { From f78ffc669fdb72b0140fc03113146c2ed6ead9b0 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 21:56:30 +0900 Subject: [PATCH 15/16] =?UTF-8?q?=E2=9C=A8=20feat:=20Table=20Modal?= =?UTF-8?q?=EC=97=90=20handleModalClick=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/Table.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/common/table/Table.tsx b/src/components/common/table/Table.tsx index a41c8df7..5f53ceba 100644 --- a/src/components/common/table/Table.tsx +++ b/src/components/common/table/Table.tsx @@ -210,6 +210,7 @@ export default function Table(props: UserProps | NoticeProps) { From cd288634bf0d4df4ce28e200879ce5b4f2180a61 Mon Sep 17 00:00:00 2001 From: Moon-ju-young Date: Sun, 22 Jun 2025 22:00:22 +0900 Subject: [PATCH 16/16] =?UTF-8?q?=F0=9F=94=A5=20remove:=20TableButtons=20h?= =?UTF-8?q?andleModalClick=20=ED=95=A8=EC=88=98=20=EB=B0=8F=20status=20sta?= =?UTF-8?q?te=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/table/TableButtons.tsx | 23 ++------------------ 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/components/common/table/TableButtons.tsx b/src/components/common/table/TableButtons.tsx index d9427e0b..bc0e1830 100644 --- a/src/components/common/table/TableButtons.tsx +++ b/src/components/common/table/TableButtons.tsx @@ -1,7 +1,5 @@ -import { useEffect, useState, type MouseEvent } from 'react'; +import { useEffect, useState } from 'react'; import Button from '../Button'; -import TableStatus from './TableStatus'; -import { putNoticeApplications } from '@/api/applicationApi'; interface Props { index: number; @@ -9,23 +7,8 @@ interface Props { } export default function TableButtons({ index, click }: Props) { - const [status, setStatus] = useState<'pending' | 'accepted' | 'rejected'>( - 'pending', - ); const [isMobile, setIsMobile] = useState(window.innerWidth < 768); - const handleModalClick = async () => { - closeModal(); - setStatus(modal.status); - try { - await putNoticeApplications(shopId, noticeId, applicaitonId, { - status: modal.status, - }); - } catch { - setStatus('pending'); - } - }; - useEffect(() => { const handleResize = () => { setIsMobile(window.innerWidth < 768); @@ -34,7 +17,7 @@ export default function TableButtons({ index, click }: Props) { return () => window.removeEventListener('resize', handleResize); }, []); - return status === 'pending' ? ( + return (
- ) : ( - ); }