mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 11:06:29 +00:00
c9dc6a5e51
Replace the event and task lists with a monthly calendar grid, calendar filters, and event detail view. Add multi-calendar event fetching and route create, edit, and delete actions to the selected calendar.
112 lines
3.3 KiB
TypeScript
112 lines
3.3 KiB
TypeScript
'use client';
|
|
|
|
import { Calendar as CalendarIcon, ExternalLink, RefreshCw, Plus, CheckSquare } from 'lucide-react';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Badge } from '@/components/ui/badge';
|
|
|
|
interface CalendarHeaderProps {
|
|
calendarId?: string;
|
|
serviceAccountEmail?: string;
|
|
onRefresh: () => void;
|
|
onAddEvent: () => void;
|
|
onAddTask?: () => void;
|
|
isRefreshing?: boolean;
|
|
}
|
|
|
|
export default function CalendarHeader({
|
|
calendarId,
|
|
serviceAccountEmail,
|
|
onRefresh,
|
|
onAddEvent,
|
|
onAddTask,
|
|
isRefreshing = false,
|
|
}: CalendarHeaderProps) {
|
|
const googleCalendarWebUrl = calendarId
|
|
? `https://calendar.google.com/calendar/u/0/r?cid=${encodeURIComponent(calendarId)}`
|
|
: 'https://calendar.google.com';
|
|
|
|
return (
|
|
<div className="flex flex-col gap-4 pb-4 border-b border-zinc-200 dark:border-zinc-800">
|
|
<div className="flex flex-col lg:flex-row lg:items-center justify-between gap-4">
|
|
{/* Title & Info */}
|
|
<div className="space-y-1.5">
|
|
<div className="flex items-center gap-2.5">
|
|
<div className="p-2 rounded-lg bg-zinc-100 dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100">
|
|
<CalendarIcon className="size-5" />
|
|
</div>
|
|
<div>
|
|
<h1 className="text-xl md:text-2xl font-bold tracking-tight text-zinc-900 dark:text-zinc-100">
|
|
Google Calendar & Task Testing
|
|
</h1>
|
|
<p className="text-xs md:text-sm text-zinc-500 dark:text-zinc-400">
|
|
Integrasi Server-to-Server (Single System OAuth2 Refresh Token) • Tanpa OAuth Login Pengguna
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
{/* Badges Info */}
|
|
<div className="flex flex-wrap items-center gap-2 pt-1 text-xs">
|
|
<span className="text-zinc-500 font-medium">Koneksi Aktif:</span>
|
|
{calendarId && (
|
|
<Badge variant="outline" className="font-mono text-[11px] max-w-[280px] sm:max-w-none truncate">
|
|
Cal: {calendarId}
|
|
</Badge>
|
|
)}
|
|
{serviceAccountEmail && (
|
|
<Badge variant="outline" className="font-mono text-[11px] max-w-[260px] sm:max-w-none truncate">
|
|
Auth: {serviceAccountEmail}
|
|
</Badge>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Action Buttons */}
|
|
<div className="flex flex-wrap items-center gap-2.5">
|
|
<Button
|
|
variant="outline"
|
|
size="sm"
|
|
onClick={onRefresh}
|
|
disabled={isRefreshing}
|
|
className="h-9 px-3"
|
|
>
|
|
<RefreshCw className={`size-3.5 mr-1.5 ${isRefreshing ? 'animate-spin' : ''}`} />
|
|
<span>Muat Ulang</span>
|
|
</Button>
|
|
|
|
<Button
|
|
asChild
|
|
variant="outline"
|
|
size="sm"
|
|
className="h-9 px-3"
|
|
>
|
|
<a href={googleCalendarWebUrl} target="_blank" rel="noopener noreferrer">
|
|
<span>Buka Google Calendar</span>
|
|
<ExternalLink className="size-3.5 ml-1.5" />
|
|
</a>
|
|
</Button>
|
|
|
|
{onAddTask && (
|
|
<Button
|
|
size="sm"
|
|
variant="outline"
|
|
onClick={onAddTask}
|
|
className="h-9 px-3 border-emerald-600 text-emerald-700 dark:text-emerald-400 dark:border-emerald-700 hover:bg-emerald-50 dark:hover:bg-emerald-950/40"
|
|
>
|
|
<CheckSquare className="size-3.5 mr-1.5" />
|
|
<span>Tambah Task</span>
|
|
</Button>
|
|
)}
|
|
|
|
<Button
|
|
size="sm"
|
|
onClick={onAddEvent}
|
|
>
|
|
<Plus className="size-3.5 mr-1.5" />
|
|
<span>Tambah Event</span>
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|