feat: 프로젝트 진행 현황 추적 시스템 구축 + 마케팅 카피 강화
[DB] - supabase/migrations/002_project_milestones.sql 추가 quotes.user_id 컬럼 + project_milestones 테이블 생성 SQL [API] - GET /api/projects — 로그인 사용자의 프로젝트+마일스톤 조회 - POST /api/projects/link — 견적서 토큰으로 계정에 프로젝트 연결 - GET/POST /api/admin/milestones — 관리자 마일스톤 목록/기본 7단계 초기화 - PATCH/DELETE /api/admin/milestones/[id] — 관리자 단계별 상태·메모 업데이트 [UI — 마이페이지] - '프로젝트 현황' 탭 신규 추가 (Tab type 확장) - 진행률 바, 단계별 타임라인, 개발자 메모 표시 - 견적서 코드 입력 → 계정 연결 폼 [UI — 관리자 견적서 편집] - '진행 단계' 탭 추가: 기본 7단계 초기화, 단계별 status/메모 편집 [마케팅 카피] - page.tsx PROMISES 4번째 추가: "진행 현황 마이페이지 실시간 확인" - freelance 보증 카드 5번째 추가: 실시간 진행 현황 (그리드 2×5) - services/website trust badge 5번째 추가 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
56
app/api/admin/milestones/[id]/route.ts
Normal file
56
app/api/admin/milestones/[id]/route.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { createAdminClient } from '@/lib/supabase/admin';
|
||||
import { verifyAdminTokenNode } from '@/lib/admin-auth';
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
|
||||
async function checkAuth() {
|
||||
const cookieStore = await cookies();
|
||||
const token = cookieStore.get('admin_token')?.value;
|
||||
return token && verifyAdminTokenNode(token);
|
||||
}
|
||||
|
||||
export async function PATCH(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
if (!(await checkAuth())) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
|
||||
const { id } = await params;
|
||||
const body = await request.json();
|
||||
|
||||
const ALLOWED = ['status', 'note', 'title', 'description'] as const;
|
||||
const update: Record<string, unknown> = {};
|
||||
ALLOWED.forEach((k) => { if (k in body) update[k] = body[k]; });
|
||||
|
||||
if (body.status === 'completed') {
|
||||
update.completed_at = new Date().toISOString();
|
||||
} else if ('status' in body) {
|
||||
update.completed_at = null;
|
||||
}
|
||||
update.updated_at = new Date().toISOString();
|
||||
|
||||
const admin = createAdminClient();
|
||||
const { data, error } = await admin
|
||||
.from('project_milestones')
|
||||
.update(update)
|
||||
.eq('id', id)
|
||||
.select()
|
||||
.single();
|
||||
|
||||
if (error) return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
return NextResponse.json({ milestone: data });
|
||||
}
|
||||
|
||||
export async function DELETE(
|
||||
_req: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
if (!(await checkAuth())) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
const { id } = await params;
|
||||
const admin = createAdminClient();
|
||||
const { error } = await admin.from('project_milestones').delete().eq('id', id);
|
||||
if (error) return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
return NextResponse.json({ success: true });
|
||||
}
|
||||
72
app/api/admin/milestones/route.ts
Normal file
72
app/api/admin/milestones/route.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { createAdminClient } from '@/lib/supabase/admin';
|
||||
import { verifyAdminTokenNode } from '@/lib/admin-auth';
|
||||
import { cookies } from 'next/headers';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
|
||||
const DEFAULT_MILESTONES = [
|
||||
{ step_number: 1, title: '의뢰 접수', description: '고객 의뢰 및 요구사항 파악 완료' },
|
||||
{ step_number: 2, title: '계약 체결', description: '계약서 작성 및 계약금 입금' },
|
||||
{ step_number: 3, title: '기획/와이어프레임', description: '사이트맵·화면 구성·기능 정의' },
|
||||
{ step_number: 4, title: '디자인 시안', description: 'UI/UX 시안 제작 및 고객 확인' },
|
||||
{ step_number: 5, title: '개발 진행', description: '프론트·백엔드 구현' },
|
||||
{ step_number: 6, title: '검수/테스트', description: '기능 검증 및 수정사항 반영' },
|
||||
{ step_number: 7, title: '납품 완료', description: '소스코드 이관 및 도메인 배포' },
|
||||
];
|
||||
|
||||
async function checkAuth() {
|
||||
const cookieStore = await cookies();
|
||||
const token = cookieStore.get('admin_token')?.value;
|
||||
return token && verifyAdminTokenNode(token);
|
||||
}
|
||||
|
||||
export async function GET(request: Request) {
|
||||
if (!(await checkAuth())) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const quoteId = searchParams.get('quoteId');
|
||||
if (!quoteId) return NextResponse.json({ error: 'quoteId 필요' }, { status: 400 });
|
||||
|
||||
const admin = createAdminClient();
|
||||
const { data, error } = await admin
|
||||
.from('project_milestones')
|
||||
.select('*')
|
||||
.eq('quote_id', quoteId)
|
||||
.order('step_number', { ascending: true });
|
||||
|
||||
if (error) return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
return NextResponse.json({ milestones: data ?? [] });
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
if (!(await checkAuth())) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
|
||||
const body = await request.json();
|
||||
const admin = createAdminClient();
|
||||
|
||||
// 기본 7단계 초기화
|
||||
if (body.useDefaults && body.quoteId) {
|
||||
await admin.from('project_milestones').delete().eq('quote_id', body.quoteId);
|
||||
const toInsert = DEFAULT_MILESTONES.map((m) => ({ ...m, quote_id: body.quoteId }));
|
||||
const { data, error } = await admin.from('project_milestones').insert(toInsert).select();
|
||||
if (error) return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
return NextResponse.json({ milestones: data }, { status: 201 });
|
||||
}
|
||||
|
||||
// 단일 추가
|
||||
const { data, error } = await admin
|
||||
.from('project_milestones')
|
||||
.insert({
|
||||
quote_id: body.quote_id,
|
||||
step_number: body.step_number ?? 1,
|
||||
title: body.title ?? '새 단계',
|
||||
description: body.description ?? '',
|
||||
status: 'pending',
|
||||
})
|
||||
.select()
|
||||
.single();
|
||||
|
||||
if (error) return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
return NextResponse.json({ milestone: data }, { status: 201 });
|
||||
}
|
||||
45
app/api/projects/link/route.ts
Normal file
45
app/api/projects/link/route.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { createAdminClient } from '@/lib/supabase/admin';
|
||||
import { createClient } from '@/lib/supabase/server';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const supabase = await createClient();
|
||||
const { data: { user } } = await supabase.auth.getUser();
|
||||
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
|
||||
const body = await request.json();
|
||||
const token = (body.token as string | undefined)?.trim();
|
||||
if (!token) return NextResponse.json({ error: '견적서 코드를 입력해주세요' }, { status: 400 });
|
||||
|
||||
const admin = createAdminClient();
|
||||
|
||||
const { data: quote, error } = await admin
|
||||
.from('quotes')
|
||||
.select('id, status, user_id, client_email')
|
||||
.eq('public_token', token)
|
||||
.single();
|
||||
|
||||
if (error || !quote) {
|
||||
return NextResponse.json({ error: '견적서를 찾을 수 없습니다. 코드를 다시 확인해주세요.' }, { status: 404 });
|
||||
}
|
||||
if (quote.status === 'draft') {
|
||||
return NextResponse.json({ error: '아직 발송되지 않은 견적서입니다.' }, { status: 400 });
|
||||
}
|
||||
if (quote.user_id && quote.user_id !== user.id) {
|
||||
return NextResponse.json({ error: '이미 다른 계정에 연결된 견적서입니다.' }, { status: 400 });
|
||||
}
|
||||
if (quote.user_id === user.id) {
|
||||
return NextResponse.json({ success: true, quoteId: quote.id, alreadyLinked: true });
|
||||
}
|
||||
|
||||
const { error: updateErr } = await admin
|
||||
.from('quotes')
|
||||
.update({ user_id: user.id, updated_at: new Date().toISOString() })
|
||||
.eq('id', quote.id);
|
||||
|
||||
if (updateErr) return NextResponse.json({ error: updateErr.message }, { status: 500 });
|
||||
|
||||
return NextResponse.json({ success: true, quoteId: quote.id });
|
||||
}
|
||||
50
app/api/projects/route.ts
Normal file
50
app/api/projects/route.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
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) return NextResponse.json({ error: qErr.message }, { 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 });
|
||||
}
|
||||
Reference in New Issue
Block a user