fix: 외주 플랫폼 전환율 개선 + API 보안 정비 + 시크릿 노출 제거
[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>
This commit is contained in:
@@ -8,6 +8,8 @@ import {
|
|||||||
getClientIp,
|
getClientIp,
|
||||||
INPUT_LIMITS,
|
INPUT_LIMITS,
|
||||||
} from '@/lib/security';
|
} from '@/lib/security';
|
||||||
|
import { createAdminClient } from '@/lib/supabase/admin';
|
||||||
|
import { createClient } from '@/lib/supabase/server';
|
||||||
|
|
||||||
const resend = new Resend(process.env.RESEND_API_KEY);
|
const resend = new Resend(process.env.RESEND_API_KEY);
|
||||||
|
|
||||||
@@ -58,27 +60,67 @@ export async function POST(request: Request) {
|
|||||||
// message는 pre-wrap으로 렌더링되므로 반드시 이스케이프
|
// message는 pre-wrap으로 렌더링되므로 반드시 이스케이프
|
||||||
const safeMessage = escapeHtml(message);
|
const safeMessage = escapeHtml(message);
|
||||||
|
|
||||||
await resend.emails.send({
|
// ── 로그인 사용자 확인 (optional) ─────────────────────────
|
||||||
from: 'onboarding@resend.dev',
|
let userId: string | null = null;
|
||||||
to: ['bgg8988@gmail.com'],
|
try {
|
||||||
replyTo: email,
|
const supabase = await createClient();
|
||||||
subject: `[쟁승메이드] 새로운 문의: ${safeSubject}`,
|
const { data } = await supabase.auth.getUser();
|
||||||
html: `
|
userId = data?.user?.id ?? null;
|
||||||
<h2>새로운 프로젝트 문의가 도착했습니다</h2>
|
} catch {
|
||||||
<hr />
|
// 비로그인 상태 — 무시
|
||||||
<p><strong>이름:</strong> ${safeName}</p>
|
}
|
||||||
<p><strong>연락처:</strong> ${safePhone}</p>
|
|
||||||
<p><strong>이메일:</strong> ${safeEmail}</p>
|
// ── 이메일 전송 ──────────────────────────────────────────
|
||||||
<p><strong>서비스:</strong> ${safeService}</p>
|
let emailSent = true;
|
||||||
<hr />
|
try {
|
||||||
<h3>문의 내용:</h3>
|
await resend.emails.send({
|
||||||
<p style="white-space: pre-wrap;">${safeMessage}</p>
|
from: 'onboarding@resend.dev',
|
||||||
<hr />
|
to: ['bgg8988@gmail.com'],
|
||||||
<p style="color: #666; font-size: 12px;">
|
replyTo: email,
|
||||||
이 메일은 jaengseung-made.com의 문의 폼에서 발송되었습니다.
|
subject: `[쟁승메이드] 새로운 문의: ${safeSubject}`,
|
||||||
</p>
|
html: `
|
||||||
`,
|
<h2>새로운 프로젝트 문의가 도착했습니다</h2>
|
||||||
});
|
<hr />
|
||||||
|
<p><strong>이름:</strong> ${safeName}</p>
|
||||||
|
<p><strong>연락처:</strong> ${safePhone}</p>
|
||||||
|
<p><strong>이메일:</strong> ${safeEmail}</p>
|
||||||
|
<p><strong>서비스:</strong> ${safeService}</p>
|
||||||
|
<hr />
|
||||||
|
<h3>문의 내용:</h3>
|
||||||
|
<p style="white-space: pre-wrap;">${safeMessage}</p>
|
||||||
|
<hr />
|
||||||
|
<p style="color: #666; font-size: 12px;">
|
||||||
|
이 메일은 jaengseung-made.com의 문의 폼에서 발송되었습니다.
|
||||||
|
</p>
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
} catch (emailError) {
|
||||||
|
console.error('[Contact] Email send error:', emailError);
|
||||||
|
emailSent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── DB 저장 (이메일 성공/실패 무관) ──────────────────────
|
||||||
|
try {
|
||||||
|
const admin = createAdminClient();
|
||||||
|
await admin.from('contact_requests').insert({
|
||||||
|
name,
|
||||||
|
email,
|
||||||
|
phone: phone || null,
|
||||||
|
service: service || null,
|
||||||
|
message,
|
||||||
|
user_id: userId,
|
||||||
|
created_at: new Date().toISOString(),
|
||||||
|
});
|
||||||
|
} catch (dbError) {
|
||||||
|
console.error('[Contact] DB insert error:', dbError);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!emailSent) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{ error: '메일 전송에 실패했습니다. 다시 시도해주세요.' },
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ success: true, message: '문의가 성공적으로 전송되었습니다!' },
|
{ success: true, message: '문의가 성공적으로 전송되었습니다!' },
|
||||||
@@ -86,9 +128,9 @@ export async function POST(request: Request) {
|
|||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 클라이언트에 내부 오류 상세 노출 금지
|
// 클라이언트에 내부 오류 상세 노출 금지
|
||||||
console.error('[Contact] Email send error:', error);
|
console.error('[Contact] Unexpected error:', error);
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ error: '메일 전송에 실패했습니다. 다시 시도해주세요.' },
|
{ error: '문의 처리 중 오류가 발생했습니다. 다시 시도해주세요.' },
|
||||||
{ status: 500 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,12 @@
|
|||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
import { createAdminClient } from '@/lib/supabase/admin';
|
import { createAdminClient } from '@/lib/supabase/admin';
|
||||||
import { createClient } from '@/lib/supabase/server';
|
import { createClient } from '@/lib/supabase/server';
|
||||||
import { createClient as createSupabaseClient } from '@supabase/supabase-js';
|
|
||||||
|
|
||||||
export const runtime = 'nodejs';
|
export const runtime = 'nodejs';
|
||||||
|
|
||||||
export async function POST(request: Request) {
|
export async function POST(request: Request) {
|
||||||
// Cookie 기반 또는 Bearer 토큰 기반 인증 모두 지원
|
const supabase = await createClient();
|
||||||
const authHeader = request.headers.get('authorization');
|
const { data: { user } } = await supabase.auth.getUser();
|
||||||
let user = null;
|
|
||||||
|
|
||||||
if (authHeader?.startsWith('Bearer ')) {
|
|
||||||
const token = authHeader.slice(7);
|
|
||||||
const client = createSupabaseClient(
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
||||||
);
|
|
||||||
const { data } = await client.auth.getUser(token);
|
|
||||||
user = data?.user ?? null;
|
|
||||||
} else {
|
|
||||||
const supabase = await createClient();
|
|
||||||
const { data } = await supabase.auth.getUser();
|
|
||||||
user = data?.user ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||||
|
|
||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
@@ -56,7 +39,10 @@ export async function POST(request: Request) {
|
|||||||
.update({ user_id: user.id, updated_at: new Date().toISOString() })
|
.update({ user_id: user.id, updated_at: new Date().toISOString() })
|
||||||
.eq('id', quote.id);
|
.eq('id', quote.id);
|
||||||
|
|
||||||
if (updateErr) return NextResponse.json({ error: updateErr.message }, { status: 500 });
|
if (updateErr) {
|
||||||
|
console.error('[Projects/Link] DB update error:', updateErr.message);
|
||||||
|
return NextResponse.json({ error: '견적서 연결에 실패했습니다. 다시 시도해주세요.' }, { status: 500 });
|
||||||
|
}
|
||||||
|
|
||||||
return NextResponse.json({ success: true, quoteId: quote.id });
|
return NextResponse.json({ success: true, quoteId: quote.id });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,12 @@
|
|||||||
import { NextResponse } from 'next/server';
|
import { NextResponse } from 'next/server';
|
||||||
import { createAdminClient } from '@/lib/supabase/admin';
|
import { createAdminClient } from '@/lib/supabase/admin';
|
||||||
import { createClient } from '@/lib/supabase/server';
|
import { createClient } from '@/lib/supabase/server';
|
||||||
import { createClient as createSupabaseClient } from '@supabase/supabase-js';
|
|
||||||
|
|
||||||
export const runtime = 'nodejs';
|
export const runtime = 'nodejs';
|
||||||
|
|
||||||
export async function GET(request: Request) {
|
export async function GET() {
|
||||||
// Cookie 기반 또는 Bearer 토큰 기반 인증 모두 지원
|
const supabase = await createClient();
|
||||||
const authHeader = request.headers.get('authorization');
|
const { data: { user } } = await supabase.auth.getUser();
|
||||||
let user = null;
|
|
||||||
|
|
||||||
if (authHeader?.startsWith('Bearer ')) {
|
|
||||||
const token = authHeader.slice(7);
|
|
||||||
const client = createSupabaseClient(
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
|
||||||
);
|
|
||||||
const { data } = await client.auth.getUser(token);
|
|
||||||
user = data?.user ?? null;
|
|
||||||
} else {
|
|
||||||
const supabase = await createClient();
|
|
||||||
const { data } = await supabase.auth.getUser();
|
|
||||||
user = data?.user ?? null;
|
|
||||||
}
|
|
||||||
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||||
|
|
||||||
const admin = createAdminClient();
|
const admin = createAdminClient();
|
||||||
@@ -34,7 +18,10 @@ export async function GET(request: Request) {
|
|||||||
.in('status', ['sent', 'accepted', 'in_progress', 'completed', 'delivered'])
|
.in('status', ['sent', 'accepted', 'in_progress', 'completed', 'delivered'])
|
||||||
.order('created_at', { ascending: false });
|
.order('created_at', { ascending: false });
|
||||||
|
|
||||||
if (qErr) return NextResponse.json({ error: qErr.message }, { status: 500 });
|
if (qErr) {
|
||||||
|
console.error('[Projects] DB query error:', qErr.message);
|
||||||
|
return NextResponse.json({ error: '프로젝트 정보를 불러올 수 없습니다.' }, { status: 500 });
|
||||||
|
}
|
||||||
if (!quotes?.length) return NextResponse.json({ projects: [] });
|
if (!quotes?.length) return NextResponse.json({ projects: [] });
|
||||||
|
|
||||||
const quoteIds = quotes.map((q) => q.id);
|
const quoteIds = quotes.map((q) => q.id);
|
||||||
|
|||||||
@@ -15,7 +15,13 @@ export async function GET(_req: Request, { params }: { params: Promise<{ token:
|
|||||||
.single();
|
.single();
|
||||||
|
|
||||||
if (error || !data) return NextResponse.json({ error: 'Not found' }, { status: 404 });
|
if (error || !data) return NextResponse.json({ error: 'Not found' }, { status: 404 });
|
||||||
return NextResponse.json({ quote: data });
|
|
||||||
|
// 만료 검증: valid_until이 현재 시간보다 과거이면 expired 플래그 추가
|
||||||
|
const expired = data.valid_until
|
||||||
|
? new Date(data.valid_until).getTime() < Date.now()
|
||||||
|
: false;
|
||||||
|
|
||||||
|
return NextResponse.json({ quote: data, expired });
|
||||||
}
|
}
|
||||||
|
|
||||||
// 고객이 견적 수락
|
// 고객이 견적 수락
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const portfolio = [
|
|||||||
tags: ['Next.js', 'Tailwind CSS', 'Vercel', 'SEO'],
|
tags: ['Next.js', 'Tailwind CSS', 'Vercel', 'SEO'],
|
||||||
status: '납품 완료',
|
status: '납품 완료',
|
||||||
statusType: 'done',
|
statusType: 'done',
|
||||||
|
priceRange: '50~200만원',
|
||||||
accentColor: 'text-indigo-400',
|
accentColor: 'text-indigo-400',
|
||||||
accentBg: 'bg-[#0d0a2e]',
|
accentBg: 'bg-[#0d0a2e]',
|
||||||
borderAccent: 'border-indigo-400/20',
|
borderAccent: 'border-indigo-400/20',
|
||||||
@@ -25,6 +26,7 @@ const portfolio = [
|
|||||||
tags: ['Python', 'Gmail API', 'Google Apps Script'],
|
tags: ['Python', 'Gmail API', 'Google Apps Script'],
|
||||||
status: '납품 완료',
|
status: '납품 완료',
|
||||||
statusType: 'done',
|
statusType: 'done',
|
||||||
|
priceRange: '30~150만원',
|
||||||
accentColor: 'text-red-400',
|
accentColor: 'text-red-400',
|
||||||
accentBg: 'bg-[#200a0a]',
|
accentBg: 'bg-[#200a0a]',
|
||||||
borderAccent: 'border-red-400/20',
|
borderAccent: 'border-red-400/20',
|
||||||
@@ -37,6 +39,7 @@ const portfolio = [
|
|||||||
tags: ['Python', 'Selenium', 'Telegram Bot'],
|
tags: ['Python', 'Selenium', 'Telegram Bot'],
|
||||||
status: '납품 완료',
|
status: '납품 완료',
|
||||||
statusType: 'done',
|
statusType: 'done',
|
||||||
|
priceRange: '30~150만원',
|
||||||
accentColor: 'text-violet-400',
|
accentColor: 'text-violet-400',
|
||||||
accentBg: 'bg-[#0d0a2e]',
|
accentBg: 'bg-[#0d0a2e]',
|
||||||
borderAccent: 'border-violet-400/20',
|
borderAccent: 'border-violet-400/20',
|
||||||
@@ -49,6 +52,7 @@ const portfolio = [
|
|||||||
tags: ['Python', 'OpenPyXL', 'ReportLab'],
|
tags: ['Python', 'OpenPyXL', 'ReportLab'],
|
||||||
status: '납품 완료',
|
status: '납품 완료',
|
||||||
statusType: 'done',
|
statusType: 'done',
|
||||||
|
priceRange: '30~150만원',
|
||||||
accentColor: 'text-cyan-400',
|
accentColor: 'text-cyan-400',
|
||||||
accentBg: 'bg-[#012030]',
|
accentBg: 'bg-[#012030]',
|
||||||
borderAccent: 'border-cyan-400/20',
|
borderAccent: 'border-cyan-400/20',
|
||||||
@@ -61,6 +65,7 @@ const portfolio = [
|
|||||||
tags: ['Python', '공공데이터 API', 'PostgreSQL', 'Telegram'],
|
tags: ['Python', '공공데이터 API', 'PostgreSQL', 'Telegram'],
|
||||||
status: '납품 완료',
|
status: '납품 완료',
|
||||||
statusType: 'done',
|
statusType: 'done',
|
||||||
|
priceRange: '30~150만원',
|
||||||
accentColor: 'text-blue-400',
|
accentColor: 'text-blue-400',
|
||||||
accentBg: 'bg-[#04102b]',
|
accentBg: 'bg-[#04102b]',
|
||||||
borderAccent: 'border-blue-400/20',
|
borderAccent: 'border-blue-400/20',
|
||||||
@@ -341,6 +346,12 @@ export default function FreelancePage() {
|
|||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex items-center justify-between mt-3 pt-3 border-t border-slate-100">
|
||||||
|
<span className="text-xs text-blue-600 font-semibold bg-blue-50 px-2 py-0.5 rounded-full">{item.priceRange}</span>
|
||||||
|
<a href="#contact-form" className="inline-flex items-center gap-1 text-sm text-blue-600 hover:text-blue-800 font-medium transition">
|
||||||
|
비슷한 서비스 의뢰하기 →
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -408,6 +419,13 @@ export default function FreelancePage() {
|
|||||||
<p className="text-center text-slate-400 text-xs mt-5">
|
<p className="text-center text-slate-400 text-xs mt-5">
|
||||||
* 의뢰인 동의 하에 게시된 후기입니다. 전체 대화 내역 공개 요청 시 제공 가능합니다.
|
* 의뢰인 동의 하에 게시된 후기입니다. 전체 대화 내역 공개 요청 시 제공 가능합니다.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<div className="text-center py-6">
|
||||||
|
<a href="#contact-form" className="inline-flex items-center gap-2 px-6 py-3 bg-[#1a56db] text-white font-semibold rounded-xl hover:bg-blue-700 transition shadow-sm">
|
||||||
|
무료 상담 시작하기
|
||||||
|
</a>
|
||||||
|
<p className="text-sm text-slate-400 mt-2">24시간 내 답변 · 상담은 무료입니다</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -581,7 +599,7 @@ export default function FreelancePage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* ─── 문의 폼 ─── */}
|
{/* ─── 문의 폼 ─── */}
|
||||||
<div className="px-6 pb-14 lg:px-12">
|
<div id="contact-form" className="px-6 pb-14 lg:px-12">
|
||||||
<div className="max-w-5xl mx-auto">
|
<div className="max-w-5xl mx-auto">
|
||||||
<div className="text-center mb-8">
|
<div className="text-center mb-8">
|
||||||
<p className="text-[#1a56db] text-xs font-bold uppercase tracking-widest mb-2">CONTACT</p>
|
<p className="text-[#1a56db] text-xs font-bold uppercase tracking-widest mb-2">CONTACT</p>
|
||||||
|
|||||||
@@ -48,14 +48,6 @@ interface Order {
|
|||||||
status: string;
|
status: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LottoHistoryItem {
|
|
||||||
id: number;
|
|
||||||
numbers: number[];
|
|
||||||
source: string;
|
|
||||||
plan_id: string;
|
|
||||||
created_at: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ProjectMilestone {
|
interface ProjectMilestone {
|
||||||
id: string;
|
id: string;
|
||||||
step_number: number;
|
step_number: number;
|
||||||
@@ -85,22 +77,15 @@ interface ActiveSubscription {
|
|||||||
cancelled_at: string | null;
|
cancelled_at: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PLAN_LABELS: Record<string, { label: string; emoji: string; color: string }> = {
|
|
||||||
lotto_gold: { label: '골드', emoji: '🥇', color: 'amber' },
|
|
||||||
lotto_platinum: { label: '플래티넘', emoji: '💎', color: 'sky' },
|
|
||||||
lotto_diamond: { label: '다이아', emoji: '👑', color: 'violet' },
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function MyPage() {
|
export default function MyPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const supabase = createClient();
|
const supabase = createClient();
|
||||||
const [user, setUser] = useState<User | null>(null);
|
const [user, setUser] = useState<User | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [tab, setTab] = useState<Tab>('profile');
|
const [tab, setTab] = useState<Tab>('projects');
|
||||||
const [sajuRecords, setSajuRecords] = useState<SajuRecord[]>([]);
|
const [sajuRecords, setSajuRecords] = useState<SajuRecord[]>([]);
|
||||||
const [payments, setPayments] = useState<Payment[]>([]);
|
const [payments, setPayments] = useState<Payment[]>([]);
|
||||||
const [orders, setOrders] = useState<Order[]>([]);
|
const [orders, setOrders] = useState<Order[]>([]);
|
||||||
const [lottoHistory, setLottoHistory] = useState<LottoHistoryItem[]>([]);
|
|
||||||
const [activeSubscriptions, setActiveSubscriptions] = useState<ActiveSubscription[]>([]);
|
const [activeSubscriptions, setActiveSubscriptions] = useState<ActiveSubscription[]>([]);
|
||||||
const [projects, setProjects] = useState<Project[]>([]);
|
const [projects, setProjects] = useState<Project[]>([]);
|
||||||
const [linkToken, setLinkToken] = useState('');
|
const [linkToken, setLinkToken] = useState('');
|
||||||
@@ -172,15 +157,6 @@ export default function MyPage() {
|
|||||||
setProjects(projData.projects ?? []);
|
setProjects(projData.projects ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 로또 히스토리 조회
|
|
||||||
const { data: history } = await supabase
|
|
||||||
.from('lotto_history')
|
|
||||||
.select('id, numbers, source, plan_id, created_at')
|
|
||||||
.eq('user_id', user.id)
|
|
||||||
.order('created_at', { ascending: false })
|
|
||||||
.limit(50);
|
|
||||||
setLottoHistory(history ?? []);
|
|
||||||
|
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
init();
|
init();
|
||||||
@@ -308,12 +284,12 @@ export default function MyPage() {
|
|||||||
const activeSubs = activeSubscriptions.filter((s) => s.status === 'active' || s.status === 'cancelled');
|
const activeSubs = activeSubscriptions.filter((s) => s.status === 'active' || s.status === 'cancelled');
|
||||||
|
|
||||||
const tabs: { key: Tab; label: string; count?: number }[] = [
|
const tabs: { key: Tab; label: string; count?: number }[] = [
|
||||||
{ key: 'profile', label: '내 정보' },
|
|
||||||
{ key: 'projects', label: '프로젝트 현황', count: projects.length || undefined },
|
{ key: 'projects', label: '프로젝트 현황', count: projects.length || undefined },
|
||||||
|
{ key: 'orders', label: '의뢰 내역', count: orders.length || undefined },
|
||||||
|
{ key: 'payments', label: '결제 내역', count: payments.length || undefined },
|
||||||
|
{ key: 'profile', label: '내 정보' },
|
||||||
{ key: 'subscription', label: '구독 관리', count: activeSubs.length || undefined },
|
{ key: 'subscription', label: '구독 관리', count: activeSubs.length || undefined },
|
||||||
{ key: 'saju', label: '사주 기록', count: sajuRecords.length || undefined },
|
{ key: 'saju', label: '사주 기록', count: sajuRecords.length || undefined },
|
||||||
{ key: 'payments', label: '결제 내역', count: payments.length || undefined },
|
|
||||||
{ key: 'orders', label: '의뢰 내역', count: orders.length || undefined },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -405,21 +381,21 @@ export default function MyPage() {
|
|||||||
|
|
||||||
{/* 구독 중인 서비스 - 요약 (탭으로 유도) */}
|
{/* 구독 중인 서비스 - 요약 (탭으로 유도) */}
|
||||||
{activeSubs.length > 0 && (
|
{activeSubs.length > 0 && (
|
||||||
<div className="bg-amber-50 rounded-2xl border border-amber-200 p-5 flex items-center justify-between gap-3">
|
<div className="bg-blue-50 rounded-2xl border border-blue-200 p-5 flex items-center justify-between gap-3">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<span className="text-2xl">{PLAN_LABELS[activeSubs[0].product_id]?.emoji ?? '🎟'}</span>
|
<span className="text-2xl">🎟</span>
|
||||||
<div>
|
<div>
|
||||||
<div className="text-sm font-bold text-[#04102b]">
|
<div className="text-sm font-bold text-[#04102b]">
|
||||||
로또 {PLAN_LABELS[activeSubs[0].product_id]?.label} 구독 중
|
서비스 구독 중
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-amber-600 mt-0.5">
|
<div className="text-xs text-blue-600 mt-0.5">
|
||||||
{Math.max(0, Math.ceil((new Date(activeSubs[0].expires_at).getTime() - Date.now()) / 86400000))}일 후 만료
|
{Math.max(0, Math.ceil((new Date(activeSubs[0].expires_at).getTime() - Date.now()) / 86400000))}일 후 만료
|
||||||
{activeSubs[0].status === 'cancelled' && ' · 해지 예정'}
|
{activeSubs[0].status === 'cancelled' && ' · 해지 예정'}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button onClick={() => setTab('subscription')}
|
<button onClick={() => setTab('subscription')}
|
||||||
className="text-xs font-bold text-amber-700 bg-amber-100 hover:bg-amber-200 px-3 py-1.5 rounded-lg transition">
|
className="text-xs font-bold text-blue-700 bg-blue-100 hover:bg-blue-200 px-3 py-1.5 rounded-lg transition">
|
||||||
구독 관리 →
|
구독 관리 →
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -574,7 +550,6 @@ export default function MyPage() {
|
|||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
activeSubscriptions.map((sub) => {
|
activeSubscriptions.map((sub) => {
|
||||||
const info = PLAN_LABELS[sub.product_id];
|
|
||||||
const expiresDate = new Date(sub.expires_at);
|
const expiresDate = new Date(sub.expires_at);
|
||||||
const daysLeft = Math.max(0, Math.ceil((expiresDate.getTime() - Date.now()) / 86400000));
|
const daysLeft = Math.max(0, Math.ceil((expiresDate.getTime() - Date.now()) / 86400000));
|
||||||
const isExpired = sub.status === 'expired';
|
const isExpired = sub.status === 'expired';
|
||||||
@@ -586,10 +561,10 @@ export default function MyPage() {
|
|||||||
{/* 헤더 */}
|
{/* 헤더 */}
|
||||||
<div className="flex items-start justify-between mb-5">
|
<div className="flex items-start justify-between mb-5">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<span className="text-3xl">{info?.emoji ?? '🎟'}</span>
|
<span className="text-3xl">🎟</span>
|
||||||
<div>
|
<div>
|
||||||
<div className="font-bold text-[#04102b] text-base">
|
<div className="font-bold text-[#04102b] text-base">
|
||||||
로또 번호 추천 {info?.label ?? sub.product_id}
|
{sub.product_id}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-slate-500 mt-0.5">
|
<div className="text-xs text-slate-500 mt-0.5">
|
||||||
{new Date(sub.started_at).toLocaleDateString('ko-KR')} 시작
|
{new Date(sub.started_at).toLocaleDateString('ko-KR')} 시작
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ export default function QuotePage() {
|
|||||||
.finally(() => setLoading(false));
|
.finally(() => setLoading(false));
|
||||||
}, [token]);
|
}, [token]);
|
||||||
|
|
||||||
|
const isExpired = quote?.valid_until ? new Date(quote.valid_until) < new Date() : false;
|
||||||
|
|
||||||
const requiredItems = quote?.items.filter((i) => !i.optional) ?? [];
|
const requiredItems = quote?.items.filter((i) => !i.optional) ?? [];
|
||||||
const optionalItems = quote?.items.filter((i) => i.optional) ?? [];
|
const optionalItems = quote?.items.filter((i) => i.optional) ?? [];
|
||||||
|
|
||||||
@@ -227,6 +229,19 @@ export default function QuotePage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* 만료 배너 */}
|
||||||
|
{isExpired && (
|
||||||
|
<div style={{ maxWidth: 900, margin: '0 auto', padding: '16px 24px 0' }}>
|
||||||
|
<div style={{ background: 'rgba(245,158,11,0.1)', border: '1px solid rgba(245,158,11,0.3)', borderRadius: 12, padding: '14px 20px', display: 'flex', alignItems: 'center', gap: 10 }}>
|
||||||
|
<span style={{ fontSize: 18 }}>⚠</span>
|
||||||
|
<div>
|
||||||
|
<div style={{ color: '#f59e0b', fontWeight: 700, fontSize: 14 }}>이 견적서는 만료되었습니다</div>
|
||||||
|
<div style={{ color: '#92400e', fontSize: 13 }}>유효기간({quote.valid_until?.slice(0, 10)})이 지났습니다. 새 견적이 필요하시면 문의해 주세요.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* 본문 */}
|
{/* 본문 */}
|
||||||
<div style={{ maxWidth: 900, margin: '0 auto', padding: '32px 24px' }}>
|
<div style={{ maxWidth: 900, margin: '0 auto', padding: '32px 24px' }}>
|
||||||
|
|
||||||
@@ -445,7 +460,7 @@ export default function QuotePage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 하단 고정 바 — 견적 수락 */}
|
{/* 하단 고정 바 — 견적 수락 */}
|
||||||
{quote.status !== 'accepted' && quote.status !== 'rejected' && (
|
{quote.status !== 'accepted' && quote.status !== 'rejected' && !isExpired && (
|
||||||
<div style={{ position: 'fixed', bottom: 0, left: 0, right: 0, background: 'rgba(10,15,30,0.95)', backdropFilter: 'blur(12px)', borderTop: '1px solid rgba(255,255,255,0.08)', padding: '16px 24px' }}>
|
<div style={{ position: 'fixed', bottom: 0, left: 0, right: 0, background: 'rgba(10,15,30,0.95)', backdropFilter: 'blur(12px)', borderTop: '1px solid rgba(255,255,255,0.08)', padding: '16px 24px' }}>
|
||||||
<div style={{ maxWidth: 900, margin: '0 auto', display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16, flexWrap: 'wrap' }}>
|
<div style={{ maxWidth: 900, margin: '0 auto', display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16, flexWrap: 'wrap' }}>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
3
app/quote/layout.tsx
Normal file
3
app/quote/layout.tsx
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default function QuoteLayout({ children }: { children: React.ReactNode }) {
|
||||||
|
return <>{children}</>;
|
||||||
|
}
|
||||||
@@ -13,17 +13,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { createClient } from '@supabase/supabase-js';
|
import { createClient } from '@supabase/supabase-js';
|
||||||
|
import { config } from 'dotenv';
|
||||||
|
|
||||||
const BASE_URL = 'http://localhost:3000';
|
// .env.test 파일에서 환경변수 로드
|
||||||
const SUPABASE_URL = 'https://avickbbhyhlnqbbqfzws.supabase.co';
|
config({ path: '.env.test' });
|
||||||
const SUPABASE_ANON_KEY =
|
|
||||||
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImF2aWNrYmJoeWhsbnFiYnFmendzIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA4MjY0OTQsImV4cCI6MjA4NjQwMjQ5NH0.CFJCWlZpVzv3FQohhVuQLS8GbkvJrc7T7zDwltWuVZw';
|
const BASE_URL = process.env.TEST_BASE_URL || 'http://localhost:3000';
|
||||||
const ADMIN_ID = 'jaengseung_admin';
|
const SUPABASE_URL = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
||||||
const ADMIN_PASSWORD = 'JaengSeung@Admin2026!';
|
const SUPABASE_ANON_KEY = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
||||||
|
const ADMIN_ID = process.env.TEST_ADMIN_ID;
|
||||||
|
const ADMIN_PASSWORD = process.env.TEST_ADMIN_PASSWORD;
|
||||||
|
|
||||||
|
if (!SUPABASE_URL || !SUPABASE_ANON_KEY || !ADMIN_ID || !ADMIN_PASSWORD) {
|
||||||
|
console.error('❌ .env.test 파일에 필수 환경변수가 없습니다.');
|
||||||
|
console.error(' NEXT_PUBLIC_SUPABASE_URL, NEXT_PUBLIC_SUPABASE_ANON_KEY, TEST_ADMIN_ID, TEST_ADMIN_PASSWORD');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// 테스트 계정 정보
|
// 테스트 계정 정보
|
||||||
const TEST_EMAIL = `testuser_${Date.now()}@test-jaengseung.com`;
|
const TEST_EMAIL = `testuser_${Date.now()}@test-jaengseung.com`;
|
||||||
const TEST_PASSWORD = 'Test@2026!';
|
const TEST_PASSWORD = process.env.TEST_USER_PASSWORD || 'Test@2026!';
|
||||||
|
|
||||||
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
|
||||||
|
|
||||||
@@ -312,8 +321,8 @@ function printBrowserGuide(quote, email, password, linked) {
|
|||||||
console.log(`
|
console.log(`
|
||||||
[관리자 화면]
|
[관리자 화면]
|
||||||
URL: http://localhost:3000/admin/login
|
URL: http://localhost:3000/admin/login
|
||||||
ID : jaengseung_admin
|
ID : ${ADMIN_ID}
|
||||||
PW : JaengSeung@Admin2026!
|
PW : (환경변수 TEST_ADMIN_PASSWORD 참조)
|
||||||
|
|
||||||
→ 로그인 후 견적서 목록에서 아래 견적서 클릭:
|
→ 로그인 후 견적서 목록에서 아래 견적서 클릭:
|
||||||
"${quote.title}" (${quote.id.slice(0, 8)}...)
|
"${quote.title}" (${quote.id.slice(0, 8)}...)
|
||||||
|
|||||||
Reference in New Issue
Block a user