Files
dance_school/src/app/admin/instructors/AddInstructorForm.tsx
2026-01-08 00:51:13 +03:00

36 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
import { useState } from 'react';
import { useRouter } from 'next/navigation';
import styles from '../branches/branches.module.css'; // Reuse styles
export function AddInstructorForm() {
const [name, setName] = useState('');
const [bio, setBio] = useState('');
const router = useRouter();
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
await fetch('/api/instructors', {
method: 'POST',
body: JSON.stringify({ name, bio }),
});
setName('');
setBio('');
router.refresh();
};
return (
<form onSubmit={handleSubmit} className={styles.form}>
<div className={styles.inputGroup}>
<label>Hoca Adı</label>
<input value={name} onChange={e => setName(e.target.value)} className={styles.input} required />
</div>
<div className={styles.inputGroup}>
<label>Biyografi / Uzmanlık</label>
<input value={bio} onChange={e => setBio(e.target.value)} className={styles.input} />
</div>
<button type="submit" className={styles.btn}>Ekle</button>
</form>
);
}