From 13bc512bf26618d5c040fd9b19cc0afd7af7c55b Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Mon, 18 Aug 2025 07:04:44 +0000 Subject: (고건) 리스크 관리 테이블 내 등급 정보 추가 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/risk-management/table/risks-columns.tsx | 421 +++++++++++++++++++++++++++- lib/risk-management/table/risks-table.tsx | 13 +- 2 files changed, 421 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/risk-management/table/risks-columns.tsx b/lib/risk-management/table/risks-columns.tsx index fe98448a..cd1aca39 100644 --- a/lib/risk-management/table/risks-columns.tsx +++ b/lib/risk-management/table/risks-columns.tsx @@ -13,6 +13,13 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; +import { + RISK_RATING_CASHFLOW_LIST, + RISK_RATING_CREDIT_LIST, + RISK_RATING_TOTAL_LIST, + RISK_RATING_WATCH_LIST +} from '@/config/risksConfig'; +import { type AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime'; import { type ColumnDef } from '@tanstack/react-table'; import { type DataTableRowAction } from '@/types/table'; import { type RisksView } from '@/db/schema'; @@ -21,13 +28,16 @@ import { type RisksView } from '@/db/schema'; /* TYPES */ interface GetColumnsProps { - setRowAction: Dispatch | null>>, + setRowAction: Dispatch | null>>; + router: AppRouterInstance; + paramsLanguage: string; }; // ---------------------------------------------------------------------------------------------------- /* FUNCTION FOR GETTING COLUMNS SETTING */ -function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { +function getColumns(props: GetColumnsProps): ColumnDef[] { + const { setRowAction, router, paramsLanguage } = props; // [1] SELECT COLUMN - CHECKBOX const selectColumn: ColumnDef = { @@ -53,7 +63,6 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { ), enableSorting: false, enableHiding: false, - size: 40, }; // [2] SOURCE COLUMNS @@ -173,7 +182,7 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { ), cell: ({ row }) => { - const value = row.getValue('content') ?? '-'; + const value = row.getValue('content'); return (
{value} @@ -187,7 +196,6 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { group: 'Risk Information', type: 'text', }, - size: 100, }, { accessorKey: 'occuredAt', @@ -212,7 +220,379 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { }, ]; - // [3] INPUT COLUMNS + // [3] TOTAL RATING COLUMNS + const ratingTotalColumns: ColumnDef[] = [ + { + accessorKey: 'prevRatingTotal', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const value = row.getValue('prevRatingTotal'); + return ( +
+ {value} +
+ ); + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Previous', + group: 'Total Rating', + type: 'text', + }, + }, + { + accessorKey: 'curRatingTotal', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const value = row.getValue('curRatingTotal'); + return ( +
+ {value} +
+ ); + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Current', + group: 'Total Rating', + type: 'text', + }, + }, + { + accessorKey: 'changeRatingTotal', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const prevValue = row.getValue('prevRatingTotal'); + const curValue = row.getValue('curRatingTotal'); + + if (prevValue === '-' || curValue === '-' || !prevValue || !curValue) { + return ( +
+ - +
+ ); + } + const prevRating = RISK_RATING_TOTAL_LIST.find(rating => rating.label === prevValue); + const curRating = RISK_RATING_TOTAL_LIST.find(rating => rating.label === curValue); + + if (!prevRating || !curRating || prevRating === curRating) { + return ( +
+ - +
+ ); + } else if (prevRating.value > curRating.value) { + return ( +
+ ▲ +
+ ); + } else { + return ( +
+ ▼ +
+ ); + } + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Change', + group: 'Total Rating', + type: 'text', + }, + }, + ]; + + // [4] CREDIT RATING COLUMNS + const ratingCreditColumns: ColumnDef[] = [ + { + accessorKey: 'prevRatingCredit', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const value = row.getValue('prevRatingCredit'); + return ( +
+ {value} +
+ ); + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Previous', + group: 'Credit Rating', + type: 'text', + }, + }, + { + accessorKey: 'curRatingCredit', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const value = row.getValue('curRatingCredit'); + return ( +
+ {value} +
+ ); + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Current', + group: 'Credit Rating', + type: 'text', + }, + }, + { + accessorKey: 'changeRatingCredit', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const prevValue = row.getValue('prevRatingCredit'); + const curValue = row.getValue('curRatingCredit'); + + if (prevValue === '-' || curValue === '-' || !prevValue || !curValue) { + return ( +
+ - +
+ ); + } + const prevRating = RISK_RATING_CREDIT_LIST.find(rating => rating.label === prevValue); + const curRating = RISK_RATING_CREDIT_LIST.find(rating => rating.label === curValue); + + if (!prevRating || !curRating || prevRating === curRating) { + return ( +
+ - +
+ ); + } else if (prevRating.value > curRating.value) { + return ( +
+ ▲ +
+ ); + } else { + return ( +
+ ▼ +
+ ); + } + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Change', + group: 'Credit Rating', + type: 'text', + }, + }, + ]; + + // [5] CASHFLOW RATING COLUMNS + const ratingCashflowColumns: ColumnDef[] = [ + { + accessorKey: 'prevRatingCashflow', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const value = row.getValue('prevRatingCashflow'); + return ( +
+ {value} +
+ ); + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Previous', + group: 'Cashflow Rating', + type: 'text', + }, + }, + { + accessorKey: 'curRatingCashflow', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const value = row.getValue('curRatingCashflow'); + return ( +
+ {value} +
+ ); + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Current', + group: 'Cashflow Rating', + type: 'text', + }, + }, + { + accessorKey: 'changeRatingCashflow', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const prevValue = row.getValue('prevRatingCashflow'); + const curValue = row.getValue('curRatingCashflow'); + + if (prevValue === '-' || curValue === '-' || !prevValue || !curValue) { + return ( +
+ - +
+ ); + } + const prevRating = RISK_RATING_CASHFLOW_LIST.find(rating => rating.label === prevValue); + const curRating = RISK_RATING_CASHFLOW_LIST.find(rating => rating.label === curValue); + + if (!prevRating || !curRating || prevRating === curRating) { + return ( +
+ - +
+ ); + } else if (prevRating.value > curRating.value) { + return ( +
+ ▲ +
+ ); + } else { + return ( +
+ ▼ +
+ ); + } + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Change', + group: 'Cashflow Rating', + type: 'text', + }, + }, + ]; + + // [6] WATCH RATING COLUMNS + const ratingWatchColumns: ColumnDef[] = [ + { + accessorKey: 'prevRatingWatch', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const value = row.getValue('prevRatingWatch'); + return ( +
+ {value} +
+ ); + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Previous', + group: 'Watch Rating', + type: 'text', + }, + }, + { + accessorKey: 'curRatingWatch', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const value = row.getValue('curRatingWatch'); + return ( +
+ {value} +
+ ); + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Current', + group: 'Watch Rating', + type: 'text', + }, + }, + { + accessorKey: 'changeRatingWatch', + header: ({ column }) => ( + + ), + cell: ({ row }) => { + const prevValue = row.getValue('prevRatingWatch'); + const curValue = row.getValue('curRatingWatch'); + + if (prevValue === '-' || curValue === '-' || !prevValue || !curValue) { + return ( +
+ - +
+ ); + } + const prevRating = RISK_RATING_WATCH_LIST.find(rating => rating.label === prevValue); + const curRating = RISK_RATING_WATCH_LIST.find(rating => rating.label === curValue); + + if (!prevRating || !curRating || prevRating === curRating) { + return ( +
+ - +
+ ); + } else if (prevRating.value > curRating.value) { + return ( +
+ ▲ +
+ ); + } else { + return ( +
+ ▼ +
+ ); + } + }, + enableSorting: true, + enableHiding: false, + meta: { + excelHeader: 'Change', + group: 'Watch Rating', + type: 'text', + }, + }, + ]; + + // [7] INPUT COLUMNS const inputColumns: ColumnDef[] = [ { accessorKey: 'eventStatus', @@ -286,11 +666,10 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { group: 'Risk Management', type: 'text', }, - size: 300, }, ]; - // [4] ACTIONS COLUMN - DROPDOWN MENU WITH VIEW ACTION + // [8] ACTIONS COLUMN - DROPDOWN MENU WITH VIEW ACTION const actionsColumn: ColumnDef = { id: 'actions', enableHiding: false, @@ -315,8 +694,9 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { 리스크 관리 { - // 신용정보 관리화면으로 이동 + onClick={() => { + const vendorId = row.original.vendorId; + router.push(`/${paramsLanguage}/evcp/vendors/${vendorId}/info/credit`); }} className="cursor-pointer" > @@ -327,7 +707,6 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { ) }, - size: 80, }; return [ @@ -337,6 +716,26 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef[] { header: '리스크 정보', columns: sourceColumns, }, + { + id: 'ratingTotal', + header: '종합등급', + columns: ratingTotalColumns, + }, + { + id: 'ratingCredit', + header: '신용등급', + columns: ratingCreditColumns, + }, + { + id: 'ratingCashflow', + header: '현금흐름등급', + columns: ratingCashflowColumns, + }, + { + id: 'ratingWatch', + header: 'WATCH등급', + columns: ratingWatchColumns, + }, { id: 'riskInput', header: '리스크 관리', diff --git a/lib/risk-management/table/risks-table.tsx b/lib/risk-management/table/risks-table.tsx index d6317c26..2bd328f2 100644 --- a/lib/risk-management/table/risks-table.tsx +++ b/lib/risk-management/table/risks-table.tsx @@ -16,7 +16,7 @@ import { } from '@/types/table'; import { useDataTable } from '@/hooks/use-data-table'; import { use, useCallback, useMemo, useState } from 'react'; -import { useRouter } from 'next/navigation'; +import { useParams, useRouter } from 'next/navigation'; import { RISK_EVENT_TYPE_LIST, RISK_PROVIDER_LIST } from '@/config/risksConfig'; // ---------------------------------------------------------------------------------------------------- @@ -33,12 +33,13 @@ interface RisksTableProps { /* TABLE COMPONENT */ function RisksTable({ promises }: RisksTableProps) { const router = useRouter(); + const params = useParams(); const [rowAction, setRowAction] = useState | null>(null); const [isMailDialogOpen, setIsMailDialogOpen] = useState(false); const [promiseData] = use(promises); const tableData = promiseData; const columns = useMemo( - () => getColumns({ setRowAction }), + () => getColumns({ setRowAction, router, paramsLanguage: params?.lng as string ?? 'ko' }), [setRowAction], ); @@ -127,6 +128,14 @@ function RisksTable({ promises }: RisksTableProps) { managerId: 0, managerName: '', adminComment: '', + prevRatingTotal: '', + curRatingTotal: '', + prevRatingCredit: '', + curRatingCredit: '', + prevRatingCashflow: '', + curRatingCashflow: '', + prevRatingWatch: '', + curRatingWatch: '', occuredAt: new Date(), }; -- cgit v1.2.3