diff --git a/frontend/src/Cabinet/api/axios/axios.custom.ts b/frontend/src/Cabinet/api/axios/axios.custom.ts index 8ff595ce2..620d3f275 100644 --- a/frontend/src/Cabinet/api/axios/axios.custom.ts +++ b/frontend/src/Cabinet/api/axios/axios.custom.ts @@ -371,6 +371,23 @@ export const axiosItems = async (): Promise => { const response = await instance.get(axiosItemsURL); return response; } catch (error) { + console.log(error); + logAxiosError( + error, + ErrorType.STORE, + "상점 아이템 목록 불러오는중 오류 발생" + ); + throw error; + } +}; + +const axiosAdminItemsURL = "/v5/admin/items"; +export const axiosAdminItems = async (): Promise => { + try { + const response = await instance.get(axiosAdminItemsURL); + return response; + } catch (error) { + console.log(error); logAxiosError( error, ErrorType.STORE, @@ -743,9 +760,9 @@ export const axiosLentClubCabinet = async ( try { const response = await instance.post( axiosLentClubCabinetURL + - clubId.toString() + - "/cabinets/" + - cabinetId.toString() + clubId.toString() + + "/cabinets/" + + cabinetId.toString() ); return response; } catch (error) { @@ -905,6 +922,7 @@ export const axiosSendSlackNotificationToChannel = async ( } }; +// TODO: 확인하고 필요없으면 지우기 const axiosItemAssignURL = "v5/admin/items/assign"; export const axiosItemAssign = async ( itemSku: string, @@ -922,7 +940,7 @@ export const axiosItemAssign = async ( } }; -const axiosCoinAssignURL = "v5/admin/items/assign/coin"; +const axiosCoinAssignURL = "v5/admin/items/assign"; export const axiosCoinAssign = async ( itemSku: string, userIds: number[], diff --git a/frontend/src/Cabinet/components/Modals/StoreModal/AdminItemProvisionModal.tsx b/frontend/src/Cabinet/components/Modals/StoreModal/AdminItemProvisionModal.tsx index 89c8f616b..80f809c8e 100644 --- a/frontend/src/Cabinet/components/Modals/StoreModal/AdminItemProvisionModal.tsx +++ b/frontend/src/Cabinet/components/Modals/StoreModal/AdminItemProvisionModal.tsx @@ -15,8 +15,8 @@ import { import { IItemDetail } from "@/Cabinet/types/dto/store.dto"; import { StoreItemType } from "@/Cabinet/types/enum/store.enum"; import { - axiosCoinAssign, // axiosItemAssign, - axiosItems, + axiosCoinAssign, + axiosAdminItems, } from "@/Cabinet/api/axios/axios.custom"; interface IPenaltyModalProps { @@ -44,7 +44,6 @@ const AdminItemProvisionModal: React.FC = ({ onClose }) => { coinRefVal = coinRefVal == "" ? "0" : String(coinRefVal); setIsLoading(true); try { - // await axiosItemAssign(selectedItemSku, [targetUserInfo.userId!]); await axiosCoinAssign( selectedItemSku, [targetUserInfo.userId!], @@ -53,7 +52,7 @@ const AdminItemProvisionModal: React.FC = ({ onClose }) => { setModalTitle("아이템 지급완료"); } catch (error: any) { setHasErrorOnResponse(true); - if (error.response.ststus === 400) setModalTitle("아이템 지급실패"); + if (error.response.status === 400) setModalTitle("아이템 지급실패"); else error.response ? setModalTitle(error.response.data.message) @@ -82,7 +81,7 @@ const AdminItemProvisionModal: React.FC = ({ onClose }) => { const getItems = async () => { try { - const response = await axiosItems(); + const response = await axiosAdminItems(); setItems(response.data.items); } catch (error) { throw error; @@ -126,17 +125,19 @@ const AdminItemProvisionModal: React.FC = ({ onClose }) => { }, []); const getItemTypeOptions = (item: IItemDetail) => { + console.log(item.items); + return item.items.length === 1 ? [ - { - name: "타입이 없습니다", - value: item.items[0].itemSku, - hasNoOptions: true, - }, - ] + { + name: "타입이 없습니다", + value: item.items[0].itemSku, + hasNoOptions: true, + }, + ] : item.items.map((item) => { - return { name: item.itemDetails, value: item.itemSku }; - }); + return { name: item.itemDetails, value: item.itemSku }; + }); }; const modalContents: IModalContents = {