From d6d3bbc55a557acde7d1f07c3bd4813e367d4e86 Mon Sep 17 00:00:00 2001 From: 0-Zz-ang Date: Thu, 25 Sep 2025 15:57:18 +0900 Subject: (박서영)동의관련 언어설정 추가 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/polices/policy-page-client.tsx | 281 ++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 components/polices/policy-page-client.tsx (limited to 'components/polices/policy-page-client.tsx') diff --git a/components/polices/policy-page-client.tsx b/components/polices/policy-page-client.tsx new file mode 100644 index 00000000..ccc87c31 --- /dev/null +++ b/components/polices/policy-page-client.tsx @@ -0,0 +1,281 @@ +'use client' + +import { useState } from 'react' +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' +import { FileText, Shield, Clock, Calendar, User } from 'lucide-react' +import { PolicyManagementClient } from '@/components/polices/policy-management-client' + +interface Policy { + id: number + policyType: string + locale: string + version: string + content: string + effectiveDate: string + isCurrent: boolean + createdAt: string +} + +interface PolicyPageClientProps { + data: { + currentPolicies: { + ko: Record + en: Record + } + allPolicies: { + ko: { + privacy_policy: Policy[] + terms_of_service: Policy[] + } + en: { + privacy_policy: Policy[] + terms_of_service: Policy[] + } + } + stats: { + totalVersions: number + koVersions: { + privacy: number + terms: number + } + enVersions: { + privacy: number + terms: number + } + lastUpdate: string | null + } + } +} + +// 선택된 locale의 가장 최근 업데이트 날짜를 가져오는 함수 +function getLastUpdateForLocale(data: PolicyPageClientProps['data'], locale: 'ko' | 'en'): string | null { + const allPolicies = [ + ...(data.allPolicies[locale]?.privacy_policy || []), + ...(data.allPolicies[locale]?.terms_of_service || []) + ] + + if (allPolicies.length === 0) return null + + // 가장 최근 createdAt 날짜 찾기 + const sortedPolicies = allPolicies.sort((a, b) => + new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime() + ) + + return sortedPolicies[0]?.createdAt || null +} + +export function PolicyPageClient({ data }: PolicyPageClientProps) { + const [selectedLocale, setSelectedLocale] = useState<'ko' | 'en'>('ko') + + // 선택된 locale에 맞는 데이터 필터링 + const filteredData = { + currentPolicies: { + privacy_policy: data.currentPolicies[selectedLocale]?.privacy_policy || null, + terms_of_service: data.currentPolicies[selectedLocale]?.terms_of_service || null + }, + allPolicies: { + privacy_policy: data.allPolicies[selectedLocale]?.privacy_policy || [], + terms_of_service: data.allPolicies[selectedLocale]?.terms_of_service || [] + }, + stats: { + totalVersions: data.stats[`${selectedLocale}Versions`].privacy + data.stats[`${selectedLocale}Versions`].terms, + privacyVersions: data.stats[`${selectedLocale}Versions`].privacy, + termsVersions: data.stats[`${selectedLocale}Versions`].terms, + lastUpdate: getLastUpdateForLocale(data, selectedLocale) + } + } + + return ( +
+ {/* 헤더 */} +
+
+

정책 관리

+

+ 개인정보 처리방침과 이용약관을 버전별로 관리합니다 +

+
+ + {/* 전역 locale 토글 */} +
+
+ + +
+
+
+ + {/* 통계 카드들 */} +
+ + + 총 버전 수 + + + +
{filteredData.stats.totalVersions}
+

+ 전체 정책 버전 +

+
+
+ + + + 개인정보 정책 + + + +
{filteredData.stats.privacyVersions}
+

+ 버전 수 +

+
+
+ + + + 이용약관 + + + +
{filteredData.stats.termsVersions}
+

+ 버전 수 +

+
+
+ + + + 최근 업데이트 + + + +
+ {filteredData.stats.lastUpdate + ? new Date(filteredData.stats.lastUpdate).toLocaleDateString('ko-KR').split('.').slice(1, 3).join('.') + : 'N/A' + } +
+

+ 마지막 정책 변경 +

+
+
+
+ + {/* 현재 활성 정책들 */} +
+ + + + + 개인정보 처리방침 + + + {filteredData.currentPolicies.privacy_policy ? + `현재 활성 정책 • 시행일: ${new Date(filteredData.currentPolicies.privacy_policy.effectiveDate).toLocaleDateString('ko-KR')}` : + `아직 등록된 ${selectedLocale === 'ko' ? '한국어' : '영어'} 개인정보 정책이 없습니다` + } + + + +
+
+ 정책 내용 미리보기: +
+
+
+ {filteredData.currentPolicies.privacy_policy ? + filteredData.currentPolicies.privacy_policy.content?.replace(/#{1,6}\s+/g, '').replace(/\*\*(.*?)\*\*/g, '$1').substring(0, 200) + '...' : + `아직 등록된 ${selectedLocale === 'ko' ? '한국어' : '영어'} 개인정보 정책이 없습니다` + } +
+
+ + {/* 메타 정보 */} +
+
+ + 생성: {filteredData.currentPolicies.privacy_policy?.createdAt ? new Date(filteredData.currentPolicies.privacy_policy.createdAt).toLocaleDateString('ko-KR') : 'N/A'} +
+
+ + 관리자 +
+
+
+
+
+ + + + + + 이용약관 + + + {filteredData.currentPolicies.terms_of_service ? + `현재 활성 정책 • 시행일: ${new Date(filteredData.currentPolicies.terms_of_service.effectiveDate).toLocaleDateString('ko-KR')}` : + `아직 등록된 ${selectedLocale === 'ko' ? '한국어' : '영어'} 이용약관이 없습니다` + } + + + +
+
+ 정책 내용 미리보기: +
+
+
+ {filteredData.currentPolicies.terms_of_service ? + filteredData.currentPolicies.terms_of_service.content?.replace(/#{1,6}\s+/g, '').replace(/\*\*(.*?)\*\*/g, '$1').substring(0, 200) + '...' : + `아직 등록된 ${selectedLocale === 'ko' ? '한국어' : '영어'} 이용약관이 없습니다` + } +
+
+ + {/* 메타 정보 */} +
+
+ + 생성: {filteredData.currentPolicies.terms_of_service?.createdAt ? new Date(filteredData.currentPolicies.terms_of_service.createdAt).toLocaleDateString('ko-KR') : 'N/A'} +
+
+ + 관리자 +
+
+
+
+
+
+ + {/* 정책 편집 부분 - 선택된 locale의 데이터만 표시 */} + +
+ ) +} -- cgit v1.2.3