upgrade to tamagui v2 and guest pwa overhaul
This commit is contained in:
26
resources/js/guest-v2/services/tasksApi.ts
Normal file
26
resources/js/guest-v2/services/tasksApi.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { fetchJson } from './apiClient';
|
||||
import { getDeviceId } from '../lib/device';
|
||||
|
||||
export type TaskItem = Record<string, unknown>;
|
||||
|
||||
type TaskResponse = {
|
||||
data?: TaskItem[];
|
||||
};
|
||||
|
||||
export async function fetchTasks(eventToken: string, options: { locale?: string; page?: number; perPage?: number } = {}) {
|
||||
const params = new URLSearchParams();
|
||||
if (options.locale) params.set('locale', options.locale);
|
||||
if (options.page) params.set('page', String(options.page));
|
||||
if (options.perPage) params.set('per_page', String(options.perPage));
|
||||
|
||||
const response = await fetchJson<TaskResponse>(
|
||||
`/api/v1/events/${encodeURIComponent(eventToken)}/tasks${params.toString() ? `?${params.toString()}` : ''}`,
|
||||
{
|
||||
headers: {
|
||||
'X-Device-Id': getDeviceId(),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return response.data?.data ?? [];
|
||||
}
|
||||
Reference in New Issue
Block a user