Initial commit of Dance School App
This commit is contained in:
35
src/app/admin/instructors/AddInstructorForm.tsx
Normal file
35
src/app/admin/instructors/AddInstructorForm.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
'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>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user