141 lines
4.4 KiB
TypeScript
141 lines
4.4 KiB
TypeScript
/**
|
|
* File: page.tsx
|
|
* Created by: AI Assistant
|
|
* Date: 2025-11-29
|
|
* Purpose: Create assignment page for kreatiVortex platform
|
|
* Part of: kreatiVortex - Platform Pembelajaran Tari Online
|
|
*/
|
|
|
|
'use client';
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
import { useRouter, useSearchParams } from 'next/navigation';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Input } from '@/components/ui/input';
|
|
import { Label } from '@/components/ui/label';
|
|
import { Textarea } from '@/components/ui/textarea';
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
|
|
|
export default function NewAssignmentPage() {
|
|
const router = useRouter();
|
|
const searchParams = useSearchParams();
|
|
const classId = searchParams.get('classId');
|
|
const [loading, setLoading] = useState(false);
|
|
const [formData, setFormData] = useState({
|
|
title: '',
|
|
description: '',
|
|
classId: '',
|
|
dueDate: '',
|
|
maxScore: 100,
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (classId) {
|
|
setFormData(prev => ({ ...prev, classId }));
|
|
}
|
|
}, [classId]);
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault();
|
|
setLoading(true);
|
|
|
|
// Simulate API call
|
|
setTimeout(() => {
|
|
setLoading(false);
|
|
router.push('/dashboard/assignments');
|
|
}, 1000);
|
|
};
|
|
|
|
return (
|
|
<div className="max-w-2xl mx-auto">
|
|
<div className="mb-6">
|
|
<h1 className="text-2xl font-bold text-white">Buat Tugas Baru</h1>
|
|
<p className="text-gray-400">Berikan tugas kepada siswa untuk evaluasi pembelajaran</p>
|
|
</div>
|
|
|
|
<form onSubmit={handleSubmit} className="space-y-6">
|
|
<div className="space-y-2">
|
|
<Label htmlFor="title" className="text-gray-300">
|
|
Judul Tugas
|
|
</Label>
|
|
<Input
|
|
type="text"
|
|
id="title"
|
|
value={formData.title}
|
|
onChange={(e) => setFormData({ ...formData, title: e.target.value })}
|
|
required
|
|
placeholder="Contoh: Analisis Gerakan Tari Piring"
|
|
className="bg-white/10 border-white/20 text-white placeholder:text-gray-400"
|
|
/>
|
|
</div>
|
|
|
|
<div className="space-y-2">
|
|
<Label htmlFor="classId" className="text-gray-300">
|
|
Kelas
|
|
</Label>
|
|
<Select
|
|
value={formData.classId}
|
|
onValueChange={(value) => setFormData({ ...formData, classId: value })}
|
|
>
|
|
<SelectTrigger className="bg-white/10 border-white/20 text-white">
|
|
<SelectValue placeholder="Pilih Kelas" />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
<SelectItem value="asdf">Pilih Kelas</SelectItem>
|
|
<SelectItem value="1">Tari Tradisional Indonesia 101</SelectItem>
|
|
<SelectItem value="2">Sejarah Tari</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
|
|
<div className="space-y-2">
|
|
<Label htmlFor="dueDate" className="text-gray-300">
|
|
Tenggat Waktu
|
|
</Label>
|
|
<Input
|
|
type="datetime-local"
|
|
id="dueDate"
|
|
value={formData.dueDate}
|
|
onChange={(e) => setFormData({ ...formData, dueDate: e.target.value })}
|
|
required
|
|
className="bg-white/10 border-white/20 text-white"
|
|
/>
|
|
</div>
|
|
|
|
<div className="space-y-2">
|
|
<Label htmlFor="description" className="text-gray-300">
|
|
Deskripsi Tugas
|
|
</Label>
|
|
<Textarea
|
|
id="description"
|
|
rows={6}
|
|
value={formData.description}
|
|
onChange={(e) => setFormData({ ...formData, description: e.target.value })}
|
|
required
|
|
placeholder="Jelaskan detail tugas yang harus dikerjakan..."
|
|
className="bg-white/10 border-white/20 text-white placeholder:text-gray-400"
|
|
/>
|
|
</div>
|
|
|
|
<div className="pt-4 flex justify-end space-x-3">
|
|
<Button
|
|
type="button"
|
|
variant="ghost"
|
|
onClick={() => router.back()}
|
|
disabled={loading}
|
|
className="text-gray-300 hover:text-white"
|
|
>
|
|
Batal
|
|
</Button>
|
|
<Button
|
|
type="submit"
|
|
disabled={loading}
|
|
className="bg-gold-500 hover:bg-gold-600 text-navy-900"
|
|
>
|
|
{loading ? 'Menyimpan...' : 'Buat Tugas'}
|
|
</Button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
);
|
|
} |