fix: 데모 화면의 DB 조회·쓰기를 서버 함수로 옮긴다
브라우저가 공개 키로 테이블을 직접 읽고 쓰던 구조를 없앤다.
- api/db.js: 정해진 작업만 서비스 키로 실행 (임의 쿼리·열 지정 불가)
- api/_origin.js: 서버 함수 공용 출처 검사, 공개 배포에서는 404
- src/lib/db.ts: 화면용 호출 함수, 반환 형태 { data, error } 유지
- 빌드 큐에 바로 넣던 예전 진단 신청 모달 삭제
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b91fdf1a6a
commit
0be730f0f9
14 files changed
+264
-378
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useLocation } from 'react-router';
|
||||
import type { MarketingPlan, ChannelStrategyCard, CalendarData, ContentStrategyData } from '../types/plan';
|
||||
import { fetchReportById, fetchActiveContentPlan, supabase } from '../lib/supabase';
|
||||
import { fetchReportById, fetchActiveContentPlan } from '../lib/supabase';
|
||||
import { db } from '../lib/db';
|
||||
import { transformReportToPlan } from '../lib/transformPlan';
|
||||
import { mockPlan } from '../data/mockPlan';
|
||||
import { mockPlanBanobagi } from '../data/mockPlan_banobagi';
|
||||
@@ -125,21 +126,13 @@ export function useMarketingPlan(id: string | undefined): UseMarketingPlanResult
|
||||
|
||||
if (!clinicId) {
|
||||
// Try to find clinicId from analysis_runs by run/report ID
|
||||
const { data: run } = await supabase
|
||||
.from('analysis_runs')
|
||||
.select('clinic_id')
|
||||
.eq('id', id)
|
||||
.single();
|
||||
const { data: run } = await db<{ clinic_id: string }>('run.clinicId', { id });
|
||||
if (run) clinicId = run.clinic_id;
|
||||
}
|
||||
|
||||
if (clinicId) {
|
||||
// Fetch clinic info for plan metadata
|
||||
const { data: clinic } = await supabase
|
||||
.from('clinics')
|
||||
.select('name, name_en, url')
|
||||
.eq('id', clinicId)
|
||||
.single();
|
||||
const { data: clinic } = await db<{ name: string | null; name_en: string | null; url: string | null }>('clinic.byId', { id: clinicId });
|
||||
if (clinic) {
|
||||
clinicName = clinic.name || '';
|
||||
clinicNameEn = clinic.name_en || '';
|
||||
|
||||
Reference in new issue
Block a user