diff --git a/apps/wr/app/matMng/coMng/coSttn/page.tsx b/apps/wr/app/matMng/coMng/coSttn/page.tsx index 8e2705450..1dbf511eb 100644 --- a/apps/wr/app/matMng/coMng/coSttn/page.tsx +++ b/apps/wr/app/matMng/coMng/coSttn/page.tsx @@ -5,6 +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, excelDownload, formatPhoneNumber, getCity, @@ -30,6 +31,7 @@ import { Button } from "@common/components/ui"; import moment from "moment"; import { useCallback, useEffect, useState } from "react"; import toast, { Toaster } from "react-hot-toast"; +import { useTranslation } from "react-i18next"; export default function CoSttn() { const { @@ -43,6 +45,7 @@ export default function CoSttn() { updateDemandCompany, coSttnTxtSearch, demandCompList, + coSttnPwInit, } = useWrStore((state) => state); const { regAuthrtYn, mdfcnAuthrtYn } = auth; @@ -103,9 +106,8 @@ export default function CoSttn() { ...item, telno: formatPhoneNumber(item.telno || undefined), regDt: moment(item.regDt).format("YYYY-MM-DD"), - dmdInfoId: `${item.dmdInfoId.slice(0, 3)}-${item.dmdInfoId.slice(3, 5)}-${item.dmdInfoId.slice(5,10)}-${item.dmdInfoId.slice(10)}` - })); - console.log("chData:", chData) + dmdInfoId: `${item.dmdInfoId.slice(0, 3)}-${item.dmdInfoId.slice(3, 5)}-${item.dmdInfoId.slice(5, 10)}-${item.dmdInfoId.slice(10)}` + })); // .filter((item: any) => item !== undefined); setBdstTable(chData); } else if (coSttnRes?.length == 0) { @@ -156,6 +158,18 @@ export default function CoSttn() { } } }; + const { t } = useTranslation('base'); + const initPassword = () => { + if (upadateData) { + const dmdInfoId = upadateData.dmdInfoId; + const handleConfirm = () => { + coSttnPwInit(dmdInfoId); + }; + confirmToast(t('isInitPw'), handleConfirm); + } else { + toast.error("비밀번호 초기화를 원하는 행을 선택해주세요.") + } + } return ( <> @@ -167,7 +181,7 @@ export default function CoSttn() {
- +
+
@@ -286,9 +307,7 @@ export default function CoSttn() { objSearch.sgg && objSearch.sgg !== "0" ? objSearch.sgg : objSearch.city; - console.log("data ", data); if (upadateData?.dmdInfoId) { - console.log("data ", data); await updateDemandCompany(data as DemandCompType); coSttnInit("1", "13", String(con)); setIsDmdModal({ diff --git a/apps/wr/app/store/matDmd/coSttn/index.tsx b/apps/wr/app/store/matDmd/coSttn/index.tsx index 1e20e8a76..1f7b2c54b 100644 --- a/apps/wr/app/store/matDmd/coSttn/index.tsx +++ b/apps/wr/app/store/matDmd/coSttn/index.tsx @@ -1,7 +1,8 @@ import type { CommonTableProps } from "@/app/store/common/type/header"; -import { fetchType, getFetchWithCount } from "@/components/lib/api"; +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; @@ -21,9 +22,10 @@ export type coSttnState = { }; 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; + 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; }; export type coSttnType = coSttnState & coSttnActions; @@ -44,7 +46,7 @@ export const coSttnActionsExport: (set: any) => coSttnActions = ( set: any ) => { return { - coSttnInit: async (pageNo:string, pageCnt:string, con: string) => { + coSttnInit: async (pageNo: string, pageCnt: string, con: string) => { try { const coSttnRes = await getFetchWithCount( @@ -67,56 +69,81 @@ export const coSttnActionsExport: (set: any) => coSttnActions = ( console.log(e) } }, - coSttnSearch: async (pageNo:string, pageCnt:string, con: string) => { - try { - const coSttnRes = await getFetchWithCount( - fetchType.WR, - `/reuseFc/request/${pageNo}/${pageCnt}/${con}` - ); - if (Number(pageCnt) >= 10000) { - set((state: coSttnState) => { - return { - ...state, - coSttn: { - ...state.coSttn, - excelList: coSttnRes.data, - //isInit: false, - }, - }; - }); - } else - set((state: coSttnState) => { - return { - ...state, - coSttn: { - ...state.coSttn, - coSttnRes: coSttnRes.data, - isInit: false, - coSttnResCount : coSttnRes.count, - }, - }; - }); - } catch (erTxt) { - console.log("error", erTxt); - } - }, - coSttnTxtSearch: async (pageNo:string, pageCnt:string, con: string, txt: string) => { - try { - const coSttnRes = await getFetchWithCount( - fetchType.WR, - `/reuseFc/request/${pageNo}/${pageCnt}/${con}/${txt}`) - set((state: coSttnState) => { - return { - ...state, - coSttn: { - ...state.coSttn, - coSttnRes: coSttnRes.data, - coSttnResCount: coSttnRes.count, - isInit: false, - }}}) - } catch (erTxt) { - console.log("error", erTxt); + coSttnSearch: async (pageNo: string, pageCnt: string, con: string) => { + try { + const coSttnRes = await getFetchWithCount( + fetchType.WR, + `/reuseFc/request/${pageNo}/${pageCnt}/${con}` + ); + if (Number(pageCnt) >= 10000) { + set((state: coSttnState) => { + return { + ...state, + coSttn: { + ...state.coSttn, + excelList: coSttnRes.data, + //isInit: false, + }, + }; + }); + } else + set((state: coSttnState) => { + return { + ...state, + coSttn: { + ...state.coSttn, + coSttnRes: coSttnRes.data, + isInit: false, + coSttnResCount: coSttnRes.count, + }, + }; + }); + } catch (erTxt) { + console.log("error", erTxt); + } + }, + coSttnTxtSearch: async (pageNo: string, pageCnt: string, con: string, txt: string) => { + try { + const coSttnRes = await getFetchWithCount( + fetchType.WR, + `/reuseFc/request/${pageNo}/${pageCnt}/${con}/${txt}`) + set((state: coSttnState) => { + return { + ...state, + coSttn: { + ...state.coSttn, + coSttnRes: coSttnRes.data, + coSttnResCount: coSttnRes.count, + isInit: false, + } } + }) + } catch (erTxt) { + console.log("error", erTxt); + } + }, + coSttnPwInit: async (dmdInfoId: string) => { + try { + const response = await putFectch(`/reuseFc/request/chgPassword/${dmdInfoId}`,[]) + if (response.status === 200) { + toast.success('비밀번호가 초기화 되었습니다.') + } else { + toast.error('비밀번호 초기화에 실패하였습니다') } + set((state: coSttnState) => { + return { + ...state, + coSttn: { + ...state.coSttn, + isInit: false, + } + } + }); + } catch (err) { + console.log(err); + toast.error('비밀번호 초기화에 실패하였습니다.') + + } + } } } \ No newline at end of file diff --git a/apps/wr/public/locales/ko/message.json b/apps/wr/public/locales/ko/message.json index d3c55de5e..859df00cf 100644 --- a/apps/wr/public/locales/ko/message.json +++ b/apps/wr/public/locales/ko/message.json @@ -1,10 +1,10 @@ { - "deleteMsg" : "{{name}}가 삭제되었습니다.", + "deleteMsg": "{{name}}가 삭제되었습니다.", "insertMsg": "{{name}}가 저장되었습니다.", "updateMsg": "{{name}}가 수정되었습니다.", - "errorMsg": "{{name}} 중 오류가 발생했습니다.", + "errorMsg": "{{name}} 중 오류가 발생했습니다.", "fileErrMsg": "빈 파일 또는 파일 오류입니다.", - "selectErrMsg": "{{name}}을(를) 선택해주세요.", + "selectErrMsg": "{{name}}을(를) 선택해주세요.", "noChangedErrMsg": "변경사항이 없습니다.", "dateErrMsg": "시작년도를 종료년도 이후로 설정할 수 없습니다.", "fileDateErrMsg": "파일업로드 이전에 등록년도를 작성해주세요.", @@ -12,19 +12,15 @@ "isUpdateMsg": "수정한 정보를 저장하시겠습니까?", "isInsertMsg": "등록하시겠습니까?", "isUpdatetMsg": "수정하시겠습니까?", - "matchFinishMsg" : "{{name}}이(가) 완료되었습니다.", + "matchFinishMsg": "{{name}}이(가) 완료되었습니다.", "excelDownErrMsg": "다운로드할 데이터가 없습니다.", - "isMatchFinishMsg":" 매칭완료를 진행하시겠습니까?", - "isNotMatchFinishMsg":"검토완료중 매칭완료 여부를 체크한 항목이 없습니다.", - "canNotChangeMatStateMsg":"매칭완료된 항목은 상태를 변경할 수 없습니다.", - - - + "isMatchFinishMsg": " 매칭완료를 진행하시겠습니까?", + "isNotMatchFinishMsg": "검토완료중 매칭완료 여부를 체크한 항목이 없습니다.", + "canNotChangeMatStateMsg": "매칭완료된 항목은 상태를 변경할 수 없습니다.", + "isInitPw": "비밀번호를 초기화하시겠습니까?", "alreadyInsertedErrMsg": "사업자번호 {{num}}(은)는 이미 등록되었습니다. 다시 등록해주세요.", "saveRowErrMsg": "수정을 원하는 행을 선택하고 저장버튼을 눌러주세요.", - "costCalcErrMsg":"공사비 계산 진행 후 저장을 눌러주세요", + "costCalcErrMsg": "공사비 계산 진행 후 저장을 눌러주세요", "maxYearErrMsg": "최대 {{year}}년까지 선택가능합니다.", "checkQtyMsg": "요구수량(m³/일)을 확인해주세요 계산할 수 없습니다." - -} - +} \ No newline at end of file