Skip to content

Commit

Permalink
[FE] FEAT: 유저 아이템 지급 구현 #1695
Browse files Browse the repository at this point in the history
  • Loading branch information
seonmiki committed Oct 25, 2024
1 parent 04706a5 commit 6be179e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 17 deletions.
26 changes: 22 additions & 4 deletions frontend/src/Cabinet/api/axios/axios.custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,23 @@ export const axiosItems = async (): Promise<any> => {
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<any> => {
try {
const response = await instance.get(axiosAdminItemsURL);
return response;
} catch (error) {
console.log(error);
logAxiosError(
error,
ErrorType.STORE,
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -905,6 +922,7 @@ export const axiosSendSlackNotificationToChannel = async (
}
};

// TODO: 확인하고 필요없으면 지우기
const axiosItemAssignURL = "v5/admin/items/assign";
export const axiosItemAssign = async (
itemSku: string,
Expand All @@ -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[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -44,7 +44,6 @@ const AdminItemProvisionModal: React.FC<IPenaltyModalProps> = ({ onClose }) => {
coinRefVal = coinRefVal == "" ? "0" : String(coinRefVal);
setIsLoading(true);
try {
// await axiosItemAssign(selectedItemSku, [targetUserInfo.userId!]);
await axiosCoinAssign(
selectedItemSku,
[targetUserInfo.userId!],
Expand All @@ -53,7 +52,7 @@ const AdminItemProvisionModal: React.FC<IPenaltyModalProps> = ({ 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)
Expand Down Expand Up @@ -82,7 +81,7 @@ const AdminItemProvisionModal: React.FC<IPenaltyModalProps> = ({ onClose }) => {

const getItems = async () => {
try {
const response = await axiosItems();
const response = await axiosAdminItems();
setItems(response.data.items);
} catch (error) {
throw error;
Expand Down Expand Up @@ -126,17 +125,19 @@ const AdminItemProvisionModal: React.FC<IPenaltyModalProps> = ({ 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 = {
Expand Down

0 comments on commit 6be179e

Please sign in to comment.