import NavBar from '../components/NavBar' import { useId, useState, useEffect, useMemo } from 'react'; import 'react-phone-number-input/style.css' import { useRouter } from 'next/router' export default function addSchoolForm() { const router = useRouter(); const [school, setSchool] = useState({}); useEffect(()=>{ // if(router.query.school<1) { // const { sid } = router.query; // setSchool(sid) if(router.query.school && router.query.school>1 ){ fetch(`https://management.beanstalkedu.com/items/school/${router.query.school}`) .then(res => res.json()) .then(data => { console.log(router.query.school); setSchool(data.data) }) } }, [router.query.school]); const handleSubmit = async (event) => { event.preventDefault() const data = { "status":"published", name: event.target.schoolName.value, country: event.target.country.value, state: event.target.state.value, cities: event.target.cities.value, anual: event.target.anual.value, toddlers: event.target.toddlers.value, early_start_programme: event.target.early_start_programme.value, interakto: event.target.interakto.value, agreement_expiry_date: event.target.agreement_expiry_date.value, school_agreement: event.target.school_agreement.value, school_contact_number: event.target.school_contact_number.value, school_email_id: event.target.school_email_id.value, } const JSONdata = JSON.stringify(data) console.log(data) const endpoint = 'https://management.beanstalkedu.com/items/school' const options = { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSONdata, } const response = await fetch(endpoint, options) const result = await response.json() // alert(`Is this your full name: ${result.data}`) alert(`School Saved`) } return (

School Registration Form

setSchool(e.target.value)} name="schoolName" placeholder='School Name' className='border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
setSchool(e.target.value)} name="school_email_id" id="school_email_id" placeholder='School Email ID' className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
setSchool(e.target.value)} name="country" />
setSchool(e.target.value)} name="state" />
setSchool(e.target.value)} name="cities" />
setSchool(e.target.value)} name="school_contact_number" />
setSchool(e.target.value)} />
setSchool(e.target.value)} />
setSchool(e.target.value)} />
setSchool(e.target.value)} />
setSchool(e.target.value)} id="agreement_expiry_date" className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
) }