Add complete snitch feature with contact management, consent system, and notification delivery
This commit is contained in:
@@ -741,6 +741,107 @@ export const api = {
|
||||
},
|
||||
},
|
||||
|
||||
// Snitch System
|
||||
snitch: {
|
||||
getSettings: async () => {
|
||||
return request<{
|
||||
snitch_enabled: boolean;
|
||||
trigger_after_nags: number;
|
||||
trigger_after_missed_doses: number;
|
||||
max_snitches_per_day: number;
|
||||
require_consent: boolean;
|
||||
consent_given: boolean;
|
||||
snitch_cooldown_hours: number;
|
||||
}>('/api/snitch/settings', { method: 'GET' });
|
||||
},
|
||||
|
||||
updateSettings: async (data: {
|
||||
snitch_enabled?: boolean;
|
||||
trigger_after_nags?: number;
|
||||
trigger_after_missed_doses?: number;
|
||||
max_snitches_per_day?: number;
|
||||
require_consent?: boolean;
|
||||
consent_given?: boolean;
|
||||
snitch_cooldown_hours?: number;
|
||||
}) => {
|
||||
return request<{ success: boolean }>('/api/snitch/settings', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
},
|
||||
|
||||
giveConsent: async (consent_given: boolean) => {
|
||||
return request<{ success: boolean; consent_given: boolean }>('/api/snitch/consent', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ consent_given }),
|
||||
});
|
||||
},
|
||||
|
||||
getContacts: async () => {
|
||||
return request<Array<{
|
||||
id: string;
|
||||
contact_name: string;
|
||||
contact_type: string;
|
||||
contact_value: string;
|
||||
priority: number;
|
||||
notify_all: boolean;
|
||||
is_active: boolean;
|
||||
}>>('/api/snitch/contacts', { method: 'GET' });
|
||||
},
|
||||
|
||||
addContact: async (data: {
|
||||
contact_name: string;
|
||||
contact_type: string;
|
||||
contact_value: string;
|
||||
priority?: number;
|
||||
notify_all?: boolean;
|
||||
is_active?: boolean;
|
||||
}) => {
|
||||
return request<{ success: boolean; contact_id: string }>('/api/snitch/contacts', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
},
|
||||
|
||||
updateContact: async (contactId: string, data: {
|
||||
contact_name?: string;
|
||||
contact_type?: string;
|
||||
contact_value?: string;
|
||||
priority?: number;
|
||||
notify_all?: boolean;
|
||||
is_active?: boolean;
|
||||
}) => {
|
||||
return request<{ success: boolean }>(`/api/snitch/contacts/${contactId}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
},
|
||||
|
||||
deleteContact: async (contactId: string) => {
|
||||
return request<{ success: boolean }>(`/api/snitch/contacts/${contactId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
},
|
||||
|
||||
getHistory: async (days?: number) => {
|
||||
return request<Array<{
|
||||
id: string;
|
||||
contact_id: string;
|
||||
medication_id: string;
|
||||
trigger_reason: string;
|
||||
snitch_count_today: number;
|
||||
sent_at: string;
|
||||
delivered: boolean;
|
||||
}>>(`/api/snitch/history?days=${days || 7}`, { method: 'GET' });
|
||||
},
|
||||
|
||||
test: async () => {
|
||||
return request<{ success: boolean; message: string }>('/api/snitch/test', {
|
||||
method: 'POST',
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
// Medications
|
||||
medications: {
|
||||
list: async () => {
|
||||
|
||||
Reference in New Issue
Block a user