summaryrefslogtreecommitdiff
path: root/lib/risk-management
diff options
context:
space:
mode:
authorjoonhoekim <26rote@gmail.com>2025-08-18 07:04:44 +0000
committerjoonhoekim <26rote@gmail.com>2025-08-18 07:04:44 +0000
commit13bc512bf26618d5c040fd9b19cc0afd7af7c55b (patch)
tree093af881e71f8c73b2a35c3f3a0e89658293c26c /lib/risk-management
parent14e81ffb5ebe0941d36a3be44e29990a18026a99 (diff)
(고건) 리스크 관리 테이블 내 등급 정보 추가
Diffstat (limited to 'lib/risk-management')
-rw-r--r--lib/risk-management/table/risks-columns.tsx421
-rw-r--r--lib/risk-management/table/risks-table.tsx13
2 files changed, 421 insertions, 13 deletions
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<SetStateAction<DataTableRowAction<RisksView> | null>>,
+ setRowAction: Dispatch<SetStateAction<DataTableRowAction<RisksView> | null>>;
+ router: AppRouterInstance;
+ paramsLanguage: string;
};
// ----------------------------------------------------------------------------------------------------
/* FUNCTION FOR GETTING COLUMNS SETTING */
-function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<RisksView>[] {
+function getColumns(props: GetColumnsProps): ColumnDef<RisksView>[] {
+ const { setRowAction, router, paramsLanguage } = props;
// [1] SELECT COLUMN - CHECKBOX
const selectColumn: ColumnDef<RisksView> = {
@@ -53,7 +63,6 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<RisksView>[] {
),
enableSorting: false,
enableHiding: false,
- size: 40,
};
// [2] SOURCE COLUMNS
@@ -173,7 +182,7 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<RisksView>[] {
<DataTableColumnHeaderSimple column={column} title="상세 내용" />
),
cell: ({ row }) => {
- const value = row.getValue<string>('content') ?? '-';
+ const value = row.getValue<string>('content');
return (
<div className="font-regular max-w-[150px] truncate" title={value}>
{value}
@@ -187,7 +196,6 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<RisksView>[] {
group: 'Risk Information',
type: 'text',
},
- size: 100,
},
{
accessorKey: 'occuredAt',
@@ -212,7 +220,379 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<RisksView>[] {
},
];
- // [3] INPUT COLUMNS
+ // [3] TOTAL RATING COLUMNS
+ const ratingTotalColumns: ColumnDef<RisksView>[] = [
+ {
+ accessorKey: 'prevRatingTotal',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="이전" />
+ ),
+ cell: ({ row }) => {
+ const value = row.getValue<string>('prevRatingTotal');
+ return (
+ <div className="font-regular">
+ {value}
+ </div>
+ );
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Previous',
+ group: 'Total Rating',
+ type: 'text',
+ },
+ },
+ {
+ accessorKey: 'curRatingTotal',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="현재" />
+ ),
+ cell: ({ row }) => {
+ const value = row.getValue<string>('curRatingTotal');
+ return (
+ <div className="font-regular">
+ {value}
+ </div>
+ );
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Current',
+ group: 'Total Rating',
+ type: 'text',
+ },
+ },
+ {
+ accessorKey: 'changeRatingTotal',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="변동" />
+ ),
+ cell: ({ row }) => {
+ const prevValue = row.getValue<string>('prevRatingTotal');
+ const curValue = row.getValue<string>('curRatingTotal');
+
+ if (prevValue === '-' || curValue === '-' || !prevValue || !curValue) {
+ return (
+ <div className="font-regular">
+ -
+ </div>
+ );
+ }
+ 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 (
+ <div className="font-regular">
+ -
+ </div>
+ );
+ } else if (prevRating.value > curRating.value) {
+ return (
+ <div className="font-regular text-red-500">
+ ▲
+ </div>
+ );
+ } else {
+ return (
+ <div className="font-regular text-blue-500">
+ ▼
+ </div>
+ );
+ }
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Change',
+ group: 'Total Rating',
+ type: 'text',
+ },
+ },
+ ];
+
+ // [4] CREDIT RATING COLUMNS
+ const ratingCreditColumns: ColumnDef<RisksView>[] = [
+ {
+ accessorKey: 'prevRatingCredit',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="이전" />
+ ),
+ cell: ({ row }) => {
+ const value = row.getValue<string>('prevRatingCredit');
+ return (
+ <div className="font-regular">
+ {value}
+ </div>
+ );
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Previous',
+ group: 'Credit Rating',
+ type: 'text',
+ },
+ },
+ {
+ accessorKey: 'curRatingCredit',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="현재" />
+ ),
+ cell: ({ row }) => {
+ const value = row.getValue<string>('curRatingCredit');
+ return (
+ <div className="font-regular">
+ {value}
+ </div>
+ );
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Current',
+ group: 'Credit Rating',
+ type: 'text',
+ },
+ },
+ {
+ accessorKey: 'changeRatingCredit',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="변동" />
+ ),
+ cell: ({ row }) => {
+ const prevValue = row.getValue<string>('prevRatingCredit');
+ const curValue = row.getValue<string>('curRatingCredit');
+
+ if (prevValue === '-' || curValue === '-' || !prevValue || !curValue) {
+ return (
+ <div className="font-regular">
+ -
+ </div>
+ );
+ }
+ 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 (
+ <div className="font-regular">
+ -
+ </div>
+ );
+ } else if (prevRating.value > curRating.value) {
+ return (
+ <div className="font-regular text-red-500">
+ ▲
+ </div>
+ );
+ } else {
+ return (
+ <div className="font-regular text-blue-500">
+ ▼
+ </div>
+ );
+ }
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Change',
+ group: 'Credit Rating',
+ type: 'text',
+ },
+ },
+ ];
+
+ // [5] CASHFLOW RATING COLUMNS
+ const ratingCashflowColumns: ColumnDef<RisksView>[] = [
+ {
+ accessorKey: 'prevRatingCashflow',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="이전" />
+ ),
+ cell: ({ row }) => {
+ const value = row.getValue<string>('prevRatingCashflow');
+ return (
+ <div className="font-regular">
+ {value}
+ </div>
+ );
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Previous',
+ group: 'Cashflow Rating',
+ type: 'text',
+ },
+ },
+ {
+ accessorKey: 'curRatingCashflow',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="현재" />
+ ),
+ cell: ({ row }) => {
+ const value = row.getValue<string>('curRatingCashflow');
+ return (
+ <div className="font-regular">
+ {value}
+ </div>
+ );
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Current',
+ group: 'Cashflow Rating',
+ type: 'text',
+ },
+ },
+ {
+ accessorKey: 'changeRatingCashflow',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="변동" />
+ ),
+ cell: ({ row }) => {
+ const prevValue = row.getValue<string>('prevRatingCashflow');
+ const curValue = row.getValue<string>('curRatingCashflow');
+
+ if (prevValue === '-' || curValue === '-' || !prevValue || !curValue) {
+ return (
+ <div className="font-regular">
+ -
+ </div>
+ );
+ }
+ 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 (
+ <div className="font-regular">
+ -
+ </div>
+ );
+ } else if (prevRating.value > curRating.value) {
+ return (
+ <div className="font-regular text-red-500">
+ ▲
+ </div>
+ );
+ } else {
+ return (
+ <div className="font-regular text-blue-500">
+ ▼
+ </div>
+ );
+ }
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Change',
+ group: 'Cashflow Rating',
+ type: 'text',
+ },
+ },
+ ];
+
+ // [6] WATCH RATING COLUMNS
+ const ratingWatchColumns: ColumnDef<RisksView>[] = [
+ {
+ accessorKey: 'prevRatingWatch',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="이전" />
+ ),
+ cell: ({ row }) => {
+ const value = row.getValue<string>('prevRatingWatch');
+ return (
+ <div className="font-regular">
+ {value}
+ </div>
+ );
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Previous',
+ group: 'Watch Rating',
+ type: 'text',
+ },
+ },
+ {
+ accessorKey: 'curRatingWatch',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="현재" />
+ ),
+ cell: ({ row }) => {
+ const value = row.getValue<string>('curRatingWatch');
+ return (
+ <div className="font-regular">
+ {value}
+ </div>
+ );
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Current',
+ group: 'Watch Rating',
+ type: 'text',
+ },
+ },
+ {
+ accessorKey: 'changeRatingWatch',
+ header: ({ column }) => (
+ <DataTableColumnHeaderSimple column={column} title="변동" />
+ ),
+ cell: ({ row }) => {
+ const prevValue = row.getValue<string>('prevRatingWatch');
+ const curValue = row.getValue<string>('curRatingWatch');
+
+ if (prevValue === '-' || curValue === '-' || !prevValue || !curValue) {
+ return (
+ <div className="font-regular">
+ -
+ </div>
+ );
+ }
+ 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 (
+ <div className="font-regular">
+ -
+ </div>
+ );
+ } else if (prevRating.value > curRating.value) {
+ return (
+ <div className="font-regular text-red-500">
+ ▲
+ </div>
+ );
+ } else {
+ return (
+ <div className="font-regular text-blue-500">
+ ▼
+ </div>
+ );
+ }
+ },
+ enableSorting: true,
+ enableHiding: false,
+ meta: {
+ excelHeader: 'Change',
+ group: 'Watch Rating',
+ type: 'text',
+ },
+ },
+ ];
+
+ // [7] INPUT COLUMNS
const inputColumns: ColumnDef<RisksView>[] = [
{
accessorKey: 'eventStatus',
@@ -286,11 +666,10 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<RisksView>[] {
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<RisksView> = {
id: 'actions',
enableHiding: false,
@@ -315,8 +694,9 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<RisksView>[] {
리스크 관리
</DropdownMenuItem>
<DropdownMenuItem
- onSelect={() => {
- // 신용정보 관리화면으로 이동
+ 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<RisksView>[] {
</DropdownMenu>
)
},
- size: 80,
};
return [
@@ -338,6 +717,26 @@ function getColumns({ setRowAction }: GetColumnsProps): ColumnDef<RisksView>[] {
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: '리스크 관리',
columns: inputColumns,
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<DataTableRowAction<RisksView> | 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(),
};