-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from softeerbootcamp4th/feat/CLAP-175
feat(CLAP-175): 어드민 미구현 기능 추가
- Loading branch information
Showing
21 changed files
with
592 additions
and
73 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { customFetch } from "@watermelon-clap/core/src/utils"; | ||
import { getAccessToken } from "@watermelon-clap/core/src/utils"; | ||
import { IWinner } from "./type"; | ||
|
||
export const apiGetLotteries = async (): Promise<IWinner[]> => { | ||
const url = `${import.meta.env.VITE_BACK_BASE_URL}/admin/lotteries`; | ||
|
||
return customFetch(url, { | ||
headers: { | ||
Authorization: `Bearer ${getAccessToken()}`, | ||
}, | ||
}) | ||
.then((response) => response.json()) | ||
.catch((error) => { | ||
throw error; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { customFetch } from "@watermelon-clap/core/src/utils"; | ||
import { getAccessToken } from "@watermelon-clap/core/src/utils"; | ||
import { IWinner } from "./type"; | ||
|
||
export const apiGetPartsWinner = async (): Promise<IWinner[]> => { | ||
const url = `${import.meta.env.VITE_BACK_BASE_URL}/admin/event/parts`; | ||
|
||
return customFetch(url, { | ||
headers: { | ||
Authorization: `Bearer ${getAccessToken()}`, | ||
}, | ||
}) | ||
.then((response) => response.json()) | ||
.catch((error) => { | ||
throw error; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { customFetch } from "@watermelon-clap/core/src/utils"; | ||
import { getAccessToken } from "@watermelon-clap/core/src/utils"; | ||
|
||
export const apiPostLottries = async (): Promise<Response> => { | ||
const url = `${import.meta.env.VITE_BACK_BASE_URL}/admin/event/lotteries | ||
`; | ||
return customFetch(url, { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${getAccessToken()}`, | ||
}, | ||
}) | ||
.then((response) => response) | ||
.catch((error) => { | ||
throw error; | ||
}); | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/admin/src/apis/partsEvent/apiPostLotteriesCheckStatus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { customFetch } from "@watermelon-clap/core/src/utils"; | ||
import { getAccessToken } from "@watermelon-clap/core/src/utils"; | ||
|
||
export const apiPostLotteriesCheckStatus = async ( | ||
id: string, | ||
): Promise<Response> => { | ||
const url = `${import.meta.env.VITE_BACK_BASE_URL}/admin/event/lotteries/${id}/done`; | ||
return customFetch(url, { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${getAccessToken()}`, | ||
}, | ||
}) | ||
.then((response) => response) | ||
.catch((error) => { | ||
throw error; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/admin/src/apis/partsEvent/apiPostPartsEventWinner.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { customFetch } from "@watermelon-clap/core/src/utils"; | ||
import { getAccessToken } from "@watermelon-clap/core/src/utils"; | ||
|
||
export const apiPostPartsEventWinner = async (): Promise<Response> => { | ||
const url = `${import.meta.env.VITE_BACK_BASE_URL}/admin/event/parts | ||
`; | ||
return customFetch(url, { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${getAccessToken()}`, | ||
}, | ||
}) | ||
.then((response) => response) | ||
.catch((error) => { | ||
throw error; | ||
}); | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/admin/src/apis/partsEvent/apiPostPartsWinnerCheckStatus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { customFetch } from "@watermelon-clap/core/src/utils"; | ||
import { getAccessToken } from "@watermelon-clap/core/src/utils"; | ||
|
||
export const apiPostPartsWinnerCheckStatus = async ( | ||
id: string, | ||
): Promise<Response> => { | ||
const url = `${import.meta.env.VITE_BACK_BASE_URL}/admin/event/parts/${id}/done`; | ||
return customFetch(url, { | ||
method: "POST", | ||
headers: { | ||
Authorization: `Bearer ${getAccessToken()}`, | ||
}, | ||
}) | ||
.then((response) => response) | ||
.catch((error) => { | ||
throw error; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/admin/src/common/components/ModalContainer/modal/PendingModal/PendingModal.css.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { css } from "@emotion/react"; | ||
import { theme } from "@watermelon-clap/core/src/theme"; | ||
|
||
export const pendingModalStyles = { | ||
content: { | ||
top: "50%", | ||
left: "50%", | ||
right: "auto", | ||
bottom: "auto", | ||
marginRight: "-50%", | ||
transform: "translate(-50%, -50%)", | ||
borderRadius: "8px", | ||
border: "none", | ||
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.2)", | ||
}, | ||
overlay: { | ||
backgroundColor: "rgba(0, 0, 0, 0.5)", | ||
zIndex: 1000, | ||
}, | ||
}; | ||
|
||
export const pendingModalBodyStyles = css` | ||
${theme.flex.center} | ||
${theme.flex.column} | ||
gap: 48.5px; | ||
padding: 23px 46px; | ||
text-align: center; | ||
`; | ||
|
||
export const pendingImgStyle = css` | ||
width: 60%; | ||
`; |
46 changes: 46 additions & 0 deletions
46
packages/admin/src/common/components/ModalContainer/modal/PendingModal/PendingModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import Modal from "react-modal"; | ||
import { useScrollStop } from "@watermelon-clap/core/src/hooks"; | ||
import { theme } from "@watermelon-clap/core/src/theme"; | ||
import { | ||
pendingModalStyles, | ||
pendingModalBodyStyles, | ||
pendingImgStyle, | ||
} from "./PendingModal.css"; | ||
import { DefaultModalProps } from "../../ModalContainer"; | ||
import { css } from "@emotion/react"; | ||
|
||
export const PendingModal = ({ isOpen, onRequestClose }: DefaultModalProps) => { | ||
useScrollStop(isOpen); | ||
|
||
return ( | ||
<Modal | ||
shouldCloseOnEsc={false} | ||
shouldCloseOnOverlayClick={false} | ||
isOpen={isOpen} | ||
onRequestClose={onRequestClose} | ||
style={pendingModalStyles} | ||
ariaHideApp={false} | ||
> | ||
<div css={pendingModalBodyStyles}> | ||
<h2>당첨자 추첨</h2> | ||
<span> | ||
<p>당첨자를 추첨중입니다.</p> | ||
<p>잠시만 기다려주세요.</p> | ||
</span> | ||
<div | ||
css={css` | ||
overflow: hidden; | ||
${theme.flex.center}; | ||
height: 40px; | ||
`} | ||
> | ||
<img | ||
css={pendingImgStyle} | ||
src="/images/modal/pending.gif" | ||
alt="로딩중 이미지" | ||
/> | ||
</div> | ||
</div> | ||
</Modal> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/admin/src/common/components/ModalContainer/modal/PendingModal/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { PendingModal } from "./PendingModal"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
packages/admin/src/components/partsEvent/WinnerDataGrid/MainEventWinnerDataGrid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { apiGetLotteries } from "@admin/apis/partsEvent/apiGetLotteries"; | ||
import { apiPostLotteriesCheckStatus } from "@admin/apis/partsEvent/apiPostLotteriesCheckStatus"; | ||
import { IWinner } from "@admin/apis/partsEvent/type"; | ||
import { Checkbox } from "@mui/material"; | ||
import { DataGrid, GridColDef } from "@mui/x-data-grid"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { ChangeEvent, useEffect, useState } from "react"; | ||
|
||
function mapDataToGrid(data: IWinner[] | undefined) { | ||
if (!Array.isArray(data)) { | ||
return []; | ||
} | ||
|
||
return data.map((item) => ({ | ||
rank: item.rank, | ||
reward: item.reward, | ||
id: item.uid, | ||
email: item.email, | ||
name: item.name, | ||
phoneNumber: item.phoneNumber, | ||
address: item.address, | ||
status: item.status, | ||
})); | ||
} | ||
|
||
export const MainEventWinnerDataGrid = () => { | ||
const { data: winnerList } = useQuery<IWinner[]>({ | ||
queryKey: ["mainEventWinnerList"], | ||
queryFn: () => apiGetLotteries(), | ||
}); | ||
|
||
const [gridData, setGridData] = useState(mapDataToGrid(winnerList)); | ||
|
||
const columns: GridColDef[] = [ | ||
{ field: "rank", headerName: "순위", width: 60 }, | ||
{ field: "reward", headerName: "경품", width: 200 }, | ||
{ field: "email", headerName: "수령인 이메일", width: 280 }, | ||
{ field: "name", headerName: "수령인 이름", width: 200 }, | ||
{ field: "phoneNumber", headerName: "수령인 핸드폰번호", width: 200 }, | ||
{ field: "address", headerName: "수령인 주소", width: 200 }, | ||
{ | ||
field: "status", | ||
headerName: "담당자 확인 정보", | ||
width: 200, | ||
renderCell: (params) => ( | ||
<Checkbox | ||
checked={params.value === "READY"} | ||
onChange={(event) => { | ||
handleCheckboxChange(params.row.id, event); | ||
}} | ||
/> | ||
), | ||
}, | ||
]; | ||
|
||
const handleCheckboxChange = ( | ||
id: string, | ||
event: ChangeEvent<HTMLInputElement>, | ||
) => { | ||
event.stopPropagation(); | ||
apiPostLotteriesCheckStatus(id); | ||
|
||
setGridData((prevData) => | ||
prevData.map((row) => | ||
row.id === id | ||
? { ...row, status: event.target.checked ? "READY" : "DONE" } | ||
: row, | ||
), | ||
); | ||
}; | ||
|
||
useEffect(() => { | ||
setGridData(mapDataToGrid(winnerList)); | ||
}, [winnerList]); | ||
|
||
return ( | ||
<div style={{ height: 400, width: "100%" }}> | ||
<DataGrid rows={gridData} columns={columns} /> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.