Initial commit

This commit is contained in:
2026-04-24 08:02:13 +02:00
commit 867c06295c
76 changed files with 10573 additions and 0 deletions
@@ -0,0 +1,52 @@
import React from 'react';
import { useSleepSession } from '../../hooks/useSleepSession';
interface SleepButtonProps {
time: string;
}
const SleepButton: React.FC<SleepButtonProps> = ({ time }) => {
const { activeSession, createSession, endSession, isCreating, isEnding } = useSleepSession();
const isSleeping = !!activeSession;
console.log('DEBUG: SleepButton State:', {
activeSession,
isSleeping,
isCreating,
isEnding
});
const handleClick = async () => {
try {
if (isSleeping && activeSession?.id) {
await endSession({ sessionId: activeSession.id, endTime: time });
} else {
await createSession({ start_time: time });
}
} catch (error: any) {
console.error('Failed to update sleep session:', error?.message || error);
}
};
return (
<button
onClick={handleClick}
disabled={isCreating || isEnding}
className={`w-full py-6 px-8 rounded-2xl text-2xl font-bold shadow-lg transition-all active:scale-95 ${
isSleeping
? 'bg-amber-500 text-white hover:bg-amber-600'
: 'bg-blue-700 text-white hover:bg-blue-800'
} ${isCreating || isEnding ? 'opacity-50 cursor-not-allowed' : ''}`}
>
{isCreating || isEnding ? (
<span className="animate-pulse">Processing...</span>
) : isSleeping ? (
'Stop Sleep'
) : (
'Start Sleep'
)}
</button>
);
};
export default SleepButton;