Changes
This commit is contained in:
@@ -20,7 +20,7 @@ import { CurriculumEditor } from '@/components/admin/CurriculumEditor';
|
||||
|
||||
interface Product { id: string; title: string; slug: string; type: string; description: string; content: string; meeting_link: string | null; recording_url: string | null; price: number; sale_price: number | null; is_active: boolean; }
|
||||
|
||||
const emptyProduct = { title: '', slug: '', type: 'consulting', description: '', content: '', meeting_link: '', recording_url: '', price: 0, sale_price: null as number | null, is_active: true };
|
||||
const emptyProduct = { title: '', slug: '', type: 'webinar', description: '', content: '', meeting_link: '', recording_url: '', price: 0, sale_price: null as number | null, is_active: true };
|
||||
|
||||
export default function Admin() {
|
||||
const { user, isAdmin, loading: authLoading } = useAuth();
|
||||
@@ -102,7 +102,7 @@ export default function Admin() {
|
||||
<div className="space-y-2"><Label>Title *</Label><Input value={form.title} onChange={(e) => setForm({ ...form, title: e.target.value, slug: generateSlug(e.target.value) })} className="border-2" /></div>
|
||||
<div className="space-y-2"><Label>Slug *</Label><Input value={form.slug} onChange={(e) => setForm({ ...form, slug: e.target.value })} className="border-2" /></div>
|
||||
</div>
|
||||
<div className="space-y-2"><Label>Type</Label><Select value={form.type} onValueChange={(v) => setForm({ ...form, type: v })}><SelectTrigger className="border-2"><SelectValue /></SelectTrigger><SelectContent><SelectItem value="consulting">Consulting</SelectItem><SelectItem value="webinar">Webinar</SelectItem><SelectItem value="bootcamp">Bootcamp</SelectItem></SelectContent></Select></div>
|
||||
<div className="space-y-2"><Label>Type</Label><Select value={form.type} onValueChange={(v) => setForm({ ...form, type: v })}><SelectTrigger className="border-2"><SelectValue /></SelectTrigger><SelectContent><SelectItem value="webinar">Webinar</SelectItem><SelectItem value="bootcamp">Bootcamp</SelectItem></SelectContent></Select></div>
|
||||
<div className="space-y-2"><Label>Description</Label><Textarea value={form.description} onChange={(e) => setForm({ ...form, description: e.target.value })} className="border-2" rows={2} /></div>
|
||||
<div className="space-y-2"><Label>Content (HTML)</Label><Textarea value={form.content} onChange={(e) => setForm({ ...form, content: e.target.value })} className="border-2 font-mono text-sm" rows={6} /></div>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
|
||||
@@ -13,7 +13,7 @@ import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
import { formatIDR } from '@/lib/format';
|
||||
import { Video, Clock, Calendar as CalendarIcon, MessageSquare } from 'lucide-react';
|
||||
import { format, addMinutes, parse, isAfter, isBefore, startOfDay, addDays } from 'date-fns';
|
||||
import { format, addMinutes, parse, isAfter, isBefore, startOfDay, addDays, isSameDay } from 'date-fns';
|
||||
import { id } from 'date-fns/locale';
|
||||
|
||||
interface ConsultingSettings {
|
||||
@@ -106,6 +106,8 @@ export default function ConsultingBooking() {
|
||||
|
||||
const slots: TimeSlot[] = [];
|
||||
const duration = settings.consulting_block_duration_minutes;
|
||||
const now = new Date();
|
||||
const isToday = isSameDay(selectedDate, now);
|
||||
|
||||
for (const wh of dayWorkhours) {
|
||||
let current = parse(wh.start_time, 'HH:mm:ss', selectedDate);
|
||||
@@ -122,10 +124,13 @@ export default function ConsultingBooking() {
|
||||
return !(slotEnd <= csStart || slotStart >= csEnd);
|
||||
});
|
||||
|
||||
// Check if slot is in the past for today
|
||||
const isPassed = isToday && isBefore(current, now);
|
||||
|
||||
slots.push({
|
||||
start: slotStart,
|
||||
end: slotEnd,
|
||||
available: !isConflict,
|
||||
available: !isConflict && !isPassed,
|
||||
});
|
||||
|
||||
current = addMinutes(current, duration);
|
||||
|
||||
@@ -32,13 +32,12 @@ interface Product {
|
||||
price: number;
|
||||
sale_price: number | null;
|
||||
is_active: boolean;
|
||||
consulting_duration_minutes: number | null;
|
||||
}
|
||||
|
||||
const emptyProduct = {
|
||||
title: '',
|
||||
slug: '',
|
||||
type: 'consulting',
|
||||
type: 'webinar',
|
||||
description: '',
|
||||
content: '',
|
||||
meeting_link: '',
|
||||
@@ -46,7 +45,6 @@ const emptyProduct = {
|
||||
price: 0,
|
||||
sale_price: null as number | null,
|
||||
is_active: true,
|
||||
consulting_duration_minutes: 60,
|
||||
};
|
||||
|
||||
export default function AdminProducts() {
|
||||
@@ -89,7 +87,6 @@ export default function AdminProducts() {
|
||||
price: product.price,
|
||||
sale_price: product.sale_price,
|
||||
is_active: product.is_active,
|
||||
consulting_duration_minutes: product.consulting_duration_minutes || 60,
|
||||
});
|
||||
setActiveTab('details');
|
||||
setDialogOpen(true);
|
||||
@@ -119,7 +116,6 @@ export default function AdminProducts() {
|
||||
price: form.price,
|
||||
sale_price: form.sale_price || null,
|
||||
is_active: form.is_active,
|
||||
consulting_duration_minutes: form.type === 'consulting' ? form.consulting_duration_minutes : null,
|
||||
};
|
||||
|
||||
if (editingProduct) {
|
||||
@@ -246,23 +242,11 @@ export default function AdminProducts() {
|
||||
<Select value={form.type} onValueChange={(v) => setForm({ ...form, type: v })}>
|
||||
<SelectTrigger className="border-2"><SelectValue /></SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="consulting">Consulting</SelectItem>
|
||||
<SelectItem value="webinar">Webinar</SelectItem>
|
||||
<SelectItem value="bootcamp">Bootcamp</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
{form.type === 'consulting' && (
|
||||
<div className="space-y-2">
|
||||
<Label>Durasi Konsultasi (menit)</Label>
|
||||
<Input
|
||||
type="number"
|
||||
value={form.consulting_duration_minutes || 60}
|
||||
onChange={(e) => setForm({ ...form, consulting_duration_minutes: parseInt(e.target.value) || 60 })}
|
||||
className="border-2"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className="space-y-2">
|
||||
<Label>Deskripsi</Label>
|
||||
<RichTextEditor content={form.description} onChange={(v) => setForm({ ...form, description: v })} />
|
||||
|
||||
Reference in New Issue
Block a user