Fix medication system and rename to Synculous.

- Add all 14 missing database tables (medications, med_logs, routines, etc.)
- Rewrite medication scheduling: support specific days, every N days, as-needed (PRN)
- Fix taken_times matching: match by created_at date, not scheduled_time string
- Fix adherence calculation: taken / expected doses, not taken / (taken + skipped)
- Add formatSchedule() helper for readable display
- Update client types and API layer
- Rename brilli-ins-client → synculous-client
- Make client PWA: add manifest, service worker, icons
- Bind dev server to 0.0.0.0 for network access
- Fix SVG icon bugs in Icons.tsx
- Add .dockerignore for client npm caching

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-13 03:23:38 -06:00
parent 3e1134575b
commit 97a166f5aa
47 changed files with 5231 additions and 61 deletions

View File

@@ -0,0 +1,157 @@
'use client';
import { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';
import api from '@/lib/api';
import { PlusIcon, PlayIcon, EditIcon, TrashIcon, FlameIcon } from '@/components/ui/Icons';
import Link from 'next/link';
interface Routine {
id: string;
name: string;
description?: string;
icon?: string;
}
export default function RoutinesPage() {
const router = useRouter();
const [routines, setRoutines] = useState<Routine[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [deleteModal, setDeleteModal] = useState<string | null>(null);
useEffect(() => {
const fetchRoutines = async () => {
try {
const data = await api.routines.list();
setRoutines(data);
} catch (err) {
console.error('Failed to fetch routines:', err);
} finally {
setIsLoading(false);
}
};
fetchRoutines();
}, []);
const handleDelete = async (routineId: string) => {
try {
await api.routines.delete(routineId);
setRoutines(routines.filter(r => r.id !== routineId));
setDeleteModal(null);
} catch (err) {
console.error('Failed to delete routine:', err);
}
};
const handleStartRoutine = async (routineId: string) => {
try {
await api.sessions.start(routineId);
router.push(`/dashboard/routines/${routineId}/run`);
} catch (err) {
console.error('Failed to start routine:', err);
}
};
if (isLoading) {
return (
<div className="flex items-center justify-center min-h-[50vh]">
<div className="w-8 h-8 border-4 border-indigo-500 border-t-transparent rounded-full animate-spin"></div>
</div>
);
}
return (
<div className="p-4 space-y-4">
<div className="flex items-center justify-between">
<h1 className="text-2xl font-bold text-gray-900">Routines</h1>
<Link
href="/dashboard/routines/new"
className="bg-indigo-600 text-white p-2 rounded-full"
>
<PlusIcon size={24} />
</Link>
</div>
{routines.length === 0 ? (
<div className="bg-white rounded-xl p-8 shadow-sm text-center mt-4">
<div className="w-16 h-16 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4">
<FlameIcon className="text-gray-400" size={32} />
</div>
<h3 className="font-semibold text-gray-900 mb-1">No routines yet</h3>
<p className="text-gray-500 text-sm mb-4">Create your first routine to get started</p>
<Link
href="/dashboard/routines/new"
className="inline-block bg-indigo-600 text-white px-4 py-2 rounded-lg font-medium"
>
Create Routine
</Link>
</div>
) : (
<div className="space-y-3">
{routines.map((routine) => (
<div
key={routine.id}
className="bg-white rounded-xl p-4 shadow-sm"
>
<div className="flex items-center gap-3">
<div className="w-12 h-12 bg-gradient-to-br from-indigo-100 to-pink-100 rounded-xl flex items-center justify-center flex-shrink-0">
<span className="text-2xl">{routine.icon || '✨'}</span>
</div>
<div className="flex-1 min-w-0">
<h3 className="font-semibold text-gray-900 truncate">{routine.name}</h3>
{routine.description && (
<p className="text-gray-500 text-sm truncate">{routine.description}</p>
)}
</div>
<div className="flex items-center gap-2">
<button
onClick={() => handleStartRoutine(routine.id)}
className="bg-indigo-600 text-white p-2 rounded-full"
>
<PlayIcon size={18} />
</button>
<Link
href={`/dashboard/routines/${routine.id}`}
className="text-gray-500 p-2"
>
<EditIcon size={18} />
</Link>
<button
onClick={() => setDeleteModal(routine.id)}
className="text-red-500 p-2"
>
<TrashIcon size={18} />
</button>
</div>
</div>
</div>
))}
</div>
)}
{/* Delete Modal */}
{deleteModal && (
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">
<div className="bg-white rounded-2xl p-6 max-w-sm w-full">
<h3 className="text-lg font-semibold text-gray-900 mb-2">Delete Routine?</h3>
<p className="text-gray-500 mb-4">This action cannot be undone.</p>
<div className="flex gap-3">
<button
onClick={() => setDeleteModal(null)}
className="flex-1 px-4 py-2 border border-gray-300 rounded-lg font-medium"
>
Cancel
</button>
<button
onClick={() => handleDelete(deleteModal)}
className="flex-1 px-4 py-2 bg-red-600 text-white rounded-lg font-medium"
>
Delete
</button>
</div>
</div>
</div>
)}
</div>
);
}