sn: 최종확정예산사업 popup
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { getData, postRawJson } from "@/components/lib/api";
|
||||
import type {
|
||||
CfmtnBgtCode,
|
||||
CfmtnBgtPage,
|
||||
CfmtnBgtRegistrationResult,
|
||||
} from "../model/cfmtn-bgt-types";
|
||||
|
||||
const unwrap = <T>(v: unknown): T =>
|
||||
v && typeof v === "object" && "data" in v
|
||||
? (v as { data: T }).data
|
||||
: (v as T);
|
||||
export const getCfmtnBgtCodes = (year: string) =>
|
||||
getData(
|
||||
`v1/onsemiro/cfmtnBgt/code?year=${encodeURIComponent(year)}`,
|
||||
) as Promise<CfmtnBgtCode[]>;
|
||||
export const getCfmtnBgtPage = (params: URLSearchParams) =>
|
||||
getData(`v1/onsemiro/cfmtnBgt?${params}`) as Promise<CfmtnBgtPage>;
|
||||
export const registerCfmtnBgt = async (bizSe: string, seqNos: number[]) =>
|
||||
unwrap<CfmtnBgtRegistrationResult>(
|
||||
await postRawJson("v1/obsltPplBiz/onsemiro/cfmtnBgt", { bizSe, seqNos }),
|
||||
);
|
||||
@@ -0,0 +1,82 @@
|
||||
import * as XLSX from "xlsx";
|
||||
import type { CfmtnBgtRow } from "../model/cfmtn-bgt-types";
|
||||
|
||||
const HEADERS = [
|
||||
"순번",
|
||||
"권역",
|
||||
"단위유역",
|
||||
"중권역",
|
||||
"환경청",
|
||||
"시도",
|
||||
"시군구",
|
||||
"사업코드",
|
||||
"사업명",
|
||||
"사업구분",
|
||||
"세부사업",
|
||||
"내역사업",
|
||||
"세부내역",
|
||||
"사업진행상태",
|
||||
"신규/계속",
|
||||
"착수",
|
||||
"준공",
|
||||
"사업규모_하수처리장",
|
||||
"사업규모_하수관로",
|
||||
"보조율(%)",
|
||||
"총사업비_합계",
|
||||
"총사업비_국고",
|
||||
"총사업비_지방비",
|
||||
"총사업비_원인자부담금",
|
||||
"총사업비_환특융자",
|
||||
"총사업비_기타",
|
||||
"전년까지사업비",
|
||||
"년차사업비_합계",
|
||||
"년차사업비_국고",
|
||||
"년차사업비_지방비",
|
||||
"년차사업비_원인자부담금",
|
||||
"년차사업비_환특융자",
|
||||
"년차사업비_기타",
|
||||
];
|
||||
const values = (r: CfmtnBgtRow) => [
|
||||
r.rowNumber,
|
||||
r.rvbsn,
|
||||
r.lgbsn,
|
||||
r.mdmbsn,
|
||||
r.govArea,
|
||||
r.sido,
|
||||
r.gugun,
|
||||
r.bizCd,
|
||||
r.bizNm,
|
||||
r.sourceBizSe,
|
||||
r.untBzNm,
|
||||
r.mevBzNm,
|
||||
r.dtlBzNm,
|
||||
r.bizStatus,
|
||||
r.newContinuing,
|
||||
r.startYear,
|
||||
r.endYear,
|
||||
r.treatmentPlantScale,
|
||||
r.pipeScale,
|
||||
r.aidRate,
|
||||
r.totalBizAmount,
|
||||
r.totalNational,
|
||||
r.totalLocal,
|
||||
r.totalBeneficiary,
|
||||
r.totalLoan,
|
||||
r.totalEtc,
|
||||
r.previousBizAmount,
|
||||
r.annualBizAmount,
|
||||
r.annualNational,
|
||||
r.annualLocal,
|
||||
r.annualBeneficiary,
|
||||
r.annualLoan,
|
||||
r.annualEtc,
|
||||
];
|
||||
export const downloadCfmtnBgtExcel = (rows: CfmtnBgtRow[], year: string) => {
|
||||
const wb = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(
|
||||
wb,
|
||||
XLSX.utils.aoa_to_sheet([HEADERS, ...rows.map(values)]),
|
||||
"최종확정예산관리",
|
||||
);
|
||||
XLSX.writeFileXLSX(wb, `최종확정예산관리_${year}.xlsx`);
|
||||
};
|
||||
@@ -0,0 +1,59 @@
|
||||
export type CfmtnBgtCode = {
|
||||
year: string;
|
||||
untBzCd: string;
|
||||
untBzNm: string;
|
||||
mevBzNm: string;
|
||||
dtlBzCd: string;
|
||||
dtlBzNm: string;
|
||||
};
|
||||
export type CfmtnBgtRow = {
|
||||
rowNumber: number;
|
||||
seqNo: number;
|
||||
year: string;
|
||||
rvbsn: string | null;
|
||||
lgbsn: string | null;
|
||||
mdmbsn: string | null;
|
||||
govArea: string | null;
|
||||
sido: string | null;
|
||||
gugun: string | null;
|
||||
bizCd: string | null;
|
||||
bizNm: string;
|
||||
sourceBizSe: string | null;
|
||||
untBzCd: string | null;
|
||||
untBzNm: string | null;
|
||||
mevBzNm: string | null;
|
||||
dtlBzCd: string | null;
|
||||
dtlBzNm: string | null;
|
||||
bizStatus: string;
|
||||
newContinuing: string | null;
|
||||
startYear: string | null;
|
||||
endYear: string | null;
|
||||
treatmentPlantScale: string | null;
|
||||
pipeScale: string | null;
|
||||
aidRate: number;
|
||||
totalBizAmount: number;
|
||||
totalNational: number;
|
||||
totalLocal: number;
|
||||
totalBeneficiary: number;
|
||||
totalLoan: number;
|
||||
totalEtc: number;
|
||||
previousBizAmount: number;
|
||||
annualBizAmount: number;
|
||||
annualNational: number;
|
||||
annualLocal: number;
|
||||
annualBeneficiary: number;
|
||||
annualLoan: number;
|
||||
annualEtc: number;
|
||||
};
|
||||
export type CfmtnBgtPage = {
|
||||
content: CfmtnBgtRow[];
|
||||
totalElements: number;
|
||||
totalPages: number;
|
||||
number: number;
|
||||
size: number;
|
||||
};
|
||||
export type CfmtnBgtRegistrationResult = {
|
||||
requestedCount: number;
|
||||
insertedCount: number;
|
||||
skippedCount: number;
|
||||
};
|
||||
@@ -0,0 +1,411 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Button, Input } from "@common/components/ui";
|
||||
import { SelectBox } from "@common/business_components/ui";
|
||||
import useOnsemiroAddrStore from "@/app/store/useOnsemiroAddrStore";
|
||||
import type { WindowPopupContentProps } from "../../windowPopup/model/types";
|
||||
import { WINDOW_POPUP_MESSAGE_TYPE } from "../../windowPopup/model/types";
|
||||
import { postPopupMessageAndClose } from "../../windowPopup/lib/popupMessage";
|
||||
import {
|
||||
getCfmtnBgtCodes,
|
||||
getCfmtnBgtPage,
|
||||
registerCfmtnBgt,
|
||||
} from "../api/cfmtn-bgt-api";
|
||||
import { downloadCfmtnBgtExcel } from "../lib/cfmtn-bgt-excel";
|
||||
import type {
|
||||
CfmtnBgtCode,
|
||||
CfmtnBgtPage,
|
||||
CfmtnBgtRow,
|
||||
} from "../model/cfmtn-bgt-types";
|
||||
|
||||
const ALL = { text: "전체", val: "0" };
|
||||
const PAGE_SIZE = 20;
|
||||
const EXPORT_SIZE = 1000;
|
||||
const yearDefault =
|
||||
process.env.NEXT_PUBLIC_NODE_ENV === "development"
|
||||
? "2024"
|
||||
: String(new Date().getFullYear() - 1);
|
||||
const YEAR_OPTIONS = Array.from({ length: 6 }, (_, index) => {
|
||||
const year = String(Number(yearDefault) - index);
|
||||
return { text: year, val: year };
|
||||
});
|
||||
const COLS: [keyof CfmtnBgtRow, string][] = [
|
||||
["rowNumber", "순번"],
|
||||
["rvbsn", "권역"],
|
||||
["lgbsn", "단위유역"],
|
||||
["mdmbsn", "중권역"],
|
||||
["govArea", "환경청"],
|
||||
["sido", "시도"],
|
||||
["gugun", "시군구"],
|
||||
["bizCd", "사업코드"],
|
||||
["bizNm", "사업명"],
|
||||
["sourceBizSe", "사업구분"],
|
||||
["untBzNm", "세부사업"],
|
||||
["mevBzNm", "내역사업"],
|
||||
["dtlBzNm", "세부내역"],
|
||||
["bizStatus", "진행상태"],
|
||||
["newContinuing", "신규/계속"],
|
||||
["startYear", "착수"],
|
||||
["endYear", "준공"],
|
||||
["treatmentPlantScale", "처리장규모"],
|
||||
["pipeScale", "관로규모"],
|
||||
["aidRate", "보조율"],
|
||||
["totalBizAmount", "총사업비 합계"],
|
||||
["totalNational", "총사업비 국고"],
|
||||
["totalLocal", "총사업비 지방비"],
|
||||
["totalBeneficiary", "총사업비 원인자"],
|
||||
["totalLoan", "총사업비 융자"],
|
||||
["totalEtc", "총사업비 기타"],
|
||||
["previousBizAmount", "전년까지사업비"],
|
||||
["annualBizAmount", "년차 합계"],
|
||||
["annualNational", "년차 국고"],
|
||||
["annualLocal", "년차 지방비"],
|
||||
["annualBeneficiary", "년차 원인자"],
|
||||
["annualLoan", "년차 융자"],
|
||||
["annualEtc", "년차 기타"],
|
||||
];
|
||||
const empty: CfmtnBgtPage = {
|
||||
content: [],
|
||||
totalElements: 0,
|
||||
totalPages: 0,
|
||||
number: 0,
|
||||
size: PAGE_SIZE,
|
||||
};
|
||||
const uniq = (items: { text: string; val: string }[]) =>
|
||||
Array.from(new Map(items.map((i) => [`${i.text}|${i.val}`, i])).values());
|
||||
|
||||
export default function CfmtnBgtPopupContent({
|
||||
searchParams,
|
||||
}: WindowPopupContentProps) {
|
||||
const bizSe =
|
||||
typeof searchParams.bizSe === "string" ? searchParams.bizSe : "";
|
||||
const { govArea, city, sgg, fetchGovArea, fetchCity, fetchSgg } =
|
||||
useOnsemiroAddrStore();
|
||||
const initial = () => ({
|
||||
year: yearDefault,
|
||||
govArea: "",
|
||||
sido: "",
|
||||
gugun: "",
|
||||
untBzCd: "",
|
||||
mevBzNm: bizSe === "정비사업" ? "하수관로정비" : "노후하수관로정밀조사지원",
|
||||
dtlBzCd: "",
|
||||
bizNm: "",
|
||||
});
|
||||
const [search, setSearch] = useState(initial);
|
||||
const [codes, setCodes] = useState<CfmtnBgtCode[]>([]);
|
||||
const [page, setPage] = useState(0);
|
||||
const [data, setData] = useState(empty);
|
||||
const [selected, setSelected] = useState<Set<number>>(new Set());
|
||||
const [notice, setNotice] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
useEffect(() => {
|
||||
void fetchGovArea();
|
||||
void fetchCity();
|
||||
void fetchSgg();
|
||||
}, [fetchCity, fetchGovArea, fetchSgg]);
|
||||
useEffect(() => {
|
||||
void getCfmtnBgtCodes(search.year)
|
||||
.then(setCodes)
|
||||
.catch((e) =>
|
||||
setNotice(
|
||||
e instanceof Error ? e.message : "코드를 조회하지 못했습니다.",
|
||||
),
|
||||
);
|
||||
}, [search.year]);
|
||||
const untOptions = useMemo(
|
||||
() =>
|
||||
uniq(
|
||||
codes
|
||||
.filter((c) => c.untBzNm?.startsWith("하수관로정비"))
|
||||
.map((c) => ({ text: c.untBzNm, val: c.untBzCd })),
|
||||
),
|
||||
[codes],
|
||||
);
|
||||
useEffect(() => {
|
||||
const first = untOptions[0];
|
||||
if (!search.untBzCd && first)
|
||||
setSearch((s) => ({ ...s, untBzCd: first.val }));
|
||||
}, [search.untBzCd, untOptions]);
|
||||
const mevOptions = useMemo(
|
||||
() =>
|
||||
uniq(
|
||||
codes
|
||||
.filter((c) => !search.untBzCd || c.untBzCd === search.untBzCd)
|
||||
.map((c) => ({ text: c.mevBzNm, val: c.mevBzNm }))
|
||||
.filter((x) => x.text),
|
||||
),
|
||||
[codes, search.untBzCd],
|
||||
);
|
||||
const dtlOptions = useMemo(
|
||||
() =>
|
||||
uniq(
|
||||
codes
|
||||
.filter(
|
||||
(c) =>
|
||||
(!search.untBzCd || c.untBzCd === search.untBzCd) &&
|
||||
(!search.mevBzNm || c.mevBzNm === search.mevBzNm) &&
|
||||
(bizSe !== "정비사업" ||
|
||||
c.dtlBzNm?.startsWith("노후하수관로정비")),
|
||||
)
|
||||
.map((c) => ({ text: c.dtlBzNm, val: c.dtlBzCd }))
|
||||
.filter((x) => x.text),
|
||||
),
|
||||
[bizSe, codes, search.mevBzNm, search.untBzCd],
|
||||
);
|
||||
useEffect(() => {
|
||||
const first = dtlOptions[0];
|
||||
if (bizSe === "정비사업" && !search.dtlBzCd && first)
|
||||
setSearch((s) => ({ ...s, dtlBzCd: first.val }));
|
||||
}, [bizSe, dtlOptions, search.dtlBzCd]);
|
||||
const cityName = city.find((x) => String(x.val) === search.sido)?.text ?? "";
|
||||
const sggOptions = sgg.filter(
|
||||
(x) => !search.sido || String(x.val).startsWith(search.sido.slice(0, 2)),
|
||||
);
|
||||
const params = (targetPage: number, size = PAGE_SIZE) => {
|
||||
const p = new URLSearchParams({
|
||||
page: String(targetPage),
|
||||
size: String(size),
|
||||
year: search.year,
|
||||
});
|
||||
if (search.govArea)
|
||||
p.set(
|
||||
"govArea",
|
||||
govArea.find((x) => String(x.val) === search.govArea)?.text ??
|
||||
search.govArea,
|
||||
);
|
||||
if (cityName) p.set("sido", cityName);
|
||||
if (search.gugun)
|
||||
p.set(
|
||||
"gugun",
|
||||
sggOptions.find((x) => String(x.val) === search.gugun)?.text ?? "",
|
||||
);
|
||||
["untBzCd", "mevBzNm", "dtlBzCd", "bizNm"].forEach((k) => {
|
||||
const v = search[k as keyof typeof search];
|
||||
if (v) p.set(k, v);
|
||||
});
|
||||
return p;
|
||||
};
|
||||
const load = async (targetPage = 0) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
setData(await getCfmtnBgtPage(params(targetPage)));
|
||||
setPage(targetPage);
|
||||
setNotice("");
|
||||
} catch (e) {
|
||||
setNotice(e instanceof Error ? e.message : "조회하지 못했습니다.");
|
||||
setData(empty);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
const reset = () => {
|
||||
setSearch(initial());
|
||||
setData(empty);
|
||||
setSelected(new Set());
|
||||
setPage(0);
|
||||
setNotice("");
|
||||
};
|
||||
const download = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
let p = 0,
|
||||
total = 1;
|
||||
const rows: CfmtnBgtRow[] = [];
|
||||
while (p < total) {
|
||||
const result = await getCfmtnBgtPage(params(p, EXPORT_SIZE));
|
||||
rows.push(...result.content);
|
||||
total = result.totalPages;
|
||||
p++;
|
||||
}
|
||||
downloadCfmtnBgtExcel(rows, search.year);
|
||||
} catch (e) {
|
||||
setNotice(e instanceof Error ? e.message : "엑셀을 내려받지 못했습니다.");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
const register = async () => {
|
||||
if (!selected.size) return;
|
||||
if (!confirm(`선택한 ${selected.size}건을 ${bizSe}으로 등록하시겠습니까?`))
|
||||
return;
|
||||
setLoading(true);
|
||||
try {
|
||||
const r = await registerCfmtnBgt(bizSe, [...selected]);
|
||||
postPopupMessageAndClose(WINDOW_POPUP_MESSAGE_TYPE.CFMTN_BGT_REGISTERED, {
|
||||
insertedCount: String(r.insertedCount),
|
||||
skippedCount: String(r.skippedCount),
|
||||
});
|
||||
} catch (e) {
|
||||
setNotice(e instanceof Error ? e.message : "등록하지 못했습니다.");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div className="min-w-[1300px] p-5 text-sm">
|
||||
<div className="mb-3 flex flex-wrap items-end gap-3">
|
||||
<SelectBox
|
||||
label="환경청"
|
||||
className=""
|
||||
selectClass="w-40"
|
||||
selectArray={[ALL, ...govArea]}
|
||||
value={search.govArea}
|
||||
onSelectValue={(v) =>
|
||||
setSearch((s) => ({ ...s, govArea: String(v) }))
|
||||
}
|
||||
/>
|
||||
<SelectBox
|
||||
label="시도"
|
||||
className=""
|
||||
selectClass="w-40"
|
||||
selectArray={[...city]}
|
||||
value={search.sido}
|
||||
onSelectValue={(v) =>
|
||||
setSearch((s) => ({ ...s, sido: String(v), gugun: "" }))
|
||||
}
|
||||
/>
|
||||
<SelectBox
|
||||
label="시군구"
|
||||
className=""
|
||||
selectClass="w-40"
|
||||
selectArray={[ALL, ...sggOptions]}
|
||||
value={search.gugun}
|
||||
onSelectValue={(v) => setSearch((s) => ({ ...s, gugun: String(v) }))}
|
||||
/>
|
||||
<SelectBox
|
||||
label="세부사업"
|
||||
className=""
|
||||
selectClass="w-48"
|
||||
selectArray={[ALL, ...untOptions]}
|
||||
value={search.untBzCd}
|
||||
onSelectValue={(v) =>
|
||||
setSearch((s) => ({ ...s, untBzCd: String(v), dtlBzCd: "" }))
|
||||
}
|
||||
/>
|
||||
<SelectBox
|
||||
label="내역사업"
|
||||
className=""
|
||||
selectClass="w-48"
|
||||
selectArray={[ALL, ...mevOptions]}
|
||||
value={search.mevBzNm}
|
||||
onSelectValue={(v) =>
|
||||
setSearch((s) => ({ ...s, mevBzNm: String(v), dtlBzCd: "" }))
|
||||
}
|
||||
/>
|
||||
<SelectBox
|
||||
label="세부내역"
|
||||
className=""
|
||||
selectClass="w-52"
|
||||
selectArray={[ALL, ...dtlOptions]}
|
||||
value={search.dtlBzCd}
|
||||
onSelectValue={(v) =>
|
||||
setSearch((s) => ({ ...s, dtlBzCd: String(v) }))
|
||||
}
|
||||
/>
|
||||
<SelectBox
|
||||
label="년도"
|
||||
className=""
|
||||
selectClass="w-24"
|
||||
selectArray={YEAR_OPTIONS}
|
||||
value={search.year}
|
||||
onSelectValue={(v) => setSearch((s) => ({ ...s, year: String(v) }))}
|
||||
/>
|
||||
<Input
|
||||
placeholder="사업명"
|
||||
value={search.bizNm}
|
||||
onChange={(e) => setSearch((s) => ({ ...s, bizNm: e.target.value }))}
|
||||
/>
|
||||
<Button onClick={() => void load(0)}>조회</Button>
|
||||
<Button onClick={reset}>초기화</Button>
|
||||
<Button onClick={() => void download()}>엑셀다운로드</Button>
|
||||
</div>
|
||||
{notice && <div className="mb-2 text-red-600">{notice}</div>}
|
||||
<div className="mb-2 flex justify-between">
|
||||
<span>
|
||||
총 {data.totalElements.toLocaleString()}건 / 선택 {selected.size}건
|
||||
</span>
|
||||
<Button
|
||||
disabled={!selected.size || loading}
|
||||
onClick={() => void register()}
|
||||
>
|
||||
등록
|
||||
</Button>
|
||||
</div>
|
||||
<div className="overflow-x-auto border">
|
||||
<table className="min-w-[4200px] border-collapse">
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="border p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={
|
||||
data.content.length > 0 &&
|
||||
data.content.every((r) => selected.has(r.seqNo))
|
||||
}
|
||||
onChange={(e) =>
|
||||
setSelected((prev) => {
|
||||
const n = new Set(prev);
|
||||
data.content.forEach((r) =>
|
||||
e.target.checked ? n.add(r.seqNo) : n.delete(r.seqNo),
|
||||
);
|
||||
return n;
|
||||
})
|
||||
}
|
||||
/>
|
||||
</th>
|
||||
{COLS.map(([k, t]) => (
|
||||
<th
|
||||
key={String(k)}
|
||||
className="whitespace-nowrap border bg-gray-100 p-2"
|
||||
>
|
||||
{t}
|
||||
</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data.content.map((r) => (
|
||||
<tr key={r.seqNo}>
|
||||
<td className="border p-2 text-center">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={selected.has(r.seqNo)}
|
||||
onChange={(e) =>
|
||||
setSelected((prev) => {
|
||||
const n = new Set(prev);
|
||||
e.target.checked ? n.add(r.seqNo) : n.delete(r.seqNo);
|
||||
return n;
|
||||
})
|
||||
}
|
||||
/>
|
||||
</td>
|
||||
{COLS.map(([k]) => (
|
||||
<td key={String(k)} className="whitespace-nowrap border p-2">
|
||||
{typeof r[k] === "number"
|
||||
? (r[k] as number).toLocaleString()
|
||||
: String(r[k] ?? "")}
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="mt-3 flex justify-center gap-2">
|
||||
<Button disabled={page <= 0} onClick={() => void load(page - 1)}>
|
||||
이전
|
||||
</Button>
|
||||
<span>
|
||||
{page + 1} / {Math.max(data.totalPages, 1)}
|
||||
</span>
|
||||
<Button
|
||||
disabled={page + 1 >= data.totalPages}
|
||||
onClick={() => void load(page + 1)}
|
||||
>
|
||||
다음
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3,7 +3,13 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
|
||||
import { SearchDiv, SearchFormLeft, SearchFormRight, SelectBox, UiTable } from "@common/business_components/ui";
|
||||
import {
|
||||
SearchDiv,
|
||||
SearchFormLeft,
|
||||
SearchFormRight,
|
||||
SelectBox,
|
||||
UiTable,
|
||||
} from "@common/business_components/ui";
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import { Button, Input, Label } from "@common/components/ui";
|
||||
|
||||
@@ -13,12 +19,20 @@ import {
|
||||
uploadObsltPplExcel,
|
||||
} from "../api/obslt-ppl-api";
|
||||
import { formatDate } from "../../common/util";
|
||||
import { downloadObsltPplExcel, parseObsltPplExcel } from "../lib/obslt-ppl-excel";
|
||||
import { buildObsltPplRepresentativeSggOptions, normalizeObsltPplSigunName } from "../lib/obslt-ppl-region";
|
||||
import {
|
||||
downloadObsltPplExcel,
|
||||
parseObsltPplExcel,
|
||||
} from "../lib/obslt-ppl-excel";
|
||||
import {
|
||||
buildObsltPplRepresentativeSggOptions,
|
||||
normalizeObsltPplSigunName,
|
||||
} from "../lib/obslt-ppl-region";
|
||||
import type { ObsltPplBusiness, ObsltPplPage } from "../model/obslt-ppl-types";
|
||||
|
||||
import LoadingOverlay from "@/components/ui/LoadingBar";
|
||||
import useStore from "@/store/useStore";
|
||||
import { openWindowPopup } from "../../windowPopup/lib/openWindowPopup";
|
||||
import { WINDOW_POPUP_MESSAGE_TYPE } from "../../windowPopup/model/types";
|
||||
|
||||
const DEFAULT_LIST_SIZE = 10;
|
||||
const ACTION_BUTTON_CLASS =
|
||||
@@ -33,7 +47,12 @@ const ALL_REGION_OPTION = { text: "전체", val: "0" };
|
||||
type ObsltPplTableRow = ObsltPplBusiness & {
|
||||
rowNumber: number;
|
||||
};
|
||||
type ObsltPplSearch = { bizSe: string; ctpvNm: string; sigunNm: string; bizNm: string };
|
||||
type ObsltPplSearch = {
|
||||
bizSe: string;
|
||||
ctpvNm: string;
|
||||
sigunNm: string;
|
||||
bizNm: string;
|
||||
};
|
||||
|
||||
/** 조회조건·지역 선택 코드·페이지를 목록 복귀에 사용할 URL query로 만든다. */
|
||||
const createListQueryString = (
|
||||
@@ -102,13 +121,18 @@ export function ObsltPplListPage() {
|
||||
const searchParams = useSearchParams();
|
||||
const { ctpv, sgg, fetchCtpv, fetchSgg } = useStore();
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const initialSearch = useMemo<ObsltPplSearch>(() => ({
|
||||
bizSe: searchParams.get("bizSe") ?? "",
|
||||
ctpvNm: searchParams.get("ctpvNm") ?? "",
|
||||
sigunNm: searchParams.get("sigunNm") ?? "",
|
||||
bizNm: searchParams.get("bizNm") ?? "",
|
||||
}), [searchParams]);
|
||||
const [page, setPage] = useState(() => Math.max(Number(searchParams.get("page")) || 1, 1));
|
||||
const initialSearch = useMemo<ObsltPplSearch>(
|
||||
() => ({
|
||||
bizSe: searchParams.get("bizSe") ?? "",
|
||||
ctpvNm: searchParams.get("ctpvNm") ?? "",
|
||||
sigunNm: searchParams.get("sigunNm") ?? "",
|
||||
bizNm: searchParams.get("bizNm") ?? "",
|
||||
}),
|
||||
[searchParams],
|
||||
);
|
||||
const [page, setPage] = useState(() =>
|
||||
Math.max(Number(searchParams.get("page")) || 1, 1),
|
||||
);
|
||||
const [data, setData] = useState<ObsltPplPage>(EMPTY_PAGE);
|
||||
const [rows, setRows] = useState<ObsltPplTableRow[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -117,10 +141,15 @@ export function ObsltPplListPage() {
|
||||
// 선택박스의 코드와 API 검색에 사용하는 행정구역명을 함께 관리한다.
|
||||
const [ctpvCd, setCtpvCd] = useState(() => searchParams.get("ctpvCd") ?? "0");
|
||||
const [sggCd, setSggCd] = useState(() => searchParams.get("sggCd") ?? "0");
|
||||
const [appliedCtpvCd, setAppliedCtpvCd] = useState(() => searchParams.get("ctpvCd") ?? "0");
|
||||
const [appliedSggCd, setAppliedSggCd] = useState(() => searchParams.get("sggCd") ?? "0");
|
||||
const [appliedCtpvCd, setAppliedCtpvCd] = useState(
|
||||
() => searchParams.get("ctpvCd") ?? "0",
|
||||
);
|
||||
const [appliedSggCd, setAppliedSggCd] = useState(
|
||||
() => searchParams.get("sggCd") ?? "0",
|
||||
);
|
||||
const [search, setSearch] = useState<ObsltPplSearch>(initialSearch);
|
||||
const [appliedSearch, setAppliedSearch] = useState<ObsltPplSearch>(initialSearch);
|
||||
const [appliedSearch, setAppliedSearch] =
|
||||
useState<ObsltPplSearch>(initialSearch);
|
||||
|
||||
/** 현재 선택한 시도에 속한 시군구만 선택 후보로 제공한다. */
|
||||
const availableSgg = useMemo(() => {
|
||||
@@ -134,38 +163,81 @@ export function ObsltPplListPage() {
|
||||
}, [ctpv.length, fetchCtpv, fetchSgg, sgg.length]);
|
||||
|
||||
/** 확정 검색조건과 페이지를 서버 요청 파라미터로 변환해 목록을 갱신한다. */
|
||||
const load = useCallback(async (targetPage = page, targetSearch = appliedSearch) => {
|
||||
const params = new URLSearchParams({
|
||||
page: String(Math.max(targetPage - 1, 0)),
|
||||
size: String(DEFAULT_LIST_SIZE),
|
||||
sort: "obsltSwagePplBizSn,desc",
|
||||
});
|
||||
Object.entries(targetSearch).forEach(([key, value]) => {
|
||||
if (value.trim()) params.set(key, value.trim());
|
||||
});
|
||||
const load = useCallback(
|
||||
async (targetPage = page, targetSearch = appliedSearch) => {
|
||||
const params = new URLSearchParams({
|
||||
page: String(Math.max(targetPage - 1, 0)),
|
||||
size: String(DEFAULT_LIST_SIZE),
|
||||
sort: "obsltSwagePplBizSn,desc",
|
||||
});
|
||||
Object.entries(targetSearch).forEach(([key, value]) => {
|
||||
if (value.trim()) params.set(key, value.trim());
|
||||
});
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await getObsltPplBusinesses(params);
|
||||
setData(result);
|
||||
setRows(result.content.map((row, index) => ({
|
||||
...formatBusinessForDisplay(row),
|
||||
rowNumber: result.totalElements - ((targetPage - 1) * DEFAULT_LIST_SIZE + index),
|
||||
})));
|
||||
} catch (error) {
|
||||
setNotice(error instanceof Error ? error.message : "목록을 조회하지 못했습니다.");
|
||||
setData(EMPTY_PAGE);
|
||||
setRows([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
setResetPageNo(false);
|
||||
}
|
||||
}, [appliedSearch, page]);
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await getObsltPplBusinesses(params);
|
||||
setData(result);
|
||||
setRows(
|
||||
result.content.map((row, index) => ({
|
||||
...formatBusinessForDisplay(row),
|
||||
rowNumber:
|
||||
result.totalElements -
|
||||
((targetPage - 1) * DEFAULT_LIST_SIZE + index),
|
||||
})),
|
||||
);
|
||||
} catch (error) {
|
||||
setNotice(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: "목록을 조회하지 못했습니다.",
|
||||
);
|
||||
setData(EMPTY_PAGE);
|
||||
setRows([]);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
setResetPageNo(false);
|
||||
}
|
||||
},
|
||||
[appliedSearch, page],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [load]);
|
||||
|
||||
/** 팝업 등록 완료 메시지를 받으면 기존 적용 조회조건을 유지한 채 첫 페이지를 재조회한다. */
|
||||
useEffect(() => {
|
||||
const receivePopupMessage = (event: MessageEvent) => {
|
||||
if (event.origin !== window.location.origin) return;
|
||||
if (event.data?.type !== WINDOW_POPUP_MESSAGE_TYPE.CFMTN_BGT_REGISTERED)
|
||||
return;
|
||||
const inserted = Number(event.data?.payload?.insertedCount ?? 0);
|
||||
const skipped = Number(event.data?.payload?.skippedCount ?? 0);
|
||||
setNotice(
|
||||
`최종확정예산사업 ${inserted.toLocaleString()}건을 등록했습니다.${skipped ? ` 이미 등록된 ${skipped.toLocaleString()}건은 제외했습니다.` : ""}`,
|
||||
);
|
||||
setPage(1);
|
||||
setResetPageNo(true);
|
||||
void load(1, appliedSearch);
|
||||
};
|
||||
window.addEventListener("message", receivePopupMessage);
|
||||
return () => window.removeEventListener("message", receivePopupMessage);
|
||||
}, [appliedSearch, load]);
|
||||
|
||||
/** 부모 화면의 필수 사업구분을 전달하여 최종확정예산사업 선택 팝업을 연다. */
|
||||
const handleOpenCfmtnBgt = () => {
|
||||
if (search.bizSe !== "정밀조사" && search.bizSe !== "정비사업") {
|
||||
setNotice("사업구분에서 정밀조사 또는 정비사업을 먼저 선택해 주세요.");
|
||||
return;
|
||||
}
|
||||
const popup = openWindowPopup("cfmtnBgt", { bizSe: search.bizSe });
|
||||
if (!popup)
|
||||
setNotice(
|
||||
"팝업이 차단되었습니다. 브라우저의 팝업 허용 설정을 확인해 주세요.",
|
||||
);
|
||||
};
|
||||
|
||||
/** 선택한 xlsx를 브라우저에서 검증·파싱한 뒤 JSON으로 교체 업로드한다. */
|
||||
const handleUpload = async (file?: File) => {
|
||||
if (!file) return;
|
||||
@@ -185,7 +257,9 @@ export function ObsltPplListPage() {
|
||||
setPage(1);
|
||||
await load(1, appliedSearch);
|
||||
} catch (error) {
|
||||
setNotice(error instanceof Error ? error.message : "업로드하지 못했습니다.");
|
||||
setNotice(
|
||||
error instanceof Error ? error.message : "업로드하지 못했습니다.",
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
if (fileInputRef.current) fileInputRef.current.value = "";
|
||||
@@ -203,7 +277,9 @@ export function ObsltPplListPage() {
|
||||
const exportRows = await getAllObsltPplBusinesses(params);
|
||||
downloadObsltPplExcel(exportRows);
|
||||
} catch (error) {
|
||||
setNotice(error instanceof Error ? error.message : "엑셀을 내려받지 못했습니다.");
|
||||
setNotice(
|
||||
error instanceof Error ? error.message : "엑셀을 내려받지 못했습니다.",
|
||||
);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -218,7 +294,9 @@ export function ObsltPplListPage() {
|
||||
setAppliedSggCd(sggCd);
|
||||
setResetPageNo(true);
|
||||
const queryString = createListQueryString(1, nextSearch, ctpvCd, sggCd);
|
||||
router.replace(`/oper/obsltPplBiz${queryString ? `?${queryString}` : ""}`, { scroll: false });
|
||||
router.replace(`/oper/obsltPplBiz${queryString ? `?${queryString}` : ""}`, {
|
||||
scroll: false,
|
||||
});
|
||||
if (page === 1) {
|
||||
await load(1, nextSearch);
|
||||
return;
|
||||
@@ -241,7 +319,12 @@ export function ObsltPplListPage() {
|
||||
selectClass="w-[120px] rounded-lg bg-white"
|
||||
selectArray={BIZ_SE_OPTIONS}
|
||||
value={search.bizSe}
|
||||
onSelectValue={(value) => setSearch((current) => ({ ...current, bizSe: String(value) }))}
|
||||
onSelectValue={(value) =>
|
||||
setSearch((current) => ({
|
||||
...current,
|
||||
bizSe: String(value),
|
||||
}))
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center">
|
||||
@@ -258,7 +341,9 @@ export function ObsltPplListPage() {
|
||||
setSggCd("0");
|
||||
setSearch((current) => ({
|
||||
...current,
|
||||
ctpvNm: ctpv.find((option) => String(option.val) === nextCtpvCd)?.text ?? "",
|
||||
ctpvNm:
|
||||
ctpv.find((option) => String(option.val) === nextCtpvCd)
|
||||
?.text ?? "",
|
||||
sigunNm: "",
|
||||
}));
|
||||
}}
|
||||
@@ -275,7 +360,9 @@ export function ObsltPplListPage() {
|
||||
onSelectValue={(value) => {
|
||||
const nextSggCd = String(value);
|
||||
setSggCd(nextSggCd);
|
||||
const selectedOption = availableSgg.find((option) => String(option.val) === nextSggCd);
|
||||
const selectedOption = availableSgg.find(
|
||||
(option) => String(option.val) === nextSggCd,
|
||||
);
|
||||
setSearch((current) => ({
|
||||
...current,
|
||||
sigunNm: selectedOption?.text ?? "",
|
||||
@@ -288,7 +375,12 @@ export function ObsltPplListPage() {
|
||||
<Input
|
||||
className="w-[220px] !text-2xl"
|
||||
value={search.bizNm}
|
||||
onChange={(event) => setSearch((current) => ({ ...current, bizNm: event.target.value }))}
|
||||
onChange={(event) =>
|
||||
setSearch((current) => ({
|
||||
...current,
|
||||
bizNm: event.target.value,
|
||||
}))
|
||||
}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
@@ -302,19 +394,37 @@ export function ObsltPplListPage() {
|
||||
</SearchFormLeft>
|
||||
<SearchFormRight className="ml-auto flex shrink-0 items-center justify-end px-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<Button className={ACTION_BUTTON_CLASS} size="sm" onClick={() => void handleSearch()}>
|
||||
<Button
|
||||
className={ACTION_BUTTON_CLASS}
|
||||
size="sm"
|
||||
onClick={() => void handleSearch()}
|
||||
>
|
||||
조회
|
||||
</Button>
|
||||
<Button
|
||||
className={ACTION_BUTTON_CLASS}
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
const queryString = createListQueryString(page, appliedSearch, appliedCtpvCd, appliedSggCd);
|
||||
router.push(`/oper/obsltPplBiz/register${queryString ? `?${queryString}` : ""}`);
|
||||
const queryString = createListQueryString(
|
||||
page,
|
||||
appliedSearch,
|
||||
appliedCtpvCd,
|
||||
appliedSggCd,
|
||||
);
|
||||
router.push(
|
||||
`/oper/obsltPplBiz/register${queryString ? `?${queryString}` : ""}`,
|
||||
);
|
||||
}}
|
||||
>
|
||||
등록
|
||||
</Button>
|
||||
<Button
|
||||
className={ACTION_BUTTON_CLASS}
|
||||
size="sm"
|
||||
onClick={handleOpenCfmtnBgt}
|
||||
>
|
||||
최종확정예산사업
|
||||
</Button>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
@@ -322,7 +432,11 @@ export function ObsltPplListPage() {
|
||||
className="hidden"
|
||||
onChange={(event) => void handleUpload(event.target.files?.[0])}
|
||||
/>
|
||||
<Button className={ACTION_BUTTON_CLASS} size="sm" onClick={() => fileInputRef.current?.click()}>
|
||||
<Button
|
||||
className={ACTION_BUTTON_CLASS}
|
||||
size="sm"
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
>
|
||||
업로드
|
||||
</Button>
|
||||
<Button
|
||||
@@ -337,7 +451,10 @@ export function ObsltPplListPage() {
|
||||
</SearchDiv>
|
||||
|
||||
{notice && (
|
||||
<div role="status" className="mx-[1.2rem] mt-4 rounded border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-700">
|
||||
<div
|
||||
role="status"
|
||||
className="mx-[1.2rem] mt-4 rounded border border-blue-200 bg-blue-50 px-4 py-3 text-sm text-blue-700"
|
||||
>
|
||||
{notice}
|
||||
</div>
|
||||
)}
|
||||
@@ -347,7 +464,9 @@ export function ObsltPplListPage() {
|
||||
<div className="card-header flex items-center justify-between">
|
||||
<h3 className="text-2xl font-medium">
|
||||
노후하수관로 정밀조사 및 정비사업 현황{" "}
|
||||
<span className="text-base text-gray-500">({data.totalElements.toLocaleString("ko-KR")}건)</span>
|
||||
<span className="text-base text-gray-500">
|
||||
({data.totalElements.toLocaleString("ko-KR")}건)
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
<UiTable<ObsltPplTableRow>
|
||||
@@ -360,20 +479,39 @@ export function ObsltPplListPage() {
|
||||
widthFixed
|
||||
onPageChange={(nextPage) => {
|
||||
setPage(nextPage);
|
||||
const queryString = createListQueryString(nextPage, appliedSearch, appliedCtpvCd, appliedSggCd);
|
||||
router.replace(`/oper/obsltPplBiz${queryString ? `?${queryString}` : ""}`, { scroll: false });
|
||||
const queryString = createListQueryString(
|
||||
nextPage,
|
||||
appliedSearch,
|
||||
appliedCtpvCd,
|
||||
appliedSggCd,
|
||||
);
|
||||
router.replace(
|
||||
`/oper/obsltPplBiz${queryString ? `?${queryString}` : ""}`,
|
||||
{ scroll: false },
|
||||
);
|
||||
}}
|
||||
resetPageNo={resetPageNo}
|
||||
cellClick={(index) => {
|
||||
if (typeof index !== "number" || !rows[index]) return;
|
||||
const queryString = createListQueryString(page, appliedSearch, appliedCtpvCd, appliedSggCd);
|
||||
const queryString = createListQueryString(
|
||||
page,
|
||||
appliedSearch,
|
||||
appliedCtpvCd,
|
||||
appliedSggCd,
|
||||
);
|
||||
router.push(
|
||||
`/oper/obsltPplBiz/register/${rows[index].obsltSwagePplBizSn}${queryString ? `?${queryString}` : ""}`,
|
||||
);
|
||||
}}
|
||||
renderCell={(row, headId) => {
|
||||
if (!DATE_FIELD_SET.has(headId as keyof ObsltPplBusiness)) return undefined;
|
||||
return formatDate(row[headId as keyof ObsltPplTableRow] as string | null | undefined);
|
||||
if (!DATE_FIELD_SET.has(headId as keyof ObsltPplBusiness))
|
||||
return undefined;
|
||||
return formatDate(
|
||||
row[headId as keyof ObsltPplTableRow] as
|
||||
| string
|
||||
| null
|
||||
| undefined,
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import type { WindowPopupDefinition } from "./types";
|
||||
|
||||
export const windowPopupDefinitions = {
|
||||
cfmtnBgt: {
|
||||
key: "cfmtnBgt",
|
||||
title: "최종확정예산사업",
|
||||
width: 1500,
|
||||
height: 900,
|
||||
requiredParams: ["bizSe"],
|
||||
},
|
||||
exmnBusinessRegister: {
|
||||
key: "exmnBusinessRegister",
|
||||
title: "사업정보 등록",
|
||||
|
||||
@@ -31,6 +31,7 @@ export type OpenWindowPopupParams = Record<
|
||||
>;
|
||||
|
||||
export const WINDOW_POPUP_MESSAGE_TYPE = {
|
||||
CFMTN_BGT_REGISTERED: "sn:popup:cfmtnBgtRegistered", // 최종확정예산사업
|
||||
EXMN_BUSINESS_CREATED: "sn:popup:exmnBusinessCreated",
|
||||
EXMN_BUSINESS_UPDATED: "sn:popup:exmnBusinessUpdated",
|
||||
EXMN_RESULT_COMMITTED: "sn:popup:exmnResultCommitted",
|
||||
@@ -42,8 +43,10 @@ export const WINDOW_POPUP_MESSAGE_TYPE = {
|
||||
GIS_EDIT_SESSION_SYNC: "sn:popup:gisEditSessionSync",
|
||||
GIS_EDIT_SESSION_SHOW_INLINE: "sn:popup:gisEditSessionShowInline",
|
||||
GIS_EDIT_SESSION_FOCUS_CHANGE: "sn:popup:gisEditSessionFocusChange",
|
||||
GIS_EDIT_SESSION_REMOVE_FOCUSED_CHANGE: "sn:popup:gisEditSessionRemoveFocusedChange",
|
||||
GIS_EDIT_SESSION_REMOVE_LAST_CHANGE: "sn:popup:gisEditSessionRemoveLastChange",
|
||||
GIS_EDIT_SESSION_REMOVE_FOCUSED_CHANGE:
|
||||
"sn:popup:gisEditSessionRemoveFocusedChange",
|
||||
GIS_EDIT_SESSION_REMOVE_LAST_CHANGE:
|
||||
"sn:popup:gisEditSessionRemoveLastChange",
|
||||
GIS_EDIT_SESSION_CLEAR_CHANGES: "sn:popup:gisEditSessionClearChanges",
|
||||
GIS_UPLOAD_COMPLETED: "sn:popup:gisUploadCompleted",
|
||||
WATER_RISK_READY: "sn:popup:waterRiskReady",
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { windowPopupDefinitions, type WindowPopupKey } from "./model/popupDefinitions";
|
||||
import {
|
||||
windowPopupDefinitions,
|
||||
type WindowPopupKey,
|
||||
} from "./model/popupDefinitions";
|
||||
import type { WindowPopupRegistryItem } from "./model/types";
|
||||
import AgedPipePopupContent from "./ui/AgedPipePopupContent";
|
||||
import AgedPipeStatusByCtpvPopupContent from "./ui/AgedPipeStatusByCtpvPopupContent";
|
||||
@@ -27,18 +30,27 @@ import GisManagementPopupContent from "./ui/GisManagementPopupContent";
|
||||
import PipeAnalysisPopupContent from "./ui/PipeAnalysisPopupContent";
|
||||
import PipeAnalysisDetailPopupContent from "./ui/PipeAnalysisDetailPopupContent";
|
||||
import WaterRiskPopupContent from "./ui/WaterRiskPopupContent";
|
||||
import CfmtnBgtPopupContent from "../cfmtnBgt/ui/CfmtnBgtPopupContent";
|
||||
|
||||
const FloodPredictionPlaceholderPopupContent = (_props: WindowPopupContentProps) => (
|
||||
const FloodPredictionPlaceholderPopupContent = (
|
||||
_props: WindowPopupContentProps,
|
||||
) => (
|
||||
<FeaturePlaceholderPopupContent
|
||||
title={windowPopupDefinitions.floodPredictionMapPopup.title}
|
||||
/>
|
||||
);
|
||||
|
||||
const GisEditPopupContent = (_props: WindowPopupContentProps) => (
|
||||
<FeaturePlaceholderPopupContent title={windowPopupDefinitions.gisEditPopup.title} />
|
||||
<FeaturePlaceholderPopupContent
|
||||
title={windowPopupDefinitions.gisEditPopup.title}
|
||||
/>
|
||||
);
|
||||
|
||||
export const windowPopupRegistry = {
|
||||
cfmtnBgt: {
|
||||
...windowPopupDefinitions.cfmtnBgt,
|
||||
component: CfmtnBgtPopupContent,
|
||||
},
|
||||
exmnBusinessRegister: {
|
||||
...windowPopupDefinitions.exmnBusinessRegister,
|
||||
component: ExmnBusinessRegisterPopupContent,
|
||||
|
||||
Reference in New Issue
Block a user