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
@@ -7,7 +7,7 @@
|
||||
* - 의학 검토·게시 승인은 사람 게이트다(§3-7). 후보만 보여주고 확정은 병원이 입력한다.
|
||||
*/
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { supabase } from '../../lib/supabase';
|
||||
import { db } from '../../lib/db';
|
||||
|
||||
type Build = {
|
||||
id: string;
|
||||
@@ -61,8 +61,8 @@ export function ClinicInputsPanel({ clinicId }: { clinicId: string }) {
|
||||
let alive = true;
|
||||
(async () => {
|
||||
const [b, i] = await Promise.all([
|
||||
supabase.from('supporter_builds').select('id,status,phase,preview_url,posts,report,updated_at').eq('clinic_id', clinicId).order('created_at', { ascending: false }).limit(1),
|
||||
supabase.from('supporter_inputs').select('key,post_id,value,input_by,created_at').eq('clinic_id', clinicId).order('created_at', { ascending: true }),
|
||||
db<Build[]>('builds.latest', { clinicId, fields: 'inputs' }),
|
||||
db<InputRow[]>('inputs.list', { clinicId }),
|
||||
]);
|
||||
if (!alive) return;
|
||||
if (b.error || i.error) { setLoadError((b.error ?? i.error)?.message ?? '불러오기 실패'); return; }
|
||||
@@ -82,7 +82,7 @@ export function ClinicInputsPanel({ clinicId }: { clinicId: string }) {
|
||||
|
||||
async function save(key: string, value: Record<string, unknown>, postId?: string) {
|
||||
setBusy(`${key}|${postId ?? ''}`); setMsg(null);
|
||||
const { error } = await supabase.from('supporter_inputs').insert({ clinic_id: clinicId, key, post_id: postId ?? null, value, input_by: inputBy || null });
|
||||
const { error } = await db('inputs.add', { clinicId, key, postId: postId ?? null, value, inputBy: inputBy || null });
|
||||
setBusy(null);
|
||||
if (error) { setMsg(`저장 실패: ${error.message}`); return; }
|
||||
setRows((prev) => [...prev, { key, post_id: postId ?? null, value, input_by: inputBy || null, created_at: new Date().toISOString() }]);
|
||||
|
||||
Reference in new issue
Block a user