[Backend API] - contact/route: 문의 내역 contact_requests DB 저장 추가 (이메일+DB 병행) - projects/route, link/route: 미사용 Bearer 토큰 인증 제거, Cookie 전용 - projects/route: DB 에러 메시지 클라이언트 노출 차단 (console.error로 전환) - quote/[token]/route: valid_until 만료 검증 + expired 플래그 응답 추가 [Frontend UX] - mypage: 로또 잔존 코드 완전 제거 (PLAN_LABELS, lotto_history 쿼리) - mypage: 기본 탭 projects로 변경, 탭 순서 외주 고객 우선 재배치 - freelance: 포트폴리오 가격대 뱃지 추가, 각 항목 CTA 링크 추가 - freelance: 후기 섹션 하단 CTA 블록 추가 [견적서 페이지] - quote/[token]/page: 만료 견적서 경고 배너 + 수락 버튼 숨김 - quote/layout: DashboardShell 없이 독립 렌더링 [보안] - test-flow.mjs: 하드코딩 시크릿 → .env.test 환경변수 참조로 교체 - GitGuardian 3건 대응 (admin password, JWT, test password) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import { NextResponse } from 'next/server';
|
|
import { createAdminClient } from '@/lib/supabase/admin';
|
|
import { createClient } from '@/lib/supabase/server';
|
|
|
|
export const runtime = 'nodejs';
|
|
|
|
export async function GET() {
|
|
const supabase = await createClient();
|
|
const { data: { user } } = await supabase.auth.getUser();
|
|
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
|
|
const admin = createAdminClient();
|
|
|
|
const { data: quotes, error: qErr } = await admin
|
|
.from('quotes')
|
|
.select('id, title, status, items, created_at')
|
|
.eq('user_id', user.id)
|
|
.in('status', ['sent', 'accepted', 'in_progress', 'completed', 'delivered'])
|
|
.order('created_at', { ascending: false });
|
|
|
|
if (qErr) {
|
|
console.error('[Projects] DB query error:', qErr.message);
|
|
return NextResponse.json({ error: '프로젝트 정보를 불러올 수 없습니다.' }, { status: 500 });
|
|
}
|
|
if (!quotes?.length) return NextResponse.json({ projects: [] });
|
|
|
|
const quoteIds = quotes.map((q) => q.id);
|
|
|
|
const { data: milestones } = await admin
|
|
.from('project_milestones')
|
|
.select('*')
|
|
.in('quote_id', quoteIds)
|
|
.order('step_number', { ascending: true });
|
|
|
|
const projects = quotes.map((q) => ({
|
|
id: q.id,
|
|
title: q.title,
|
|
status: q.status,
|
|
total: Array.isArray(q.items)
|
|
? q.items.reduce(
|
|
(s: number, i: { unitPrice?: number; quantity?: number }) =>
|
|
s + ((i.unitPrice ?? 0) * (i.quantity ?? 1)),
|
|
0
|
|
)
|
|
: 0,
|
|
created_at: q.created_at,
|
|
milestones: (milestones ?? [])
|
|
.filter((m) => m.quote_id === q.id)
|
|
.sort((a, b) => a.step_number - b.step_number),
|
|
}));
|
|
|
|
return NextResponse.json({ projects });
|
|
}
|