Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
12 lines
297 B
TypeScript
12 lines
297 B
TypeScript
import type { ServiceResult } from '@/services/errorHandler'
|
|
|
|
/**
|
|
* Turns a ServiceResult into a thrown error for TanStack Query,
|
|
* or returns the success payload.
|
|
*/
|
|
export const unwrapService = <T>(result: ServiceResult<T>): T => {
|
|
if (result.ok) return result.data
|
|
|
|
throw result.error
|
|
}
|