From 4291d7976c4e3f8a3ab9d3bb39cc0c0e8dcdb015 Mon Sep 17 00:00:00 2001 From: bcjang Date: Mon, 12 May 2025 10:43:24 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EC=9A=A9=EC=9E=90=EC=A0=9C=EC=9E=AC?= =?UTF-8?q?=20=EC=97=91=EC=85=80=20=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=88=98=EC=A0=95=20=EC=9D=B4=EC=9A=A9=EC=9E=90?= =?UTF-8?q?=EC=A0=9C=EC=9E=AC=20=EC=83=81=EC=84=B8=20=ED=91=9C=EC=8B=9C=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ServiceManage/UserBlockUploadBtn.js | 15 ++++- .../modal/UserBlockDetailModal.js | 61 ++++++------------- 2 files changed, 33 insertions(+), 43 deletions(-) diff --git a/src/components/ServiceManage/UserBlockUploadBtn.js b/src/components/ServiceManage/UserBlockUploadBtn.js index 39a31c1..38cd537 100644 --- a/src/components/ServiceManage/UserBlockUploadBtn.js +++ b/src/components/ServiceManage/UserBlockUploadBtn.js @@ -7,9 +7,14 @@ import Modal from '../common/modal/Modal'; import { Title, BtnWrapper, InputGroup, TableStyle, AlertText } from '../../styles/Components'; import { BlackListExcelDown, BlackListMultipleUpload } from '../../apis'; +import { useLoading } from '../../context/LoadingProvider'; +import { useAlert } from '../../context/AlertProvider'; +import { alertTypes } from '../../assets/data/types'; const UserBlockUploadBtn = ({ disabled, setGuidList, guidList, typeError, setTypeError }) => { const token = sessionStorage.getItem('token'); + const {withLoading} = useLoading(); + const {showToast} = useAlert(); // onchange states const [file, setFile] = useState(null); @@ -30,7 +35,15 @@ const UserBlockUploadBtn = ({ disabled, setGuidList, guidList, typeError, setTyp let fileTypes = ['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv']; setFile(e.target.files[0]); - setGuidList(await BlackListMultipleUpload(token, e.target.files[0])); + + await withLoading(async () => { + return await BlackListMultipleUpload(token, e.target.files[0]); + }).then(data => { + setGuidList(data); + }).catch(e => { + showToast(e, {type: alertTypes.error}); + }); + }; const handleFileDelete = e => { diff --git a/src/components/ServiceManage/modal/UserBlockDetailModal.js b/src/components/ServiceManage/modal/UserBlockDetailModal.js index 6e305e8..5102439 100644 --- a/src/components/ServiceManage/modal/UserBlockDetailModal.js +++ b/src/components/ServiceManage/modal/UserBlockDetailModal.js @@ -1,41 +1,19 @@ -import { Fragment, useState } from 'react'; +import { Fragment, useEffect, useState } from 'react'; import { styled } from 'styled-components'; import { Title, TableStyle, BtnWrapper, TextInput } from '../../../styles/Components'; import Modal from '../../common/modal/Modal'; import Button from '../../common/button/Button'; import { convertKTC } from '../../../utils'; +import { blockPeriod, blockSanctions, blockType } from '../../../assets/data'; const UserBlockDetailModal = ({ stateModal, handleModal, data }) => { - const history = data.history; - - const type = [ - { value: 'ACCESS_RESTRICTIONS', name: '접근 제한' }, - { value: 'CHATTING_RESTRICTIONS', name: '채팅 제한' }, - ]; - - const sanctions = [ - { value: 'BAD_BEHAVIOR', name: '비매너 행위' }, - { value: 'INAPPROPRIATE_NAME', name: '불건전 이름 사용' }, - { value: 'CASH_TRANSACTION', name: '현금거래 행위' }, - { value: 'GAME_INTERFERENCE', name: '게임 진행 방해' }, - { value: 'SERVICE_INTERFERENCE', name: '운영서비스 방해' }, - { value: 'ACCOUNT_IMPERSONATION', name: '계정도용' }, - { value: 'BUG_ABUSE', name: '버그/어뷰징' }, - { value: 'ILLEGAL_PROGRAM', name: '불법프로그램 사용' }, - { value: 'PERSONAL_INFO_LEAK', name: '개인정보 유출' }, - { value: 'ADMIN_IMPERSONATION', name: '운영자 사칭' }, - ]; - - const period = [ - { value: 'WARNING', name: '경고' }, - { value: 'D1', name: '1일' }, - { value: 'D3', name: '3일' }, - { value: 'D7', name: '7일' }, - { value: 'D15', name: '15일' }, - { value: 'D30', name: '30일' }, - { value: 'PERMANENT', name: '영구정지' }, - ]; + const [history, setHistory] = useState(); + useEffect(() => { + if(data){ + setHistory(data.history); + } + },[data]) return ( <> @@ -62,7 +40,7 @@ const UserBlockDetailModal = ({ stateModal, handleModal, data }) => { 제재 방식 - item.value === data.type && item.name).filter(data => data !== false) || ''} disabled /> + item.value === data.type)?.name} disabled /> @@ -71,7 +49,7 @@ const UserBlockDetailModal = ({ stateModal, handleModal, data }) => { 제재 기간 - item.value === data.period && item.name).filter(data => data !== false) || ''} disabled /> + item.value === data.period)?.name} disabled /> 시작일 : {convertKTC(data.start_dt, false)} 종료일 : {convertKTC(data.end_dt, false)} @@ -80,7 +58,7 @@ const UserBlockDetailModal = ({ stateModal, handleModal, data }) => { 제재 사유 - item.value === data.sanctions && item.name).filter(data => data !== false) || ''} disabled /> + item.value === data.sanctions)?.name} disabled /> @@ -100,18 +78,17 @@ const UserBlockDetailModal = ({ stateModal, handleModal, data }) => { - {history && - history.map((content, index) => ( + {history?.map((content, index) => ( {convertKTC(content.start_dt, false)} ~ {convertKTC(content.end_dt, false)} - {period.map(item => item.value === data.period && item.name)} - {type.map(item => item.value === data.type && item.name)} - {sanctions.map(item => item.value === data.sanctions && item.name)} - + {blockPeriod.find(item => item.value === content.period)?.name} + {blockType.find(item => item.value === content.type)?.name} + {blockSanctions.find(item => item.value === content.sanctions)?.name} + {content.create_by} ))} @@ -181,9 +158,9 @@ const BlockHistory = styled.div` top: 0; } tbody { - tr:first-child { - color: #d60000; - } + //tr:first-child { + // color: #d60000; + //} tr:last-child td { border-bottom: 1px solid #e8eaec; }