wr: 공통 alet 사용

This commit is contained in:
2026-03-17 18:05:02 +09:00
parent 43bbc81616
commit c57c7ce1f7
3 changed files with 38 additions and 32 deletions
@@ -5,7 +5,7 @@ import { btnClass } from "@/app/store/common/code";
import { excelCoSttnParsing } from "@/app/store/matDmd/coSttn/excel";
import { fetchType, getFetch } from "@/components/lib/api";
import {
confirmToast,
//confirmToast,
excelDownload,
formatPhoneNumber,
getCity,
@@ -29,9 +29,10 @@ import type { DemandCompType } from "@common/business_components/ui/sdmInsertFor
import { Button } from "@common/components/ui";
import moment from "moment";
import { useCallback, useEffect, useState } from "react";
import toast, { Toaster } from "react-hot-toast";
// import toast, { Toaster } from "react-hot-toast";
import { useTranslation } from "react-i18next";
import { useAlertStore } from "@/src/shared/lib";
import { useConfirm } from "@frontend-opensource/use-react-hooks";
export default function CoSttn() {
const {
@@ -50,6 +51,7 @@ export default function CoSttn() {
} = useWrStore((state) => state);
const { regAuthrtYn, mdfcnAuthrtYn } = auth;
const alert = useAlertStore((state) => state.setMessage);
const { confirm } = useConfirm();
const [bdstTable, setBdstTable] = useState<DemandCompType[]>();
const [pageNation, setPageNation] = useState(1);
const { coSttnRes, coSttnResCount } = coSttn;
@@ -168,16 +170,21 @@ export default function CoSttn() {
}
};
const { t } = useTranslation('base');
const initPassword = () => {
const initPassword = async () => {
if (updateData) {
const dmdInfoId = updateData.dmdInfoId;
const dmdInfoSliceId = `${dmdInfoId.slice(0, 3)}-${dmdInfoId.slice(3, 5)}-${dmdInfoId.slice(5, 10)}-${dmdInfoId.slice(10)}`
const handleConfirm = () => {
coSttnPwInit(dmdInfoId);
const handleConfirm = async () => {
const message = await coSttnPwInit(dmdInfoId);
alert(message);
};
confirmToast( t('isInitPw', { dmdInfoId: dmdInfoSliceId }), handleConfirm, 'text-2xl');
//confirmToast( t('isInitPw', { dmdInfoId: dmdInfoSliceId }), handleConfirm, 'text-2xl');
if (await confirm(t('isInitPw', { dmdInfoId: dmdInfoSliceId }))) {
await handleConfirm();
}
} else {
toast.error("비밀번호 초기화를 원하는 행을 선택해주세요.")
alert("비밀번호 초기화를 원하는 행을 선택해주세요.");
// toast.error("비밀번호 초기화를 원하는 행을 선택해주세요.")
}
}
@@ -239,7 +246,7 @@ export default function CoSttn() {
onClick={() => {
/* 저장 로직 */
if (!updateData) {
toast.error("수요처 변경을 원하는 행을 선택해주세요");
alert("수요처 변경을 원하는 행을 선택해주세요");
} else {
setIsDmdModal({
...isDmdModal,
@@ -333,9 +340,7 @@ export default function CoSttn() {
`/reuseFc/request/${data.dmdInfoId}`
);
if (dmd) {
alert(
`사업자번호 ${dmd.dmdInfoId}는 이미 등록되었습니다. 다시등록해주세요`
);
alert(`사업자번호 ${dmd.dmdInfoId}는 이미 등록되었습니다. 다시등록해주세요`);
return;
}
await regDemandCompany(data as DemandCompType);
@@ -353,7 +358,7 @@ export default function CoSttn() {
}
></UiModal>
</ContentsDiv>
<Toaster position="top-center" />
{/* <Toaster position="top-center" /> */}
</>
);
}
+8 -9
View File
@@ -2,7 +2,6 @@ import type { CommonTableProps } from "@/app/store/common/type/header";
import { fetchType, getFetchWithCount, putFectch } from "@/components/lib/api";
import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form";
import { coSttHeadListExport, coSttNodeListExport } from "./headList";
import toast from "react-hot-toast";
// 테이블 헤드 리스트
const coSttNodeList = coSttNodeListExport;
@@ -25,7 +24,7 @@ type coSttnActions = {
coSttnInit: (pageNo: string, pageCnt: string, con: string) => void;
coSttnSearch: (pageNo: string, pageCnt: string, con: string) => void;
coSttnTxtSearch: (pageNo: string, pageCnt: string, con: string, txt: string) => void;
coSttnPwInit: (dmdInfoId: string) => void;
coSttnPwInit: (dmdInfoId: string) => Promise<string>;
};
export type coSttnType = coSttnState & coSttnActions;
@@ -127,10 +126,14 @@ export const coSttnActionsExport: (set: any) => coSttnActions = (
try {
const response = await putFectch(`/reuseFc/request/chgPassword/${dmdInfoId}`,[])
if (response.status === 200) {
toast.success('비밀번호가 초기화 되었습니다.')
return "비밀번호가 초기화되었습니다.";
} else {
toast.error('비밀번호 초기화에 실패하였습니다')
return "비밀번호 초기화에 실패하였습니다.";
}
} catch (err) {
console.log(err);
return "비밀번호 초기화에 실패하였습니다.";
} finally {
set((state: coSttnState) => {
return {
...state,
@@ -140,11 +143,7 @@ export const coSttnActionsExport: (set: any) => coSttnActions = (
}
}
});
} catch (err) {
console.log(err);
toast.error('비밀번호 초기화에 실패하였습니다.')
}
}
}
}
}
+13 -11
View File
@@ -28,17 +28,19 @@ function ConfirmDialog({
{message}
</p>
</div>
<DialogFooter className="!justify-center">
<DialogClose asChild>
<Button onClick={onConfirm} {...confirmButtonProps}>
{confirmButtonProps?.label ?? "확인"}
</Button>
</DialogClose>
<DialogClose asChild>
<Button onClick={onCancel} color="white" {...cancelButtonProps}>
{cancelButtonProps?.label ?? "취소"}
</Button>
</DialogClose>
<DialogFooter>
<div className="flex w-full justify-center gap-2">
<DialogClose asChild>
<Button onClick={onConfirm} {...confirmButtonProps}>
{confirmButtonProps?.label ?? "확인"}
</Button>
</DialogClose>
<DialogClose asChild>
<Button onClick={onCancel} color="white" {...cancelButtonProps}>
{cancelButtonProps?.label ?? "취소"}
</Button>
</DialogClose>
</div>
</DialogFooter>
</DialogContent>
</Dialog>