Add account hierarchy framework with migrations, RLS policies, and UI components
This commit is contained in:
@@ -2,15 +2,15 @@ import Link from 'next/link';
|
||||
|
||||
import { ArrowLeft, ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
|
||||
import { createCourseManagementApi } from '@kit/course-management/api';
|
||||
import { formatDate } from '@kit/shared/dates';
|
||||
import { getSupabaseServerClient } from '@kit/supabase/server-client';
|
||||
import { Badge } from '@kit/ui/badge';
|
||||
import { Button } from '@kit/ui/button';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@kit/ui/card';
|
||||
|
||||
import { createCourseManagementApi } from '@kit/course-management/api';
|
||||
|
||||
import { CmsPageShell } from '~/components/cms-page-shell';
|
||||
import { AccountNotFound } from '~/components/account-not-found';
|
||||
import { CmsPageShell } from '~/components/cms-page-shell';
|
||||
|
||||
interface PageProps {
|
||||
params: Promise<{ account: string }>;
|
||||
@@ -86,7 +86,11 @@ export default async function CourseCalendarPage({ params }: PageProps) {
|
||||
}
|
||||
|
||||
// Build calendar grid
|
||||
const cells: Array<{ day: number | null; hasCourse: boolean; isToday: boolean }> = [];
|
||||
const cells: Array<{
|
||||
day: number | null;
|
||||
hasCourse: boolean;
|
||||
isToday: boolean;
|
||||
}> = [];
|
||||
|
||||
for (let i = 0; i < firstWeekday; i++) {
|
||||
cells.push({ day: null, hasCourse: false, isToday: false });
|
||||
@@ -96,7 +100,10 @@ export default async function CourseCalendarPage({ params }: PageProps) {
|
||||
cells.push({
|
||||
day: d,
|
||||
hasCourse: courseDates.has(d),
|
||||
isToday: d === now.getDate() && month === now.getMonth() && year === now.getFullYear(),
|
||||
isToday:
|
||||
d === now.getDate() &&
|
||||
month === now.getMonth() &&
|
||||
year === now.getFullYear(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -120,9 +127,7 @@ export default async function CourseCalendarPage({ params }: PageProps) {
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
</Button>
|
||||
</Link>
|
||||
<p className="text-muted-foreground">
|
||||
Kurstermine im Überblick
|
||||
</p>
|
||||
<p className="text-muted-foreground">Kurstermine im Überblick</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -143,11 +148,11 @@ export default async function CourseCalendarPage({ params }: PageProps) {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{/* Weekday Header */}
|
||||
<div className="grid grid-cols-7 gap-1 mb-1">
|
||||
<div className="mb-1 grid grid-cols-7 gap-1">
|
||||
{WEEKDAYS.map((day) => (
|
||||
<div
|
||||
key={day}
|
||||
className="text-center text-xs font-medium text-muted-foreground py-2"
|
||||
className="text-muted-foreground py-2 text-center text-xs font-medium"
|
||||
>
|
||||
{day}
|
||||
</div>
|
||||
@@ -163,15 +168,15 @@ export default async function CourseCalendarPage({ params }: PageProps) {
|
||||
cell.day === null
|
||||
? 'bg-transparent'
|
||||
: cell.hasCourse
|
||||
? 'bg-emerald-500/15 text-emerald-700 dark:text-emerald-400 font-semibold'
|
||||
? 'bg-emerald-500/15 font-semibold text-emerald-700 dark:text-emerald-400'
|
||||
: 'bg-muted/30 hover:bg-muted/50'
|
||||
} ${cell.isToday ? 'ring-2 ring-primary ring-offset-1' : ''}`}
|
||||
} ${cell.isToday ? 'ring-primary ring-2 ring-offset-1' : ''}`}
|
||||
>
|
||||
{cell.day !== null && (
|
||||
<>
|
||||
<span>{cell.day}</span>
|
||||
{cell.hasCourse && (
|
||||
<span className="absolute bottom-1 left-1/2 -translate-x-1/2 h-1.5 w-1.5 rounded-full bg-emerald-500" />
|
||||
<span className="absolute bottom-1 left-1/2 h-1.5 w-1.5 -translate-x-1/2 rounded-full bg-emerald-500" />
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
@@ -180,17 +185,17 @@ export default async function CourseCalendarPage({ params }: PageProps) {
|
||||
</div>
|
||||
|
||||
{/* Legend */}
|
||||
<div className="mt-4 flex items-center gap-4 text-xs text-muted-foreground">
|
||||
<div className="text-muted-foreground mt-4 flex items-center gap-4 text-xs">
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="inline-block h-3 w-3 rounded-sm bg-emerald-500/15" />
|
||||
Kurstag
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="inline-block h-3 w-3 rounded-sm bg-muted/30" />
|
||||
<span className="bg-muted/30 inline-block h-3 w-3 rounded-sm" />
|
||||
Frei
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<span className="inline-block h-3 w-3 rounded-sm ring-2 ring-primary" />
|
||||
<span className="ring-primary inline-block h-3 w-3 rounded-sm ring-2" />
|
||||
Heute
|
||||
</div>
|
||||
</div>
|
||||
@@ -204,7 +209,7 @@ export default async function CourseCalendarPage({ params }: PageProps) {
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{activeCourses.length === 0 ? (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
<p className="text-muted-foreground text-sm">
|
||||
Keine aktiven Kurse in diesem Monat.
|
||||
</p>
|
||||
) : (
|
||||
@@ -221,18 +226,19 @@ export default async function CourseCalendarPage({ params }: PageProps) {
|
||||
>
|
||||
{String(course.name)}
|
||||
</Link>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{course.start_date
|
||||
? new Date(String(course.start_date)).toLocaleDateString('de-DE')
|
||||
: '—'}{' '}
|
||||
–{' '}
|
||||
{course.end_date
|
||||
? new Date(String(course.end_date)).toLocaleDateString('de-DE')
|
||||
: '—'}
|
||||
<p className="text-muted-foreground text-xs">
|
||||
{formatDate(course.start_date as string)} –{' '}
|
||||
{formatDate(course.end_date as string)}
|
||||
</p>
|
||||
</div>
|
||||
<Badge variant={String(course.status) === 'running' ? 'info' : 'default'}>
|
||||
{String(course.status) === 'running' ? 'Laufend' : 'Offen'}
|
||||
<Badge
|
||||
variant={
|
||||
String(course.status) === 'running' ? 'info' : 'default'
|
||||
}
|
||||
>
|
||||
{String(course.status) === 'running'
|
||||
? 'Laufend'
|
||||
: 'Offen'}
|
||||
</Badge>
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user