sn: util.ts 추가 정리
This commit is contained in:
@@ -26,7 +26,7 @@ import {
|
||||
type PaginationState,
|
||||
} from "@tanstack/react-table";
|
||||
|
||||
import { formatDate } from "../../common/util";
|
||||
import { appendApiSearchParams, formatDate } from "@/shared/util/util";
|
||||
import {
|
||||
getAllCtyFldngPrvtnBusinesses,
|
||||
getCtyFldngPrvtnBusinesses,
|
||||
@@ -454,9 +454,7 @@ export function CtyFldngPrvtnBizListPage() {
|
||||
? `${nextSort.key},${nextSort.direction}`
|
||||
: "ctyFldngPrvtnBizSn,desc",
|
||||
});
|
||||
Object.entries(condition).forEach(([k, v]) => {
|
||||
if (v.trim()) query.set(k, v.trim());
|
||||
});
|
||||
appendApiSearchParams(query, condition);
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await getCtyFldngPrvtnBusinesses(query);
|
||||
@@ -529,9 +527,7 @@ export function CtyFldngPrvtnBizListPage() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const query = new URLSearchParams();
|
||||
Object.entries(applied).forEach(([k, v]) => {
|
||||
if (v.trim()) query.set(k, v.trim());
|
||||
});
|
||||
appendApiSearchParams(query, applied);
|
||||
await downloadCtyFldngPrvtnExcel(
|
||||
await getAllCtyFldngPrvtnBusinesses(
|
||||
query,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as XLSX from "xlsx";
|
||||
import XlsxPopulate from "xlsx-populate/browser/xlsx-populate";
|
||||
|
||||
import { formatDate } from "../../common/util";
|
||||
import { formatDate } from "@/shared/util/util";
|
||||
import type { ObsltPplBusiness, ObsltPplBusinessSaveRequest } from "../model/obslt-ppl-types";
|
||||
|
||||
type BusinessType = ObsltPplBusinessSaveRequest["bizSe"];
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
Textarea,
|
||||
} from "@common/components";
|
||||
|
||||
import { formatDate } from "../../common/util";
|
||||
import { formatDate } from "@/shared/util/util";
|
||||
import {
|
||||
createObsltPplBusiness,
|
||||
deleteObsltPplBusiness,
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
getObsltPplBusinesses,
|
||||
uploadObsltPplExcel,
|
||||
} from "../api/obslt-ppl-api";
|
||||
import { formatDate } from "../../common/util";
|
||||
import { appendApiSearchParams, formatDate } from "@/shared/util/util";
|
||||
import {
|
||||
downloadObsltPplExcel,
|
||||
parseObsltPplExcel,
|
||||
@@ -322,9 +322,7 @@ export function ObsltPplListPage() {
|
||||
? `${nextSort.key},${nextSort.direction}`
|
||||
: "obsltSwagePplBizSn,desc",
|
||||
});
|
||||
Object.entries(targetSearch).forEach(([key, value]) => {
|
||||
if (value.trim()) params.set(key, value.trim());
|
||||
});
|
||||
appendApiSearchParams(params, targetSearch);
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
@@ -423,9 +421,7 @@ export function ObsltPplListPage() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const params = new URLSearchParams();
|
||||
Object.entries(appliedSearch).forEach(([key, value]) => {
|
||||
if (value.trim()) params.set(key, value.trim());
|
||||
});
|
||||
appendApiSearchParams(params, appliedSearch);
|
||||
const exportRows = await getAllObsltPplBusinesses(
|
||||
params,
|
||||
sort ? `${sort.key},${sort.direction}` : undefined,
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
import moment from "moment";
|
||||
|
||||
/** 빈 값과 화면의 전체 선택값 `0`을 제외하고 API 검색 파라미터를 추가한다. */
|
||||
export const appendApiSearchParams = (
|
||||
params: URLSearchParams,
|
||||
search: Readonly<Record<string, string>>,
|
||||
) => {
|
||||
Object.entries(search).forEach(([key, value]) => {
|
||||
const normalized = value.trim();
|
||||
if (!normalized || normalized === "0") return;
|
||||
params.set(key, normalized);
|
||||
});
|
||||
};
|
||||
|
||||
/** 8자리 또는 구분자가 섞인 날짜 문자열을 YYYY-MM-DD 형식으로 정규화한다. */
|
||||
export const formatDate = (value?: string | null) => {
|
||||
if (!value) return "";
|
||||
Reference in New Issue
Block a user