feat: main 병합 + 인스타 올리기 API(/v1/card/{id}/instagram), 관리자 올릴 곳 선택(로컬·킹서버), 만든 카드 화면
This commit is contained in:
commit
572b2a05c8
188 files changed
+16605
-741
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
|
||||
/** 올릴 곳 (관리자 서버가 비밀값을 가진 곳만 나온다): 로컬 백엔드, 킹서버 */
|
||||
export type Target = { id: 'local' | 'king'; label: string; site: string; api: string }
|
||||
|
||||
export function useTargets() {
|
||||
return useQuery({
|
||||
queryKey: ['targets'],
|
||||
queryFn: async () => (await (await fetch('/api/targets')).json()) as Target[],
|
||||
staleTime: Infinity,
|
||||
})
|
||||
}
|
||||
|
||||
export type CardSummary = { card_id: number; status: 1 | 2 | 3; post_id?: number; ig_media_id?: string }
|
||||
|
||||
export async function postCard(target: Target['id'], body: unknown): Promise<CardSummary> {
|
||||
const r = await fetch(`/api/post?target=${target}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) })
|
||||
const res = await r.json()
|
||||
if (!r.ok || res.result?.success === false) throw new Error(res.error ?? res.msg ?? res.result?.desc ?? `HTTP ${r.status}`)
|
||||
return res
|
||||
}
|
||||
|
||||
export async function cardAction(target: Target['id'], id: number, what: 'publish' | 'reject' | 'instagram'): Promise<CardSummary> {
|
||||
const r = await fetch(`/api/cards/${id}/${what}?target=${target}`, { method: 'POST' })
|
||||
const res = await r.json()
|
||||
if (!r.ok || res.result?.success === false) throw new Error(res.error ?? res.msg ?? res.result?.desc ?? `HTTP ${r.status}`)
|
||||
return res
|
||||
}
|
||||
Reference in new issue
Block a user