import { ApiError, apiGet, apiPut } from "@/app/lib/clientApi"; export interface RegistrationLink { token: string; enabled: boolean; } export interface EventLinks { event: RegistrationLink; members: (RegistrationLink & { userId: number; name: string; username: string })[]; } export interface MyLink extends RegistrationLink { eventUuid: string; eventName: string; startDate: string; endDate: string; location: string; } export interface PrivacyNotice { id: number; companyId: number; textEn: string; textMs: string; createdBy: string; createdAt: string; } export const getEventLinks = (uuid: string) => apiGet(`/api/events/${encodeURIComponent(uuid)}/registration-links`); export const setLinkEnabled = (uuid: string, token: string, enabled: boolean) => apiPut(`/api/events/${encodeURIComponent(uuid)}/registration-links/${encodeURIComponent(token)}`, { enabled }); export const getMyLinks = () => apiGet("/api/my-registration-links"); export async function getPrivacyNotice(companyId: number): Promise { try { return await apiGet(`/api/companies/${companyId}/privacy-notice`); } catch (err) { if (err instanceof ApiError && err.status === 404) return null; // no notice published yet throw err; } } export const savePrivacyNotice = (companyId: number, body: { textEn: string; textMs: string }) => apiPut(`/api/companies/${companyId}/privacy-notice`, body);