Skip to content

Commit 561cd0b

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent 371386f commit 561cd0b

7 files changed

Lines changed: 1896 additions & 34 deletions

File tree

src/components/cases/CasesExplorer.tsx

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,8 @@ import type { Dictionary } from '@/i18n';
88
import { caseUrl } from '@/lib/routes';
99
import { GlassCard } from '@/components/GlassCard';
1010
import { cn } from '@/lib/cn';
11-
import {
12-
ArrowRightIcon,
13-
FinanceIcon,
14-
OpsIcon,
15-
SupportIcon,
16-
HRIcon,
17-
LogisticsIcon,
18-
ProcurementIcon,
19-
MarketingIcon,
20-
LegalIcon,
21-
DataIcon,
22-
AdminIcon,
23-
ProductIcon,
24-
WindowsIcon,
25-
} from '@/components/icons';
11+
import { ArrowRightIcon, WindowsIcon } from '@/components/icons';
12+
import { deptIcons } from '@/components/cases/deptIcons';
2613
import { CopyButton } from '@/components/CopyButton';
2714

2815
type Props = {
@@ -46,20 +33,6 @@ const departmentOptions: Array<Department | 'all'> = [
4633
'product',
4734
];
4835

49-
export const deptIcons: Record<Department, React.ReactNode> = {
50-
finance: <FinanceIcon size={24} />,
51-
operations: <OpsIcon size={24} />,
52-
'customer-service': <SupportIcon size={24} />,
53-
hr: <HRIcon size={24} />,
54-
logistics: <LogisticsIcon size={24} />,
55-
procurement: <ProcurementIcon size={24} />,
56-
marketing: <MarketingIcon size={24} />,
57-
legal: <LegalIcon size={24} />,
58-
data: <DataIcon size={24} />,
59-
admin: <AdminIcon size={24} />,
60-
product: <ProductIcon size={24} />,
61-
};
62-
6336
export function CasesExplorer({ cases, locale, dict }: Props) {
6437
const [filter, setFilter] = useState<Department | 'all'>('all');
6538
const [query, setQuery] = useState('');

src/components/cases/deptIcons.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { ReactNode } from 'react';
2+
import type { Department } from '@/data/cases';
3+
import {
4+
FinanceIcon,
5+
OpsIcon,
6+
SupportIcon,
7+
HRIcon,
8+
LogisticsIcon,
9+
ProcurementIcon,
10+
MarketingIcon,
11+
LegalIcon,
12+
DataIcon,
13+
AdminIcon,
14+
ProductIcon,
15+
} from '@/components/icons';
16+
17+
// Server-safe map: lives in a non-'use client' module so RSC can render the
18+
// JSX elements directly. Importing this from a client component is fine.
19+
export const deptIcons: Record<Department, ReactNode> = {
20+
finance: <FinanceIcon size={24} />,
21+
operations: <OpsIcon size={24} />,
22+
'customer-service': <SupportIcon size={24} />,
23+
hr: <HRIcon size={24} />,
24+
logistics: <LogisticsIcon size={24} />,
25+
procurement: <ProcurementIcon size={24} />,
26+
marketing: <MarketingIcon size={24} />,
27+
legal: <LegalIcon size={24} />,
28+
data: <DataIcon size={24} />,
29+
admin: <AdminIcon size={24} />,
30+
product: <ProductIcon size={24} />,
31+
};

src/components/home/HomeSections.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
LightBulbIcon,
1919
} from '@/components/icons';
2020
import { caseBundles } from '@/data/cases';
21-
import { deptIcons } from '@/components/cases/CasesExplorer';
21+
import { deptIcons } from '@/components/cases/deptIcons';
2222

2323
type Props = { locale: Locale; dict: Dictionary };
2424

0 commit comments

Comments
 (0)