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 --- app/[lng]/evcp/(evcp)/consent/page.tsx | 231 ++++++--------------------------- 1 file changed, 41 insertions(+), 190 deletions(-) (limited to 'app') diff --git a/app/[lng]/evcp/(evcp)/consent/page.tsx b/app/[lng]/evcp/(evcp)/consent/page.tsx index 5e760b5e..3e06cb0f 100644 --- a/app/[lng]/evcp/(evcp)/consent/page.tsx +++ b/app/[lng]/evcp/(evcp)/consent/page.tsx @@ -1,14 +1,9 @@ // app/admin/policies/page.tsx (서버 컴포넌트) -import { Suspense } from 'react' import { Metadata } from 'next' import { eq, desc } from 'drizzle-orm' import db from '@/db/db' import { policyVersions } from '@/db/schema' -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' -import { Badge } from '@/components/ui/badge' -import { Separator } from '@/components/ui/separator' -import { FileText, Shield, Calendar, User, Clock } from 'lucide-react' -import { PolicyManagementClient } from '@/components/polices/policy-management-client' +import { PolicyPageClient } from '@/components/polices/policy-page-client' export const metadata: Metadata = { title: '정책 관리 | eVCP Admin', @@ -18,12 +13,12 @@ export const metadata: Metadata = { // 정책 데이터 조회 함수 async function getPoliciesData() { try { - // 현재 활성 정책들 + // 현재 활성 정책들 (모든 locale) const currentPolicies = await db .select() .from(policyVersions) .where(eq(policyVersions.isCurrent, true)) - .orderBy(policyVersions.policyType) + .orderBy(policyVersions.policyType, policyVersions.locale) // 전체 정책 히스토리 const allPolicies = await db @@ -31,208 +26,64 @@ async function getPoliciesData() { .from(policyVersions) .orderBy(desc(policyVersions.createdAt)) - // 정책 타입별로 그룹화 - const policiesByType = { - privacy_policy: allPolicies.filter(p => p.policyType === 'privacy_policy'), - terms_of_service: allPolicies.filter(p => p.policyType === 'terms_of_service') + // locale별로 정책 타입별 그룹화 + const policiesByLocaleAndType = { + ko: { + privacy_policy: allPolicies.filter(p => p.policyType === 'privacy_policy' && p.locale === 'ko'), + terms_of_service: allPolicies.filter(p => p.policyType === 'terms_of_service' && p.locale === 'ko') + }, + en: { + privacy_policy: allPolicies.filter(p => p.policyType === 'privacy_policy' && p.locale === 'en'), + terms_of_service: allPolicies.filter(p => p.policyType === 'terms_of_service' && p.locale === 'en') + } } - // 현재 정책 맵 - const currentPolicyMap = {} + // 현재 정책 맵 (locale별) + const currentPolicyMap = { + ko: {}, + en: {} + } currentPolicies.forEach(policy => { - currentPolicyMap[policy.policyType] = policy + currentPolicyMap[policy.locale][policy.policyType] = policy }) return { currentPolicies: currentPolicyMap, - allPolicies: policiesByType, + allPolicies: policiesByLocaleAndType, stats: { totalVersions: allPolicies.length, - privacyVersions: policiesByType.privacy_policy.length, - termsVersions: policiesByType.terms_of_service.length, + koVersions: { + privacy: policiesByLocaleAndType.ko.privacy_policy.length, + terms: policiesByLocaleAndType.ko.terms_of_service.length + }, + enVersions: { + privacy: policiesByLocaleAndType.en.privacy_policy.length, + terms: policiesByLocaleAndType.en.terms_of_service.length + }, lastUpdate: allPolicies[0]?.createdAt || null } } } catch (error) { console.error('Failed to fetch policies:', error) return { - currentPolicies: {}, - allPolicies: { privacy_policy: [], terms_of_service: [] }, - stats: { totalVersions: 0, privacyVersions: 0, termsVersions: 0, lastUpdate: null } + currentPolicies: { ko: {}, en: {} }, + allPolicies: { + ko: { privacy_policy: [], terms_of_service: [] }, + en: { privacy_policy: [], terms_of_service: [] } + }, + stats: { + totalVersions: 0, + koVersions: { privacy: 0, terms: 0 }, + enVersions: { privacy: 0, terms: 0 }, + lastUpdate: null + } } } } + export default async function PoliciesPage() { const data = await getPoliciesData() - return ( -
- {/* 헤더 */} -
-
-

정책 관리

-

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

-
-
- - {/* 통계 카드들 */} -
- - - 총 버전 수 - - - -
{data.stats.totalVersions}
-

- 전체 정책 버전 -

-
-
- - - - 개인정보 정책 - - - -
{data.stats.privacyVersions}
-

- 버전 수 -

-
-
- - - - 이용약관 - - - -
{data.stats.termsVersions}
-

- 버전 수 -

-
-
- - - - 최근 업데이트 - - - -
- {data.stats.lastUpdate - ? new Date(data.stats.lastUpdate).toLocaleDateString('ko-KR') - : 'N/A' - } -
-

- 마지막 정책 변경 -

-
-
-
- - {/* 현재 활성 정책들 */} -
- } - policy={data.currentPolicies.privacy_policy} - type="privacy_policy" - /> - } - policy={data.currentPolicies.terms_of_service} - type="terms_of_service" - /> -
- - - - {/* 클라이언트 컴포넌트로 편집 기능 제공 */} - }> - - -
- ) -} - -// 현재 정책 카드 컴포넌트 -function CurrentPolicyCard({ title, icon, policy, type }) { - if (!policy) { - return ( - - - - {icon} - {title} - - - -
-

아직 등록된 정책이 없습니다

-

새 버전을 생성해주세요

-
-
-
- ) - } - - return ( - - - - {icon} - {title} - v{policy.version} - - - 현재 활성 정책 • 시행일: {new Date(policy.effectiveDate).toLocaleDateString('ko-KR')} - - - -
- {/* 정책 내용 미리보기 */} -
-
- {policy.content?.replace(/#{1,6}\s+/g, '').replace(/\*\*(.*?)\*\*/g, '$1').substring(0, 200)}... -
-
- - {/* 메타 정보 */} -
-
- - 생성: {new Date(policy.createdAt).toLocaleDateString('ko-KR')} -
-
- - 관리자 -
-
-
-
-
- ) + return } - -// 로딩 스켈레톤 -function PolicyManagementSkeleton() { - return ( -
-
-
-
-
-
-
-
- ) -} \ No newline at end of file -- cgit v1.2.3