formEditFuncition
parent
dd3c5a829f
commit
306c26c22a
|
@ -59,54 +59,53 @@ export default function addSchoolForm() {
|
||||||
fetch(`https://management.beanstalkedu.com/items/school/${router.query.school}`)
|
fetch(`https://management.beanstalkedu.com/items/school/${router.query.school}`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
|
|
||||||
// console.log("handleSelectAllStates:", data, options)
|
// console.log("handleSelectAllStates:", data, options)
|
||||||
// let newData = data && data.length > 0
|
// let newData = data && data.length > 0
|
||||||
console.log(router.query.school); setSchool(data)
|
console.log(router.query.school); setSchool(data.data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [router.query.school]);
|
}, [router.query.school]);
|
||||||
|
|
||||||
console.log(school);
|
// console.log(school.data);
|
||||||
// console.log(phoneValue)
|
// console.log(phoneValue)
|
||||||
// const selectCountry = countryValue => {
|
// const selectCountry = countryValue => {
|
||||||
// setCountryValue(countryValue)
|
// setCountryValue(countryValue)
|
||||||
// }
|
// }
|
||||||
const handleSubmit = async (event) => {
|
// const handleSubmit = async (event) => {
|
||||||
event.preventDefault()
|
// event.preventDefault()
|
||||||
const data = {
|
// const data = {
|
||||||
"status":"published",
|
// "status":"published",
|
||||||
name: event.target.schoolName.value,
|
// name: event.target.schoolName.value,
|
||||||
country: event.target.country.value,
|
// country: event.target.country.value,
|
||||||
state: event.target.state.value,
|
// state: event.target.state.value,
|
||||||
cities: event.target.cities.value,
|
// cities: event.target.cities.value,
|
||||||
anual: event.target.anual.value,
|
// anual: event.target.anual.value,
|
||||||
toddlers: event.target.toddlers.value,
|
// toddlers: event.target.toddlers.value,
|
||||||
early_start_programme: event.target.early_start_programme.value,
|
// early_start_programme: event.target.early_start_programme.value,
|
||||||
interakto: event.target.interakto.value,
|
// interakto: event.target.interakto.value,
|
||||||
agreement_expiry_date: event.target.agreement_expiry_date.value,
|
// agreement_expiry_date: event.target.agreement_expiry_date.value,
|
||||||
school_agreement: event.target.school_agreement.value,
|
// school_agreement: event.target.school_agreement.value,
|
||||||
school_contact_number: event.target.school_contact_number.value,
|
// school_contact_number: event.target.school_contact_number.value,
|
||||||
school_email_id: event.target.school_email_id.value,
|
// school_email_id: event.target.school_email_id.value,
|
||||||
|
|
||||||
}
|
// }
|
||||||
const JSONdata = JSON.stringify(data)
|
// const JSONdata = JSON.stringify(data)
|
||||||
console.log(data)
|
// console.log(data)
|
||||||
const endpoint = 'https://management.beanstalkedu.com/items/school'
|
// const endpoint = 'https://management.beanstalkedu.com/items/school'
|
||||||
const options = {
|
// const options = {
|
||||||
method: 'POST',
|
// method: 'POST',
|
||||||
headers: {
|
// headers: {
|
||||||
'Content-Type': 'application/json',
|
// 'Content-Type': 'application/json',
|
||||||
},
|
// },
|
||||||
body: JSONdata,
|
// body: JSONdata,
|
||||||
}
|
// }
|
||||||
const response = await fetch(endpoint, options)
|
// const response = await fetch(endpoint, options)
|
||||||
|
|
||||||
const result = await response.json()
|
// const result = await response.json()
|
||||||
// alert(`Is this your full name: ${result.data}`)
|
// // alert(`Is this your full name: ${result.data}`)
|
||||||
alert(`School Saved`)
|
// alert(`School Saved`)
|
||||||
}
|
// }
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
|
@ -118,10 +117,10 @@ export default function addSchoolForm() {
|
||||||
<img src="/img/1.svg" alt="" />
|
<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>
|
<p className='text-2xl md:text-4xl font-bold underline decoration-4 decoration-[#FE4501] pb-10'>School Registration Form</p>
|
||||||
</div>
|
</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'>
|
<div className='flex flex-col w-full'>
|
||||||
<label htmlFor="school" className='text-xl font-bold'>School Name</label>
|
<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>
|
||||||
<div className='flex flex-col w-full pt-4'>
|
<div className='flex flex-col w-full pt-4'>
|
||||||
<label htmlFor="school_email_id" className='text-xl font-bold'> Email ID</label>
|
<label htmlFor="school_email_id" className='text-xl font-bold'> Email ID</label>
|
||||||
|
|
Loading…
Reference in New Issue