- 예전 화면(/, /a)과 목업 데이터를 지우고 시안 B 를 / 로 - @hey-api/openapi-ts 로 타입·TanStack Query 함수 생성, 토큰·401 갱신 처리 - 공유는 기본 공유창, 없으면 링크 복사 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 lines
384 B
TypeScript
13 lines
384 B
TypeScript
import { createContext, use } from 'react'
|
|
import type { Me } from '../api/client/types.gen'
|
|
|
|
export type AuthApi = { loggedIn: boolean; me: Me | null; logout: () => void }
|
|
|
|
export const AuthContext = createContext<AuthApi | null>(null)
|
|
|
|
export function useAuth() {
|
|
const ctx = use(AuthContext)
|
|
if (!ctx) throw new Error('useAuth must be used inside AuthProvider')
|
|
return ctx
|
|
}
|