formEditFuncition
parent
dd3c5a829f
commit
306c26c22a
|
@ -59,54 +59,53 @@ export default function addSchoolForm() {
|
|||
fetch(`https://management.beanstalkedu.com/items/school/${router.query.school}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
|
||||
// console.log("handleSelectAllStates:", data, options)
|
||||
// let newData = data && data.length > 0
|
||||
console.log(router.query.school); setSchool(data)
|
||||
console.log(router.query.school); setSchool(data.data)
|
||||
})
|
||||
}
|
||||
|
||||
}, [router.query.school]);
|
||||
|
||||
console.log(school);
|
||||
// console.log(school.data);
|
||||
// console.log(phoneValue)
|
||||
// const selectCountry = countryValue => {
|
||||
// setCountryValue(countryValue)
|
||||
// }
|
||||
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 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 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`)
|
||||
}
|
||||
// const result = await response.json()
|
||||
// // alert(`Is this your full name: ${result.data}`)
|
||||
// alert(`School Saved`)
|
||||
// }
|
||||
|
||||
return (
|
||||
<main>
|
||||
|
@ -118,10 +117,10 @@ export default function addSchoolForm() {
|
|||
<img src="/img/1.svg" alt="" />
|
||||
<p className='text-2xl md:text-4xl font-bold underline decoration-4 decoration-[#FE4501] pb-10'>School Registration Form</p>
|
||||
</div>
|
||||
<form onSubmit={handleSubmit} className='w-full px-6 md:px-20'>
|
||||
<form className='w-full px-6 md:px-20'>
|
||||
<div className='flex flex-col w-full'>
|
||||
<label htmlFor="school" className='text-xl font-bold'>School Name</label>
|
||||
<input type="text" name="schoolName" placeholder='School Name' className='border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
|
||||
<input type="text" value={school.name} name="schoolName" placeholder='School Name' className='border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
|
||||
</div>
|
||||
<div className='flex flex-col w-full pt-4'>
|
||||
<label htmlFor="school_email_id" className='text-xl font-bold'> Email ID</label>
|
||||
|
|
Loading…
Reference in New Issue