Compare commits
10 Commits
d5de503f86
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd542259a9 | ||
|
|
721e003253 | ||
|
|
cd29713bca | ||
|
|
255ec6fd25 | ||
|
|
dbca26f3ad | ||
|
|
091435c8b4 | ||
|
|
6880c738f9 | ||
|
|
b7f98ed3ad | ||
|
|
9bb5ec46ce | ||
|
|
8fa560cd5e |
BIN
prisma/dev.db
BIN
prisma/dev.db
Binary file not shown.
@@ -19,11 +19,13 @@ model Branch {
|
||||
name String
|
||||
address String?
|
||||
phone String?
|
||||
instructors Instructor[] // Implicit many-to-many
|
||||
classes DanceClass[]
|
||||
lessons Lesson[]
|
||||
hallCount Int? @default(1)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
classes DanceClass[]
|
||||
lessons Lesson[]
|
||||
students Student[]
|
||||
instructors Instructor[] @relation("BranchToInstructor")
|
||||
}
|
||||
|
||||
model Instructor {
|
||||
@@ -31,41 +33,42 @@ model Instructor {
|
||||
name String
|
||||
bio String?
|
||||
phone String?
|
||||
branches Branch[] // Implicit many-to-many
|
||||
classes DanceClass[]
|
||||
lessons Lesson[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
classes DanceClass[]
|
||||
lessons Lesson[]
|
||||
branches Branch[] @relation("BranchToInstructor")
|
||||
}
|
||||
|
||||
model DanceClass {
|
||||
id String @id @default(uuid())
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
description String?
|
||||
branchId String
|
||||
branch Branch @relation(fields: [branchId], references: [id])
|
||||
instructorId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
instructor Instructor? @relation(fields: [instructorId], references: [id])
|
||||
lessons Lesson[]
|
||||
branch Branch @relation(fields: [branchId], references: [id])
|
||||
fees Fee[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
lessons Lesson[]
|
||||
}
|
||||
|
||||
model Lesson {
|
||||
id String @id @default(uuid())
|
||||
name String? // Optional name e.g. "Special Workshop"
|
||||
id String @id @default(uuid())
|
||||
name String?
|
||||
startTime DateTime
|
||||
endTime DateTime
|
||||
type String // GROUP, PRIVATE
|
||||
type String
|
||||
hallNumber Int @default(1)
|
||||
branchId String
|
||||
branch Branch @relation(fields: [branchId], references: [id])
|
||||
instructorId String
|
||||
instructor Instructor @relation(fields: [instructorId], references: [id])
|
||||
classId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
class DanceClass? @relation(fields: [classId], references: [id])
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
instructor Instructor @relation(fields: [instructorId], references: [id])
|
||||
branch Branch @relation(fields: [branchId], references: [id])
|
||||
}
|
||||
|
||||
model Fee {
|
||||
@@ -73,9 +76,21 @@ model Fee {
|
||||
name String
|
||||
amount Float
|
||||
currency String @default("TRY")
|
||||
type String // MONTHLY, PER_LESSON, PACKAGE
|
||||
type String
|
||||
classId String?
|
||||
class DanceClass? @relation(fields: [classId], references: [id])
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
class DanceClass? @relation(fields: [classId], references: [id])
|
||||
}
|
||||
|
||||
model Student {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
email String?
|
||||
phone String
|
||||
birthDate DateTime
|
||||
branchId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
branch Branch? @relation(fields: [branchId], references: [id])
|
||||
}
|
||||
|
||||
@@ -6,16 +6,20 @@ import styles from './branches.module.css';
|
||||
export function AddBranchForm() {
|
||||
const [name, setName] = useState('');
|
||||
const [address, setAddress] = useState('');
|
||||
const [phone, setPhone] = useState('');
|
||||
const [hallCount, setHallCount] = useState('1');
|
||||
const router = useRouter();
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
await fetch('/api/branches', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name, address }),
|
||||
body: JSON.stringify({ name, address, phone, hallCount: parseInt(hallCount) }),
|
||||
});
|
||||
setName('');
|
||||
setAddress('');
|
||||
setPhone('');
|
||||
setHallCount('1');
|
||||
router.refresh();
|
||||
};
|
||||
|
||||
@@ -25,10 +29,18 @@ export function AddBranchForm() {
|
||||
<label>Şube Adı</label>
|
||||
<input value={name} onChange={e => setName(e.target.value)} className={styles.input} required />
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Telefon</label>
|
||||
<input value={phone} onChange={e => setPhone(e.target.value)} className={styles.input} />
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Adres</label>
|
||||
<input value={address} onChange={e => setAddress(e.target.value)} className={styles.input} />
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Salon Sayısı</label>
|
||||
<input type="number" min="1" value={hallCount} onChange={e => setHallCount(e.target.value)} className={styles.input} />
|
||||
</div>
|
||||
<button type="submit" className={styles.btn}>Ekle</button>
|
||||
</form>
|
||||
);
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
'use client';
|
||||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import styles from './branches.module.css';
|
||||
|
||||
export function BranchList({ branches }: { branches: any[] }) {
|
||||
const router = useRouter();
|
||||
const [editingId, setEditingId] = useState<string | null>(null);
|
||||
const [editForm, setEditForm] = useState<any>(null);
|
||||
|
||||
const handleDelete = async (id: string) => {
|
||||
if (!confirm('Silmek istediğinize emin misiniz?')) return;
|
||||
@@ -11,15 +14,91 @@ export function BranchList({ branches }: { branches: any[] }) {
|
||||
router.refresh();
|
||||
};
|
||||
|
||||
const startEdit = (branch: any) => {
|
||||
setEditingId(branch.id);
|
||||
setEditForm({
|
||||
name: branch.name,
|
||||
phone: branch.phone || '',
|
||||
address: branch.address || '',
|
||||
hallCount: branch.hallCount?.toString() || '1'
|
||||
});
|
||||
};
|
||||
|
||||
const handleUpdate = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const res = await fetch(`/api/branches/${editingId}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(editForm),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
setEditingId(null);
|
||||
router.refresh();
|
||||
} else {
|
||||
alert('Güncelleme başarısız oldu.');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.list}>
|
||||
{branches.map(b => (
|
||||
<div key={b.id} className={styles.card}>
|
||||
<div>
|
||||
<h3>{b.name}</h3>
|
||||
<p>{b.address}</p>
|
||||
</div>
|
||||
<button onClick={() => handleDelete(b.id)} className={`${styles.btn} ${styles.btnDelete}`}>Sil</button>
|
||||
{editingId === b.id ? (
|
||||
<form onSubmit={handleUpdate} style={{ width: '100%', display: 'flex', gap: '1rem', flexWrap: 'wrap', alignItems: 'flex-end' }}>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Şube Adı</label>
|
||||
<input
|
||||
value={editForm.name}
|
||||
onChange={e => setEditForm({ ...editForm, name: e.target.value })}
|
||||
className={styles.input}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Telefon</label>
|
||||
<input
|
||||
value={editForm.phone}
|
||||
onChange={e => setEditForm({ ...editForm, phone: e.target.value })}
|
||||
className={styles.input}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Adres</label>
|
||||
<input
|
||||
value={editForm.address}
|
||||
onChange={e => setEditForm({ ...editForm, address: e.target.value })}
|
||||
className={styles.input}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Salon Sayısı</label>
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
value={editForm.hallCount}
|
||||
onChange={e => setEditForm({ ...editForm, hallCount: e.target.value })}
|
||||
className={styles.input}
|
||||
/>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
||||
<button type="submit" className={styles.btn} style={{ background: '#2e7d32' }}>Kaydet</button>
|
||||
<button type="button" onClick={() => setEditingId(null)} className={styles.btn}>İptal</button>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<>
|
||||
<div>
|
||||
<h3>{b.name}</h3>
|
||||
<p>{b.phone ? `Tel: ${b.phone}` : 'Telefon yok'} | {b.address || 'Adres yok'}</p>
|
||||
<small>Salon Sayısı: {b.hallCount || 1}</small>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
||||
<button onClick={() => startEdit(b)} className={styles.btn} style={{ background: '#ffa000' }}>Düzenle</button>
|
||||
<button onClick={() => handleDelete(b.id)} className={`${styles.btn} ${styles.btnDelete}`}>Sil</button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
'use client';
|
||||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import styles from '../branches/branches.module.css';
|
||||
|
||||
export function ClassList({ classes }: { classes: any[] }) {
|
||||
export function ClassList({
|
||||
classes,
|
||||
branches,
|
||||
instructors
|
||||
}: {
|
||||
classes: any[],
|
||||
branches: any[],
|
||||
instructors: any[]
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [editingId, setEditingId] = useState<string | null>(null);
|
||||
const [editForm, setEditForm] = useState<any>(null);
|
||||
|
||||
const handleDelete = async (id: string) => {
|
||||
if (!confirm('Silmek istediğinize emin misiniz?')) return;
|
||||
@@ -11,16 +22,101 @@ export function ClassList({ classes }: { classes: any[] }) {
|
||||
router.refresh();
|
||||
};
|
||||
|
||||
const startEdit = (c: any) => {
|
||||
setEditingId(c.id);
|
||||
setEditForm({
|
||||
name: c.name,
|
||||
description: c.description || '',
|
||||
branchId: c.branchId,
|
||||
instructorId: c.instructorId || ''
|
||||
});
|
||||
};
|
||||
|
||||
const handleUpdate = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const res = await fetch(`/api/classes/${editingId}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(editForm),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
setEditingId(null);
|
||||
router.refresh();
|
||||
} else {
|
||||
alert('Güncelleme başarısız oldu.');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.list}>
|
||||
{classes.map(c => (
|
||||
<div key={c.id} className={styles.card}>
|
||||
<div>
|
||||
<h3>{c.name}</h3>
|
||||
<p>Şube: {c.branch?.name}</p>
|
||||
{c.instructor && <p>Hoca: {c.instructor.name}</p>}
|
||||
</div>
|
||||
<button onClick={() => handleDelete(c.id)} className={`${styles.btn} ${styles.btnDelete}`}>Sil</button>
|
||||
{editingId === c.id ? (
|
||||
<form onSubmit={handleUpdate} style={{ width: '100%', display: 'flex', gap: '1rem', flexWrap: 'wrap', alignItems: 'flex-end' }}>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Sınıf Adı</label>
|
||||
<input
|
||||
value={editForm.name}
|
||||
onChange={e => setEditForm({ ...editForm, name: e.target.value })}
|
||||
className={styles.input}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Açıklama</label>
|
||||
<input
|
||||
value={editForm.description}
|
||||
onChange={e => setEditForm({ ...editForm, description: e.target.value })}
|
||||
className={styles.input}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Şube</label>
|
||||
<select
|
||||
value={editForm.branchId}
|
||||
onChange={e => setEditForm({ ...editForm, branchId: e.target.value })}
|
||||
className={styles.input}
|
||||
required
|
||||
>
|
||||
<option value="">Şube Seçiniz</option>
|
||||
{branches.map(b => (
|
||||
<option key={b.id} value={b.id}>{b.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Eğitmen</label>
|
||||
<select
|
||||
value={editForm.instructorId}
|
||||
onChange={e => setEditForm({ ...editForm, instructorId: e.target.value })}
|
||||
className={styles.input}
|
||||
>
|
||||
<option value="">Eğitmen Seçiniz</option>
|
||||
{instructors.map(i => (
|
||||
<option key={i.id} value={i.id}>{i.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
||||
<button type="submit" className={styles.btn} style={{ background: '#2e7d32' }}>Kaydet</button>
|
||||
<button type="button" onClick={() => setEditingId(null)} className={styles.btn}>İptal</button>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<>
|
||||
<div>
|
||||
<h3>{c.name}</h3>
|
||||
<p>Şube: {c.branch?.name}</p>
|
||||
{c.instructor && <p>Hoca: {c.instructor.name}</p>}
|
||||
<small>{c.description}</small>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
||||
<button onClick={() => startEdit(c)} className={styles.btn} style={{ background: '#ffa000' }}>Düzenle</button>
|
||||
<button onClick={() => handleDelete(c.id)} className={`${styles.btn} ${styles.btnDelete}`}>Sil</button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -4,9 +4,11 @@ import { ClassList } from './ClassList';
|
||||
import styles from '../branches/branches.module.css';
|
||||
|
||||
export default async function Page() {
|
||||
const classes = await prisma.danceClass.findMany({ include: { branch: true, instructor: true }, orderBy: { createdAt: 'desc' } });
|
||||
const branches = await prisma.branch.findMany();
|
||||
const instructors = await prisma.instructor.findMany();
|
||||
const [classes, branches, instructors] = await Promise.all([
|
||||
prisma.danceClass.findMany({ include: { branch: true, instructor: true }, orderBy: { createdAt: 'desc' } }),
|
||||
prisma.branch.findMany({ select: { id: true, name: true } }),
|
||||
prisma.instructor.findMany({ select: { id: true, name: true } })
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
@@ -14,7 +16,7 @@ export default async function Page() {
|
||||
<h1>Sınıflar</h1>
|
||||
</div>
|
||||
<AddClassForm branches={branches} instructors={instructors} />
|
||||
<ClassList classes={classes} />
|
||||
<ClassList classes={classes} branches={branches} instructors={instructors} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
'use client';
|
||||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import styles from '../branches/branches.module.css';
|
||||
|
||||
export function InstructorList({ instructors }: { instructors: any[] }) {
|
||||
const router = useRouter();
|
||||
const [editingId, setEditingId] = useState<string | null>(null);
|
||||
const [editForm, setEditForm] = useState<any>(null);
|
||||
|
||||
const handleDelete = async (id: string) => {
|
||||
if (!confirm('Silmek istediğinize emin misiniz?')) return;
|
||||
@@ -11,15 +14,79 @@ export function InstructorList({ instructors }: { instructors: any[] }) {
|
||||
router.refresh();
|
||||
};
|
||||
|
||||
const startEdit = (instructor: any) => {
|
||||
setEditingId(instructor.id);
|
||||
setEditForm({
|
||||
name: instructor.name,
|
||||
phone: instructor.phone || '',
|
||||
bio: instructor.bio || ''
|
||||
});
|
||||
};
|
||||
|
||||
const handleUpdate = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const res = await fetch(`/api/instructors/${editingId}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(editForm),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
setEditingId(null);
|
||||
router.refresh();
|
||||
} else {
|
||||
alert('Güncelleme başarısız oldu.');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.list}>
|
||||
{instructors.map(i => (
|
||||
<div key={i.id} className={styles.card}>
|
||||
<div>
|
||||
<h3>{i.name}</h3>
|
||||
<p>{i.bio}</p>
|
||||
</div>
|
||||
<button onClick={() => handleDelete(i.id)} className={`${styles.btn} ${styles.btnDelete}`}>Sil</button>
|
||||
{editingId === i.id ? (
|
||||
<form onSubmit={handleUpdate} style={{ width: '100%', display: 'flex', gap: '1rem', flexWrap: 'wrap', alignItems: 'flex-end' }}>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Hoca Adı</label>
|
||||
<input
|
||||
value={editForm.name}
|
||||
onChange={e => setEditForm({ ...editForm, name: e.target.value })}
|
||||
className={styles.input}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Telefon</label>
|
||||
<input
|
||||
value={editForm.phone}
|
||||
onChange={e => setEditForm({ ...editForm, phone: e.target.value })}
|
||||
className={styles.input}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Biyo</label>
|
||||
<input
|
||||
value={editForm.bio}
|
||||
onChange={e => setEditForm({ ...editForm, bio: e.target.value })}
|
||||
className={styles.input}
|
||||
/>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
||||
<button type="submit" className={styles.btn} style={{ background: '#2e7d32' }}>Kaydet</button>
|
||||
<button type="button" onClick={() => setEditingId(null)} className={styles.btn}>İptal</button>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<>
|
||||
<div>
|
||||
<h3>{i.name} {i.phone && <small>({i.phone})</small>}</h3>
|
||||
<p>{i.bio || 'Biyografi bulunmuyor'}</p>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
||||
<button onClick={() => startEdit(i)} className={styles.btn} style={{ background: '#ffa000' }}>Düzenle</button>
|
||||
<button onClick={() => handleDelete(i.id)} className={`${styles.btn} ${styles.btnDelete}`}>Sil</button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
69
src/app/admin/register/RegisterForm.tsx
Normal file
69
src/app/admin/register/RegisterForm.tsx
Normal file
@@ -0,0 +1,69 @@
|
||||
'use client';
|
||||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import styles from '../branches/branches.module.css';
|
||||
|
||||
export function RegisterForm({ branches }: { branches: any[] }) {
|
||||
const [formData, setFormData] = useState({
|
||||
name: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
birthDate: '',
|
||||
branchId: ''
|
||||
});
|
||||
const router = useRouter();
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const res = await fetch('/api/register', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(formData),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
setFormData({ name: '', email: '', phone: '', birthDate: '', branchId: '' });
|
||||
router.refresh();
|
||||
}
|
||||
};
|
||||
|
||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement>) => {
|
||||
setFormData({ ...formData, [e.target.name]: e.target.value });
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className={styles.form}>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Ad Soyad</label>
|
||||
<input name="name" value={formData.name} onChange={handleChange} className={styles.input} required placeholder="Adınız" />
|
||||
</div>
|
||||
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Email</label>
|
||||
<input name="email" type="email" value={formData.email} onChange={handleChange} className={styles.input} placeholder="ornek@email.com" />
|
||||
</div>
|
||||
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Telefon</label>
|
||||
<input name="phone" type="tel" value={formData.phone} onChange={handleChange} className={styles.input} required placeholder="5XX XXX XX XX" />
|
||||
</div>
|
||||
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Doğum Tarihi</label>
|
||||
<input name="birthDate" type="date" value={formData.birthDate} onChange={handleChange} className={styles.input} required />
|
||||
</div>
|
||||
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Şube</label>
|
||||
<select name="branchId" value={formData.branchId} onChange={handleChange} className={styles.input}>
|
||||
<option value="">Seçiniz</option>
|
||||
{branches.map(b => (
|
||||
<option key={b.id} value={b.id}>{b.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="submit" className={styles.btn}>Kaydet</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
134
src/app/admin/register/StudentList.tsx
Normal file
134
src/app/admin/register/StudentList.tsx
Normal file
@@ -0,0 +1,134 @@
|
||||
'use client';
|
||||
import { useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import styles from '../branches/branches.module.css';
|
||||
|
||||
export function StudentList({ students, branches }: { students: any[], branches: any[] }) {
|
||||
const router = useRouter();
|
||||
const [showSensitive, setShowSensitive] = useState(false);
|
||||
const [editingId, setEditingId] = useState<string | null>(null);
|
||||
const [editForm, setEditForm] = useState<any>(null);
|
||||
|
||||
const handleDelete = async (id: string) => {
|
||||
if (!confirm('Kaydı silmek istediğinize emin misiniz?')) return;
|
||||
const res = await fetch(`/api/students/${id}`, { method: 'DELETE' });
|
||||
if (res.ok) {
|
||||
router.refresh();
|
||||
} else {
|
||||
alert('Silme işlemi başarısız oldu.');
|
||||
}
|
||||
};
|
||||
|
||||
const startEdit = (student: any) => {
|
||||
setEditingId(student.id);
|
||||
setEditForm({
|
||||
name: student.name,
|
||||
email: student.email || '',
|
||||
phone: student.phone,
|
||||
branchId: student.branchId || '',
|
||||
birthDate: student.birthDate ? new Date(student.birthDate).toISOString().split('T')[0] : ''
|
||||
});
|
||||
};
|
||||
|
||||
const handleUpdate = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const res = await fetch(`/api/students/${editingId}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(editForm),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
setEditingId(null);
|
||||
router.refresh();
|
||||
} else {
|
||||
alert('Güncelleme başarısız oldu.');
|
||||
}
|
||||
};
|
||||
|
||||
const maskInfo = (text: string) => {
|
||||
if (!text) return 'Yok';
|
||||
if (showSensitive) return text;
|
||||
return text.replace(/.(?=.{4})/g, '*');
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles.list}>
|
||||
<div style={{ marginBottom: '1rem', display: 'flex', justifyContent: 'flex-end' }}>
|
||||
<button
|
||||
onClick={() => setShowSensitive(!showSensitive)}
|
||||
className={styles.btn}
|
||||
style={{ background: showSensitive ? '#666' : '#0056b3' }}
|
||||
>
|
||||
{showSensitive ? 'Bilgileri Gizle' : 'Bilgileri Göster'}
|
||||
</button>
|
||||
</div>
|
||||
{students.map(s => (
|
||||
<div key={s.id} className={styles.card}>
|
||||
{editingId === s.id ? (
|
||||
<form onSubmit={handleUpdate} style={{ width: '100%', display: 'flex', gap: '1rem', flexWrap: 'wrap', alignItems: 'flex-end' }}>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Ad Soyad</label>
|
||||
<input
|
||||
value={editForm.name}
|
||||
onChange={e => setEditForm({ ...editForm, name: e.target.value })}
|
||||
className={styles.input}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Telefon</label>
|
||||
<input
|
||||
value={editForm.phone}
|
||||
onChange={e => setEditForm({ ...editForm, phone: e.target.value })}
|
||||
className={styles.input}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Email</label>
|
||||
<input
|
||||
value={editForm.email}
|
||||
onChange={e => setEditForm({ ...editForm, email: e.target.value })}
|
||||
className={styles.input}
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.inputGroup}>
|
||||
<label>Şube</label>
|
||||
<select
|
||||
value={editForm.branchId}
|
||||
onChange={e => setEditForm({ ...editForm, branchId: e.target.value })}
|
||||
className={styles.input}
|
||||
>
|
||||
<option value="">Seçiniz</option>
|
||||
{branches.map(b => (
|
||||
<option key={b.id} value={b.id}>{b.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
||||
<button type="submit" className={styles.btn} style={{ background: '#2e7d32' }}>Kaydet</button>
|
||||
<button type="button" onClick={() => setEditingId(null)} className={styles.btn}>İptal</button>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<>
|
||||
<div>
|
||||
<h3>{s.name}</h3>
|
||||
<p>
|
||||
<strong>Tel:</strong> {maskInfo(s.phone)} |
|
||||
<strong> Email:</strong> {maskInfo(s.email)}
|
||||
</p>
|
||||
<small>{s.branch?.name || 'Şube seçilmemiş'}</small>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '0.5rem' }}>
|
||||
<button onClick={() => startEdit(s)} className={styles.btn} style={{ background: '#ffa000' }}>Düzenle</button>
|
||||
<button onClick={() => handleDelete(s.id)} className={`${styles.btn} ${styles.btnDelete}`}>Sil</button>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
27
src/app/admin/register/page.tsx
Normal file
27
src/app/admin/register/page.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { prisma } from '@/infrastructure/db/prisma';
|
||||
import { RegisterForm } from './RegisterForm';
|
||||
import { StudentList } from './StudentList';
|
||||
import styles from '../branches/branches.module.css';
|
||||
|
||||
export default async function Page() {
|
||||
const [branches, students] = await Promise.all([
|
||||
prisma.branch.findMany({ select: { id: true, name: true } }),
|
||||
prisma.student.findMany({
|
||||
include: { branch: true },
|
||||
orderBy: { createdAt: 'desc' }
|
||||
})
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div className={styles.header}>
|
||||
<h1>Öğrenci Kayıt İşlemleri</h1>
|
||||
</div>
|
||||
<RegisterForm branches={branches} />
|
||||
<div className={styles.header} style={{ marginTop: '2rem' }}>
|
||||
<h2>Kayıtlı Öğrenciler</h2>
|
||||
</div>
|
||||
<StudentList students={students} branches={branches} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -3,11 +3,12 @@ import { prisma } from '@/infrastructure/db/prisma';
|
||||
|
||||
export async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
await prisma.branch.delete({
|
||||
where: { id: params.id },
|
||||
where: { id },
|
||||
});
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
@@ -17,16 +18,25 @@ export async function DELETE(
|
||||
|
||||
export async function PUT(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
const json = await request.json();
|
||||
|
||||
// Explicitly selecting fields to update to avoid spreading unwanted fields (like id)
|
||||
const branch = await prisma.branch.update({
|
||||
where: { id: params.id },
|
||||
data: json,
|
||||
where: { id },
|
||||
data: {
|
||||
name: json.name,
|
||||
address: json.address,
|
||||
phone: json.phone,
|
||||
hallCount: (json.hallCount !== undefined && json.hallCount !== '') ? parseInt(json.hallCount.toString()) : undefined
|
||||
},
|
||||
});
|
||||
return NextResponse.json(branch);
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: 'Failed' }, { status: 500 });
|
||||
} catch (error: any) {
|
||||
console.error('Branch update error:', error);
|
||||
return NextResponse.json({ error: 'Failed to update branch', details: error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,12 @@ export async function POST(request: Request) {
|
||||
data: {
|
||||
name: json.name,
|
||||
address: json.address,
|
||||
phone: json.phone
|
||||
phone: json.phone,
|
||||
hallCount: json.hallCount ? parseInt(json.hallCount) : undefined
|
||||
}
|
||||
});
|
||||
return NextResponse.json(branch);
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: 'Failed to create branch' }, { status: 500 });
|
||||
} catch (error: any) {
|
||||
return NextResponse.json({ error: 'Failed to create branch', details: error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,36 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { prisma } from '@/infrastructure/db/prisma';
|
||||
|
||||
export async function DELETE(
|
||||
export async function PATCH(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
const json = await request.json();
|
||||
const danceClass = await prisma.danceClass.update({
|
||||
where: { id },
|
||||
data: {
|
||||
name: json.name,
|
||||
description: json.description,
|
||||
branchId: json.branchId,
|
||||
instructorId: json.instructorId
|
||||
},
|
||||
});
|
||||
return NextResponse.json({ success: true, danceClass });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: 'Failed to update class' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
await prisma.danceClass.delete({
|
||||
where: { id: params.id },
|
||||
where: { id },
|
||||
});
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
|
||||
@@ -1,13 +1,35 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { prisma } from '@/infrastructure/db/prisma';
|
||||
|
||||
export async function DELETE(
|
||||
export async function PATCH(
|
||||
request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
const json = await request.json();
|
||||
const instructor = await prisma.instructor.update({
|
||||
where: { id },
|
||||
data: {
|
||||
name: json.name,
|
||||
bio: json.bio,
|
||||
phone: json.phone
|
||||
},
|
||||
});
|
||||
return NextResponse.json({ success: true, instructor });
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: 'Failed to update instructor' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
await prisma.instructor.delete({
|
||||
where: { id: params.id },
|
||||
where: { id },
|
||||
});
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
|
||||
65
src/app/api/lessons/route.ts
Normal file
65
src/app/api/lessons/route.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
import { prisma } from "@/infrastructure/db/prisma";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
const lessons = await prisma.lesson.findMany({
|
||||
include: {
|
||||
instructor: true,
|
||||
branch: true,
|
||||
class: true,
|
||||
},
|
||||
});
|
||||
return NextResponse.json(lessons);
|
||||
} catch (error) {
|
||||
return NextResponse.json({ error: "Dersler yüklenemedi" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const json = await request.json();
|
||||
const { startTime, endTime, instructorId, branchId, classId, type, hallNumber, occurrenceCount = 1, period = 'NONE' } = json;
|
||||
|
||||
const start = new Date(startTime);
|
||||
const end = new Date(endTime);
|
||||
const lessons = [];
|
||||
|
||||
for (let i = 0; i < occurrenceCount; i++) {
|
||||
const currentStart = new Date(start);
|
||||
const currentEnd = new Date(end);
|
||||
|
||||
if (period === 'DAILY') {
|
||||
currentStart.setDate(start.getDate() + i);
|
||||
currentEnd.setDate(end.getDate() + i);
|
||||
} else if (period === 'WEEKLY') {
|
||||
currentStart.setDate(start.getDate() + (i * 7));
|
||||
currentEnd.setDate(end.getDate() + (i * 7));
|
||||
} else if (period === 'MONTHLY') {
|
||||
currentStart.setMonth(start.getMonth() + i);
|
||||
currentEnd.setMonth(end.getMonth() + i);
|
||||
} else if (period === 'SIX_MONTHLY') {
|
||||
currentStart.setMonth(start.getMonth() + (i * 6));
|
||||
currentEnd.setMonth(end.getMonth() + (i * 6));
|
||||
}
|
||||
|
||||
const lesson = await prisma.lesson.create({
|
||||
data: {
|
||||
startTime: currentStart,
|
||||
endTime: currentEnd,
|
||||
type,
|
||||
hallNumber: parseInt(hallNumber),
|
||||
branchId,
|
||||
instructorId,
|
||||
classId: classId || null,
|
||||
}
|
||||
});
|
||||
lessons.push(lesson);
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: `${lessons.length} ders başarıyla oluşturuldu`, lessons });
|
||||
} catch (error: any) {
|
||||
console.error('Lesson creation error:', error);
|
||||
return NextResponse.json({ error: "Ders oluşturulamadı", details: error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
28
src/app/api/register/route.ts
Normal file
28
src/app/api/register/route.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { prisma } from '@/infrastructure/db/prisma';
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const json = await request.json();
|
||||
|
||||
// Basic validation
|
||||
if (!json.name || !json.phone || !json.birthDate) {
|
||||
return NextResponse.json({ error: 'Missing required fields' }, { status: 400 });
|
||||
}
|
||||
|
||||
const student = await prisma.student.create({
|
||||
data: {
|
||||
name: json.name,
|
||||
email: json.email || null,
|
||||
phone: json.phone,
|
||||
birthDate: new Date(json.birthDate), // Ensure date format
|
||||
branchId: json.branchId || null
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({ success: true, student });
|
||||
} catch (error) {
|
||||
console.error('Registration error:', error);
|
||||
return NextResponse.json({ error: 'Failed to register' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
42
src/app/api/students/[id]/route.ts
Normal file
42
src/app/api/students/[id]/route.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { prisma } from '@/infrastructure/db/prisma';
|
||||
|
||||
export async function PATCH(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
const json = await request.json();
|
||||
const student = await prisma.student.update({
|
||||
where: { id },
|
||||
data: {
|
||||
name: json.name,
|
||||
email: json.email || null,
|
||||
phone: json.phone,
|
||||
birthDate: json.birthDate ? new Date(json.birthDate) : undefined,
|
||||
branchId: json.branchId || null
|
||||
},
|
||||
});
|
||||
return NextResponse.json({ success: true, student });
|
||||
} catch (error: any) {
|
||||
console.error('Update error:', error);
|
||||
return NextResponse.json({ error: 'Failed to update student', details: error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
export async function DELETE(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
try {
|
||||
const { id } = await params;
|
||||
await prisma.student.delete({
|
||||
where: { id },
|
||||
});
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error('Delete error:', error);
|
||||
return NextResponse.json({ error: 'Failed to delete student' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
@@ -1,141 +1,90 @@
|
||||
.page {
|
||||
--background: #fafafa;
|
||||
--foreground: #fff;
|
||||
--primary: #8ab4f8;
|
||||
--secondary: #202124;
|
||||
--accent: #f28b82;
|
||||
--bg: #000000;
|
||||
--white: #ffffff;
|
||||
--text: #e8eaed;
|
||||
--text-muted: #9aa0a6;
|
||||
|
||||
--text-primary: #000;
|
||||
--text-secondary: #666;
|
||||
|
||||
--button-primary-hover: #383838;
|
||||
--button-secondary-hover: #f2f2f2;
|
||||
--button-secondary-border: #ebebeb;
|
||||
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
background: var(--bg);
|
||||
font-family: var(--font-outfit, 'Outfit', sans-serif);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.nav {
|
||||
padding: 0.75rem 2rem;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: var(--font-geist-sans);
|
||||
background-color: var(--background);
|
||||
background: #000000;
|
||||
border-bottom: 1px solid #3c4043;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 700;
|
||||
color: #e8eaed;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
|
||||
.adminLink {
|
||||
padding: 0.6rem 1.2rem;
|
||||
background: var(--secondary);
|
||||
color: white;
|
||||
border-radius: 8px;
|
||||
text-decoration: none;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.adminLink:hover {
|
||||
background: var(--primary);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.main {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.hero {
|
||||
text-align: center;
|
||||
max-width: 800px;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
background-color: var(--foreground);
|
||||
padding: 120px 60px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.intro {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
text-align: left;
|
||||
gap: 24px;
|
||||
.hero h1 {
|
||||
font-size: 3.5rem;
|
||||
font-weight: 900;
|
||||
margin-bottom: 1rem;
|
||||
color: #111;
|
||||
letter-spacing: -2px;
|
||||
}
|
||||
|
||||
.intro h1 {
|
||||
max-width: 320px;
|
||||
font-size: 40px;
|
||||
font-weight: 600;
|
||||
line-height: 48px;
|
||||
letter-spacing: -2.4px;
|
||||
text-wrap: balance;
|
||||
color: var(--text-primary);
|
||||
.hero p {
|
||||
font-size: 1.25rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.intro p {
|
||||
max-width: 440px;
|
||||
font-size: 18px;
|
||||
line-height: 32px;
|
||||
text-wrap: balance;
|
||||
color: var(--text-secondary);
|
||||
.footer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.intro a {
|
||||
font-weight: 500;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.ctas {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
width: 100%;
|
||||
max-width: 440px;
|
||||
gap: 16px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.ctas a {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 40px;
|
||||
padding: 0 16px;
|
||||
border-radius: 128px;
|
||||
border: 1px solid transparent;
|
||||
transition: 0.2s;
|
||||
cursor: pointer;
|
||||
width: fit-content;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
a.primary {
|
||||
background: var(--text-primary);
|
||||
color: var(--background);
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
a.secondary {
|
||||
border-color: var(--button-secondary-border);
|
||||
}
|
||||
|
||||
/* Enable hover only on non-touch devices */
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
a.primary:hover {
|
||||
background: var(--button-primary-hover);
|
||||
border-color: transparent;
|
||||
@media (max-width: 768px) {
|
||||
.nav {
|
||||
padding: 1rem 2rem;
|
||||
}
|
||||
|
||||
a.secondary:hover {
|
||||
background: var(--button-secondary-hover);
|
||||
border-color: transparent;
|
||||
.hero h1 {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.main {
|
||||
padding: 48px 24px;
|
||||
}
|
||||
|
||||
.intro {
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.intro h1 {
|
||||
font-size: 32px;
|
||||
line-height: 40px;
|
||||
letter-spacing: -1.92px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.logo {
|
||||
filter: invert();
|
||||
}
|
||||
|
||||
.page {
|
||||
--background: #000;
|
||||
--foreground: #000;
|
||||
|
||||
--text-primary: #ededed;
|
||||
--text-secondary: #999;
|
||||
|
||||
--button-primary-hover: #ccc;
|
||||
--button-secondary-hover: #1a1a1a;
|
||||
--button-secondary-border: #1a1a1a;
|
||||
}
|
||||
}
|
||||
}
|
||||
105
src/app/page.tsx
105
src/app/page.tsx
@@ -1,66 +1,57 @@
|
||||
import Image from "next/image";
|
||||
import { prisma } from "@/infrastructure/db/prisma";
|
||||
import { ScheduleCalendar } from "@/components/ScheduleCalendar";
|
||||
import Link from "next/link";
|
||||
import styles from "./page.module.css";
|
||||
|
||||
export default function Home() {
|
||||
export default async function Home() {
|
||||
// Calculate start and end of current week
|
||||
const now = new Date();
|
||||
const dayOfWeek = now.getDay(); // 0 is Sunday
|
||||
const diff = now.getDate() - dayOfWeek + (dayOfWeek === 0 ? -6 : 1); // Adjust to Monday
|
||||
const startOfWeek = new Date(now.setDate(diff));
|
||||
startOfWeek.setHours(0, 0, 0, 0);
|
||||
|
||||
const endOfWeek = new Date(startOfWeek);
|
||||
endOfWeek.setDate(endOfWeek.getDate() + 7);
|
||||
|
||||
// Get the first branch to determine hallCount (or you could add a selector)
|
||||
const branch = await prisma.branch.findFirst();
|
||||
const hallCount = branch?.hallCount || 1;
|
||||
|
||||
const lessons = await prisma.lesson.findMany({
|
||||
where: {
|
||||
startTime: {
|
||||
gte: startOfWeek,
|
||||
lt: endOfWeek,
|
||||
},
|
||||
},
|
||||
include: {
|
||||
instructor: true,
|
||||
branch: true,
|
||||
class: true,
|
||||
},
|
||||
orderBy: {
|
||||
startTime: 'asc',
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<nav className={styles.nav}>
|
||||
<div className={styles.logo}>{branch?.name || "Dance School"}</div>
|
||||
<Link href="/admin/dashboard" className={styles.adminLink}>
|
||||
Yönetici Paneli
|
||||
</Link>
|
||||
</nav>
|
||||
|
||||
<main className={styles.main}>
|
||||
<Image
|
||||
className={styles.logo}
|
||||
src="/next.svg"
|
||||
alt="Next.js logo"
|
||||
width={100}
|
||||
height={20}
|
||||
priority
|
||||
/>
|
||||
<div className={styles.intro}>
|
||||
<h1>To get started, edit the page.tsx file.</h1>
|
||||
<p>
|
||||
Looking for a starting point or more instructions? Head over to{" "}
|
||||
<a
|
||||
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Templates
|
||||
</a>{" "}
|
||||
or the{" "}
|
||||
<a
|
||||
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Learning
|
||||
</a>{" "}
|
||||
center.
|
||||
</p>
|
||||
</div>
|
||||
<div className={styles.ctas}>
|
||||
<a
|
||||
className={styles.primary}
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<Image
|
||||
className={styles.logo}
|
||||
src="/vercel.svg"
|
||||
alt="Vercel logomark"
|
||||
width={16}
|
||||
height={16}
|
||||
/>
|
||||
Deploy Now
|
||||
</a>
|
||||
<a
|
||||
className={styles.secondary}
|
||||
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<ScheduleCalendar lessons={lessons} hallCount={hallCount} branchId={branch?.id} />
|
||||
</main>
|
||||
|
||||
<footer className={styles.footer}>
|
||||
<p>© {new Date().getFullYear()} Dance School Yönetim Sistemi. Tüm hakları saklıdır.</p>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
213
src/components/ScheduleCalendar.module.css
Normal file
213
src/components/ScheduleCalendar.module.css
Normal file
@@ -0,0 +1,213 @@
|
||||
.container {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background-color: #000000;
|
||||
color: #e8eaed;
|
||||
font-family: var(--font-outfit, 'Outfit', -apple-system, sans-serif);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.title {
|
||||
text-align: center;
|
||||
padding: 0.75rem 0;
|
||||
margin: 0;
|
||||
font-size: 1.25rem;
|
||||
font-weight: 500;
|
||||
border-bottom: 1px solid #3c4043;
|
||||
}
|
||||
|
||||
.calendarWrapper {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.stickyHeader {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
background: #000;
|
||||
border-bottom: 1px solid #3c4043;
|
||||
}
|
||||
|
||||
.headerRow {
|
||||
display: flex;
|
||||
margin-left: 60px;
|
||||
/* Space for time axis */
|
||||
}
|
||||
|
||||
.dayHeader {
|
||||
flex: 1;
|
||||
min-width: 120px;
|
||||
text-align: center;
|
||||
padding: 0.5rem 0;
|
||||
border-right: 1px solid #3c4043;
|
||||
font-size: 0.75rem;
|
||||
color: #9aa0a6;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.dayHeader:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.today .dayHeader {
|
||||
color: #8ab4f8;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.hallLabelsRow {
|
||||
display: flex;
|
||||
margin-left: 60px;
|
||||
border-top: 1px solid rgba(60, 64, 67, 0.3);
|
||||
}
|
||||
|
||||
.hallLabel {
|
||||
flex: 1;
|
||||
min-width: calc(120px / var(--hall-count, 1));
|
||||
text-align: center;
|
||||
font-size: 0.65rem;
|
||||
color: #5f6368;
|
||||
padding: 2px 0;
|
||||
border-right: 1px solid rgba(60, 64, 67, 0.3);
|
||||
}
|
||||
|
||||
.gridContainer {
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 1440px;
|
||||
/* 24 hours * 60px */
|
||||
}
|
||||
|
||||
.timeAxis {
|
||||
width: 60px;
|
||||
background: #000;
|
||||
border-right: 1px solid #3c4043;
|
||||
position: sticky;
|
||||
left: 0;
|
||||
z-index: 50;
|
||||
/* Ensure time axis fills the height */
|
||||
height: 1440px;
|
||||
}
|
||||
|
||||
.timeLabel {
|
||||
height: 60px;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: flex-end;
|
||||
padding-right: 8px;
|
||||
font-size: 0.7rem;
|
||||
color: #9aa0a6;
|
||||
/* Center the text vertically at the hour mark */
|
||||
position: relative;
|
||||
top: -8px;
|
||||
}
|
||||
|
||||
.mainGrid {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
background-image: linear-gradient(#3c4043 1px, transparent 1px);
|
||||
background-size: 100% 60px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.dayColumn {
|
||||
flex: 1;
|
||||
min-width: 120px;
|
||||
border-right: 1px solid #3c4043;
|
||||
display: flex;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.dayColumn:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.hallColumn {
|
||||
flex: 1;
|
||||
position: relative;
|
||||
border-right: 1px solid rgba(60, 64, 67, 0.2);
|
||||
}
|
||||
|
||||
.hallColumn:last-child {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.nowLine {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 2px;
|
||||
background: #ea4335;
|
||||
z-index: 10;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.nowLine::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: -4px;
|
||||
top: -4px;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
background: #ea4335;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.lessonCard {
|
||||
position: absolute;
|
||||
left: 3px;
|
||||
right: 3px;
|
||||
background: rgba(138, 180, 248, 0.2);
|
||||
border: 1px solid #8ab4f8;
|
||||
border-radius: 4px;
|
||||
padding: 4px;
|
||||
font-size: 0.7rem;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
z-index: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
}
|
||||
|
||||
.lessonCard:hover {
|
||||
background: rgba(138, 180, 248, 0.3);
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
.lessonCard[data-type="Individual"] {
|
||||
background: rgba(242, 139, 130, 0.2);
|
||||
border-color: #f28b82;
|
||||
}
|
||||
|
||||
.lessonTime {
|
||||
color: #8ab4f8;
|
||||
font-weight: 500;
|
||||
font-size: 0.65rem;
|
||||
}
|
||||
|
||||
.lessonCard[data-type="Individual"] .lessonTime {
|
||||
color: #f28b82;
|
||||
}
|
||||
|
||||
.lessonTitle {
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.lessonMeta {
|
||||
color: #9aa0a6;
|
||||
font-size: 0.6rem;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
380
src/components/ScheduleCalendar.tsx
Normal file
380
src/components/ScheduleCalendar.tsx
Normal file
@@ -0,0 +1,380 @@
|
||||
'use client';
|
||||
import { useMemo, useEffect, useRef, useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
interface Lesson {
|
||||
id: string;
|
||||
name?: string | null;
|
||||
startTime: Date | string;
|
||||
endTime: Date | string;
|
||||
type: string;
|
||||
class?: { name: string } | null;
|
||||
instructor: { name: string };
|
||||
branch: { name: string; hallCount?: number | null };
|
||||
hallNumber?: number | null;
|
||||
}
|
||||
|
||||
export function ScheduleCalendar({ lessons, hallCount = 1, branchId }: { lessons: Lesson[], hallCount?: number, branchId?: string }) {
|
||||
const router = useRouter();
|
||||
const days = ['Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi', 'Pazar'];
|
||||
const hours = Array.from({ length: 24 }, (_, i) => i);
|
||||
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
const [now, setNow] = useState(new Date());
|
||||
|
||||
// Modal State
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const [selectedSlot, setSelectedSlot] = useState<{ dayIdx: number, hour: number, hNum: number } | null>(null);
|
||||
const [instructors, setInstructors] = useState<any[]>([]);
|
||||
const [classes, setClasses] = useState<any[]>([]);
|
||||
const [formData, setFormData] = useState({
|
||||
instructorId: '',
|
||||
classId: '',
|
||||
type: 'Group',
|
||||
period: 'NONE',
|
||||
occurrenceCount: 1,
|
||||
duration: 60
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const timer = setInterval(() => setNow(new Date()), 60000);
|
||||
if (scrollRef.current) {
|
||||
const currentHour = now.getHours();
|
||||
const scrollHour = Math.max(0, currentHour - 2);
|
||||
scrollRef.current.scrollTop = scrollHour * 60;
|
||||
}
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
|
||||
const fetchFormData = async () => {
|
||||
const [instRes, classRes] = await Promise.all([
|
||||
fetch('/api/instructors'),
|
||||
fetch('/api/classes')
|
||||
]);
|
||||
const instData = await instRes.json();
|
||||
const classData = await classRes.json();
|
||||
setInstructors(instData);
|
||||
setClasses(classData);
|
||||
};
|
||||
|
||||
const handleSlotClick = (dayIdx: number, hour: number, hNum: number) => {
|
||||
if (!branchId) return;
|
||||
setSelectedSlot({ dayIdx, hour, hNum });
|
||||
setIsModalOpen(true);
|
||||
fetchFormData();
|
||||
};
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!selectedSlot || !branchId) return;
|
||||
|
||||
// Calculate actual date for the selected slot in the current week
|
||||
const now = new Date();
|
||||
const dayOfWeek = now.getDay();
|
||||
const diff = now.getDate() - dayOfWeek + (dayOfWeek === 0 ? -6 : 1);
|
||||
const startOfWeek = new Date(now.setDate(diff));
|
||||
|
||||
const startTime = new Date(startOfWeek);
|
||||
startTime.setDate(startOfWeek.getDate() + selectedSlot.dayIdx);
|
||||
startTime.setHours(selectedSlot.hour, 0, 0, 0);
|
||||
|
||||
const endTime = new Date(startTime);
|
||||
endTime.setMinutes(startTime.getMinutes() + parseInt(formData.duration.toString()));
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/lessons', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
...formData,
|
||||
branchId,
|
||||
hallNumber: selectedSlot.hNum,
|
||||
startTime,
|
||||
endTime
|
||||
})
|
||||
});
|
||||
|
||||
if (res.ok) {
|
||||
setIsModalOpen(false);
|
||||
router.refresh();
|
||||
} else {
|
||||
const errData = await res.json();
|
||||
alert(`Ders oluşturulamadı: ${errData.details || errData.error || 'Bilinmeyen hata'}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
const nowTop = (now.getHours() * 60) + now.getMinutes();
|
||||
|
||||
const groupedLessons = useMemo(() => {
|
||||
const groups: Record<number, Record<number, any[]>> = {};
|
||||
lessons.forEach(lesson => {
|
||||
const start = new Date(lesson.startTime);
|
||||
const end = new Date(lesson.endTime);
|
||||
let dayIndex = start.getDay() - 1;
|
||||
if (dayIndex === -1) dayIndex = 6;
|
||||
const hallNum = lesson.hallNumber || 1;
|
||||
const top = (start.getHours() * 60) + start.getMinutes();
|
||||
const bottom = (end.getHours() * 60) + end.getMinutes();
|
||||
if (!groups[dayIndex]) groups[dayIndex] = {};
|
||||
if (!groups[dayIndex][hallNum]) groups[dayIndex][hallNum] = [];
|
||||
groups[dayIndex][hallNum].push({
|
||||
...lesson,
|
||||
top,
|
||||
height: Math.max(bottom - top, 20),
|
||||
startTimeStr: start.toLocaleTimeString('tr-TR', { hour: '2-digit', minute: '2-digit' })
|
||||
});
|
||||
});
|
||||
return groups;
|
||||
}, [lessons]);
|
||||
|
||||
const timeWidth = 60;
|
||||
const dayMinWidth = 180;
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
width: '100%',
|
||||
height: '100vh',
|
||||
backgroundColor: '#000',
|
||||
color: '#fff',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
overflow: 'hidden',
|
||||
fontFamily: 'sans-serif'
|
||||
}}>
|
||||
<h1 style={{ textAlign: 'center', padding: '10px', margin: 0, fontSize: '1.2rem', borderBottom: '1px solid #333' }}>
|
||||
Haftalık Ders Programı
|
||||
</h1>
|
||||
|
||||
<div ref={scrollRef} style={{ flex: 1, overflow: 'auto', position: 'relative' }}>
|
||||
<div style={{ position: 'sticky', top: 0, zIndex: 100, backgroundColor: '#000', borderBottom: '1px solid #333' }}>
|
||||
<div style={{ display: 'flex', marginLeft: timeWidth }}>
|
||||
{days.map((day, idx) => {
|
||||
const isToday = ((new Date().getDay() - 1 + 7) % 7) === idx;
|
||||
return (
|
||||
<div key={day} style={{
|
||||
flex: 1,
|
||||
minWidth: dayMinWidth,
|
||||
textAlign: 'center',
|
||||
padding: '8px 0',
|
||||
borderRight: '1px solid #333',
|
||||
fontSize: '0.8rem',
|
||||
color: isToday ? '#8ab4f8' : '#9aa0a6',
|
||||
fontWeight: isToday ? 'bold' : 'normal'
|
||||
}}>
|
||||
{day}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
{hallCount > 1 && (
|
||||
<div style={{ display: 'flex', marginLeft: timeWidth, borderTop: '1px solid #222' }}>
|
||||
{days.map((_, dIdx) => (
|
||||
<div key={dIdx} style={{ flex: 1, minWidth: dayMinWidth, display: 'flex' }}>
|
||||
{Array.from({ length: hallCount }).map((_, hIdx) => (
|
||||
<div key={hIdx} style={{
|
||||
flex: 1,
|
||||
textAlign: 'center',
|
||||
fontSize: '0.6rem',
|
||||
color: '#666',
|
||||
borderRight: hIdx === hallCount - 1 ? '1px solid #333' : '1px solid #222',
|
||||
padding: '4px 0',
|
||||
backgroundColor: '#050505'
|
||||
}}>
|
||||
S{hIdx + 1}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', minHeight: '1440px', position: 'relative' }}>
|
||||
<div style={{ width: timeWidth, position: 'sticky', left: 0, zIndex: 50, backgroundColor: '#000', borderRight: '1px solid #333' }}>
|
||||
{hours.map(h => (
|
||||
<div key={h} style={{ height: '60px', paddingRight: '5px', textAlign: 'right', fontSize: '0.7rem', color: '#666', paddingTop: '2px' }}>
|
||||
{h === 0 ? '12 AM' : h === 12 ? '12 PM' : h > 12 ? `${h - 12} PM` : `${h} AM`}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div style={{ flex: 1, position: 'relative', display: 'flex', backgroundImage: 'linear-gradient(#222 1px, transparent 1px)', backgroundSize: '100% 60px' }}>
|
||||
<div style={{ position: 'absolute', top: nowTop, left: 0, right: 0, height: '2px', backgroundColor: 'red', zIndex: 40, pointerEvents: 'none' }}>
|
||||
<div style={{ position: 'absolute', left: '-5px', top: '-4px', width: '10px', height: '10px', borderRadius: '50%', backgroundColor: 'red' }} />
|
||||
</div>
|
||||
|
||||
{days.map((_, dIdx) => (
|
||||
<div key={dIdx} style={{ flex: 1, minWidth: dayMinWidth, borderRight: '1px solid #333', position: 'relative', display: 'flex' }}>
|
||||
{Array.from({ length: hallCount }).map((_, hIdx) => {
|
||||
const hNum = hIdx + 1;
|
||||
return (
|
||||
<div key={hIdx} style={{ flex: 1, position: 'relative', borderRight: hallCount > 1 ? '1px solid #111' : 'none' }}>
|
||||
{/* Hoverable Slots */}
|
||||
{hours.map(h => (
|
||||
<div
|
||||
key={h}
|
||||
onClick={() => handleSlotClick(dIdx, h, hNum)}
|
||||
style={{ height: '60px', position: 'relative', cursor: 'pointer' }}
|
||||
className="slot-hover"
|
||||
>
|
||||
<div className="plus-btn" style={{
|
||||
position: 'absolute',
|
||||
right: '5px',
|
||||
top: '5px',
|
||||
width: '20px',
|
||||
height: '20px',
|
||||
backgroundColor: 'rgba(255,255,255,0.1)',
|
||||
borderRadius: '50%',
|
||||
display: 'none',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
fontSize: '12px'
|
||||
}}>+</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{groupedLessons[dIdx]?.[hNum]?.map(lesson => (
|
||||
<div key={lesson.id} style={{
|
||||
position: 'absolute',
|
||||
top: lesson.top,
|
||||
height: lesson.height,
|
||||
left: '2px',
|
||||
right: '2px',
|
||||
backgroundColor: lesson.type === 'Individual' ? 'rgba(242, 139, 130, 0.2)' : 'rgba(138, 180, 248, 0.2)',
|
||||
borderLeft: `3px solid ${lesson.type === 'Individual' ? '#f28b82' : '#8ab4f8'}`,
|
||||
borderRadius: '4px',
|
||||
padding: '4px',
|
||||
fontSize: '0.7rem',
|
||||
overflow: 'hidden',
|
||||
zIndex: 10
|
||||
}}>
|
||||
<div style={{ fontWeight: 'bold', fontSize: '0.6rem', opacity: 0.8 }}>{lesson.startTimeStr}</div>
|
||||
<div style={{ fontWeight: 'bold', margin: '2px 0' }}>{lesson.class?.name || lesson.name}</div>
|
||||
<div style={{ opacity: 0.6 }}>{lesson.instructor.name}</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Reservation Modal */}
|
||||
{isModalOpen && (
|
||||
<div style={{
|
||||
position: 'fixed',
|
||||
top: 0, left: 0, right: 0, bottom: 0,
|
||||
backgroundColor: 'rgba(0,0,0,0.8)',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
zIndex: 200
|
||||
}}>
|
||||
<form onSubmit={handleSubmit} style={{
|
||||
backgroundColor: '#1e1e1e',
|
||||
padding: '2rem',
|
||||
borderRadius: '8px',
|
||||
width: '400px',
|
||||
border: '1px solid #333',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
gap: '1rem'
|
||||
}}>
|
||||
<h3>Yeni Ders Rezervasyonu</h3>
|
||||
<p style={{ fontSize: '0.8rem', color: '#9aa0a6' }}>
|
||||
{days[selectedSlot!.dayIdx]} - Saat: {selectedSlot!.hour}:00 - Salon: {selectedSlot!.hNum}
|
||||
</p>
|
||||
|
||||
<label>Eğitmen</label>
|
||||
<select
|
||||
required
|
||||
value={formData.instructorId}
|
||||
onChange={(e) => setFormData({ ...formData, instructorId: e.target.value })}
|
||||
style={{ padding: '8px', backgroundColor: '#2b2b2b', color: '#fff', border: '1px solid #444' }}
|
||||
>
|
||||
<option value="">Seçiniz</option>
|
||||
{instructors.map(i => <option key={i.id} value={i.id}>{i.name}</option>)}
|
||||
</select>
|
||||
|
||||
<label>Sınıf (Opsiyonel)</label>
|
||||
<select
|
||||
value={formData.classId}
|
||||
onChange={(e) => setFormData({ ...formData, classId: e.target.value })}
|
||||
style={{ padding: '8px', backgroundColor: '#2b2b2b', color: '#fff', border: '1px solid #444' }}
|
||||
>
|
||||
<option value="">Seçiniz</option>
|
||||
{classes.map(c => <option key={c.id} value={c.id}>{c.name}</option>)}
|
||||
</select>
|
||||
|
||||
<label>Ders Türü</label>
|
||||
<select
|
||||
value={formData.type}
|
||||
onChange={(e) => setFormData({ ...formData, type: e.target.value })}
|
||||
style={{ padding: '8px', backgroundColor: '#2b2b2b', color: '#fff', border: '1px solid #444' }}
|
||||
>
|
||||
<option value="Group">Grup Dersi</option>
|
||||
<option value="Individual">Özel Ders</option>
|
||||
</select>
|
||||
|
||||
<label>Süre (Dakika)</label>
|
||||
<input
|
||||
type="number"
|
||||
value={formData.duration}
|
||||
onChange={(e) => setFormData({ ...formData, duration: parseInt(e.target.value) })}
|
||||
style={{ padding: '8px', backgroundColor: '#2b2b2b', color: '#fff', border: '1px solid #444' }}
|
||||
/>
|
||||
|
||||
<label>Tekrar</label>
|
||||
<select
|
||||
value={formData.period}
|
||||
onChange={(e) => setFormData({ ...formData, period: e.target.value })}
|
||||
style={{ padding: '8px', backgroundColor: '#2b2b2b', color: '#fff', border: '1px solid #444' }}
|
||||
>
|
||||
<option value="NONE">Tek Seferlik</option>
|
||||
<option value="DAILY">Günlük</option>
|
||||
<option value="WEEKLY">Haftalık</option>
|
||||
<option value="MONTHLY">Aylık</option>
|
||||
<option value="SIX_MONTHLY">6 Aylık</option>
|
||||
</select>
|
||||
|
||||
{formData.period !== 'NONE' && (
|
||||
<>
|
||||
<label>Tekrar Sayısı</label>
|
||||
<input
|
||||
type="number"
|
||||
value={formData.occurrenceCount}
|
||||
onChange={(e) => setFormData({ ...formData, occurrenceCount: parseInt(e.target.value) })}
|
||||
style={{ padding: '8px', backgroundColor: '#2b2b2b', color: '#fff', border: '1px solid #444' }}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
<div style={{ display: 'flex', gap: '10px', marginTop: '10px' }}>
|
||||
<button type="submit" style={{ flex: 1, padding: '10px', backgroundColor: '#8ab4f8', color: '#000', border: 'none', borderRadius: '4px', fontWeight: 'bold', cursor: 'pointer' }}>
|
||||
Kaydet
|
||||
</button>
|
||||
<button type="button" onClick={() => setIsModalOpen(false)} style={{ flex: 1, padding: '10px', backgroundColor: 'transparent', color: '#fff', border: '1px solid #444', borderRadius: '4px', cursor: 'pointer' }}>
|
||||
İptal
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<style jsx>{`
|
||||
.slot-hover:hover .plus-btn {
|
||||
display: flex !important;
|
||||
}
|
||||
.slot-hover:hover {
|
||||
background-color: rgba(255,255,255,0.05);
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -2,8 +2,13 @@ import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const globalForPrisma = global as unknown as { prisma: PrismaClient };
|
||||
|
||||
export const prisma =
|
||||
globalForPrisma.prisma ||
|
||||
new PrismaClient();
|
||||
const prismaInstance = globalForPrisma.prisma || new PrismaClient();
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma;
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
globalForPrisma.prisma = prismaInstance;
|
||||
// Log models to verify generation
|
||||
const models = Object.keys(prismaInstance).filter(k => !k.startsWith('_') && !k.startsWith('$'));
|
||||
console.log('Prisma models available:', models);
|
||||
}
|
||||
|
||||
export const prisma = prismaInstance;
|
||||
|
||||
@@ -8,12 +8,12 @@ export function Sidebar() {
|
||||
const router = useRouter();
|
||||
|
||||
const navItems = [
|
||||
{ name: 'Takvime Git 🗓️', href: '/' },
|
||||
{ name: 'Dashboard', href: '/admin/dashboard' },
|
||||
{ name: 'Şubeler', href: '/admin/branches' },
|
||||
{ name: 'Hocalar', href: '/admin/instructors' },
|
||||
{ name: 'Sınıflar', href: '/admin/classes' },
|
||||
{ name: 'Ders Programı', href: '/admin/lessons' },
|
||||
{ name: 'Ücretler', href: '/admin/fees' },
|
||||
{ name: 'Kayıt', href: '/admin/register' },
|
||||
];
|
||||
|
||||
const handleLogout = () => {
|
||||
|
||||
Reference in New Issue
Block a user