main2
Kar 2023-05-20 23:04:29 +05:30
parent 54f74f8860
commit 300df6001b
18 changed files with 216 additions and 1570 deletions

View File

@ -21,6 +21,7 @@
"formidable": "^2.1.1",
"formik": "^2.2.9",
"jsonwebtoken": "^9.0.0",
"jwt-decode": "^3.1.2",
"next": "13.3.1",
"next-auth": "^4.22.1",
"postcss": "8.4.23",

View File

@ -1,24 +1,36 @@
import Image from 'next/image'
import { Inter } from 'next/font/google'
import { signIn, signOut, useSession } from 'next-auth/react'
import Link from 'next/link'
const inter = Inter({ subsets: ['latin'] })
export default function Home() {
export default function NavBar() {
const { data: session } = useSession()
console.log(session)
if (session) {
return (
<main>
<div>
<section className="container-fluid bg-[#FFF6F2]">
<div className="container mx-auto px-4">
<div className='flex flex-row gap-x-2 md:gap-x-16 p-4 justify-center whitespace-nowrap'>
<Link href="/add-school-form">Add School </Link>|
<Link href="/school-list">School List</Link>|
<Link href="/add-user-form">Add User </Link>|
<Link href="/user-list">User List </Link>|
<button onClick={() => signOut()}>Sign out</button>
</div>
</div>
</section>
</div>
</main>
)
}
return (
<main>
<div>
<section className="container-fluid bg-[#FFF6F2]">
<div className="container mx-auto px-4">
<div className='flex flex-row gap-x-2 md:gap-x-16 p-4 justify-center whitespace-nowrap'>
<a href="/add-school-form">Add School </a>|
<a href="/school-list">School List</a>|
<a href="/add-user-form">Add User </a>|
<a href="/user-list">User List </a>
</div>
</div>
</section>
</div>
</main>
<>
Not signed in <br />
<button onClick={() => signIn()}>Sign in</button>
</>
)
}

View File

@ -5,8 +5,8 @@ import countryList from 'react-select-country-list'
import 'react-phone-number-input/style.css'
import PhoneInput from 'react-phone-number-input'
export default function addSchoolForm() {
const [countryValue, setCountryValue] = useState('')
export default function AddSchool() {
const [countryValue, setCountryValue] =useState('')
const options = useMemo(() => countryList().getData(), [])
const [phoneValue, setphoneValue] = useState()
const [allStates, setAllStates] = useState([])

View File

@ -10,7 +10,7 @@ import NavBar from '../components/NavBar';
const typeParent = "parent"
export default function addUserForm() {
export default function AddUser() {
const [allLanguage, setLanguage] = useState([
{lang: "Assamese", value: false},
{lang: "Bengali", value: false},

View File

@ -1,336 +0,0 @@
// https://management.beanstalkedu.com/items/school
// import React from 'react';
import {useId, useState, useEffect, useMemo} from 'react';
import Select from 'react-select'
import countryList from 'react-select-country-list'
import 'react-phone-number-input/style.css'
import PhoneInput from 'react-phone-number-input'
import NavBar from '../components/NavBar';
// import { Inter } from 'next/font/google'
const typeParent = "parent"
export default function addUserForm() {
const [allLanguage, setLanguage] = useState([
{lang: "Assamese", value: false},
{lang: "Bengali", value: false},
{lang: "English", value: false},
{lang: "Hindi", value: false},
{lang: "telegu", value: false},
{lang: "Punjabi", value: false},
{lang: "malayalam", value: false},
{lang: "tamil", value: false},
{lang: "kannada", value: false},
{lang: "gujrati", value: false},
])
const [currentType, setCurrentType] = useState(typeParent)
const [countryValue, setCountryValue] = useState('')
const options = useMemo(() => countryList().getData(), [])
const [phoneValue, setphoneValue] = useState()
let [individualValue = true, setindividualValue] = useState()
const [allStates, setAllStates] = useState([])
const [allCities, setAllCities] = useState([])
const handleSelectAllStates = stateCode => {
setAllCities([])
fetch(`https://api.siliconpin.com/v3/list/country/city/?country=${countryValue.value}&state=${stateCode.value}`).then(res => res.json())
.then(data => {
console.log("handleSelectAllStates:", data, options)
let newData = data && data.length > 0 && data.map(n => {
return {
label: n.name,
value: n.name
}
})
setAllCities(newData)
})
}
const selectCountry = countryValue => {
setAllStates([])
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${countryValue.value}`).then(res => res.json())
.then(data => {
console.log("countryValue:", data, options)
let newData = data && data.length > 0 && data.map(n => {
return {
label: n.name,
value: n.iso2
}
})
setAllStates(newData)
setAllCities([])
})
setCountryValue(countryValue)
}
const individual = (event) => {
// console.log(event.target.schoolID.value)
setindividualValue(individualValue = false)
}
const [school, setSchool] = useState(null);
useEffect(() => {
fetch(`https://management.beanstalkedu.com/items/school`)
.then(res => res.json())
.then(data => {
setSchool(data)
})
}, [])
// console.log(school);
const handleFormsubmit = async (event) => {
event.preventDefault()
const data = {
"status": "published",
type: event.target.type.value,
name: event.target.name.value,
user: event.target.email.value,
country: event.target.country.value,
phone: event.target.phone.value,
school: event.target.schoolID.value,
class: event.target.class.value,
lang: event.target.lang.value,
start_month: event.target.start_month.value,
start_date: event.target.start_date.value,
end_date: event.target.end_date.value,
annual: event.target.annual.value,
}
const JSONdata = JSON.stringify(data)
const endpoint = '/api/addUsers'
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}`)
}
const handleOnLanguageChange = (e, v) => {
let idx = allLanguage.findIndex(o => o.lang === e.target.value);
let newAllLang = [...allLanguage]
newAllLang[idx].value = true
if ([typeParent, "teacher"].includes(currentType)) {
let counter = 0
newAllLang.forEach((n, idx) => {
if (n.value) {
counter++
}
})
if (counter >= 2) {
newAllLang.forEach((n, idx) => {
newAllLang[idx].disabled = true
})
}
}
setLanguage(newAllLang)
}
const handleTypeOnChange = (e) => {
let newAllLang = [...allLanguage]
newAllLang.forEach((n, idx) => {
newAllLang[idx].value = false
newAllLang[idx].disabled = false
})
setLanguage(newAllLang)
setCurrentType(e.target.value)
}
return (
<main>
<div>
<NavBar/>
<section className='container mx-auto px-4 my-16 lg:px-28 xl:px-56 2xl:px-96'>
<div
className='flex flex-col justify-center place-items-center bg-[#FFF6F2] pt-6 pb-20 rounded-tl-[50px] rounded-br-[50px]'>
<div className='flex flex-col justify-center place-items-center'>
<img src="/img/2.svg" alt=""/>
<p className='text-2xl md:text-4xl font-bold underline decoration-4 decoration-[#FE4501] pb-10'>User
Registration Form</p>
</div>
<form onSubmit={handleFormsubmit} action="" className='w-full px-6 md:px-20'>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="class" className='text-xl font-bold'>Type</label>
<select name="type"
onChange={handleTypeOnChange}
className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value={typeParent}>Parent</option>
<option value="teacher">Teacher</option>
<option value="coordinator">Coordinator</option>
<option value="master">Master</option>
</select>
</div>
<div className='flex flex-col w-full'>
<label htmlFor="name" className='text-xl font-bold'> Name</label>
<input type="text" name="name"
className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
placeholder='Enter your Name'/>
</div>
<div className='flex flex-col w-full'>
<label htmlFor="email" className='text-xl font-bold'>Email</label>
<input type="email" name="email" placeholder='ex. xyz@email.com'
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'>
<label htmlFor="country" className='text-xl font-bold'>Country</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="country" instanceId={useId()} options={options} value={countryValue}
onChange={selectCountry}/>
</div>
{allStates && allStates.length > 0 &&
<div className='flex flex-col w-full'>
<label htmlFor="state" className='text-xl font-bold'>State</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="state" options={allStates} value={allStates[0].name}
onChange={handleSelectAllStates}/>
</div>}
{
allCities && allCities.length > 0 &&
<div className='flex flex-col w-full'>
<label htmlFor="Cities" className='text-xl font-bold'>Cities</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="Cities" options={allCities} value={allCities[0].name}
// onChange={() => {}}
/>
</div>}
<div className='flex flex-col w-full'>
<label htmlFor="phone" className='text-xl font-bold'> Phone</label>
<PhoneInput
className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="phone" placeholder="Enter phone number" value={phoneValue}
onChange={setphoneValue}/>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="" className='text-xl font-bold'>School name</label>
<select name="schoolID" onChange={individual}
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="individual"> individual</option>
{school && school.data.map(data =>
<option value={data.id} key={data.id}>{data.name}</option>
)}
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="class" className='text-xl font-bold'>Class</label>
<select name="class"
className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0">-Select-</option>
<option value="IK1">IK1</option>
<option value="IK2">IK2</option>
<option value="IK3">IK3</option>
<option value="PG">PG</option>
</select>
</div>
{individualValue &&
<div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="annual" className='text-xl font-bold'>annual</label>
<select name="annual"
className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0">-NA-</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
{/* <div className='flex flex-col w-full pt-4'>
<label htmlFor="plan" className='text-xl font-bold'>Plan</label>
<div className='grid grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-y-2 pt-2 '>
<div className='flex flex-row place-items-center'>
<label className='cursor-pointer' htmlFor="annual">annual</label>&nbsp;
<input type="checkbox" name="plan" id="annual" value='annual' className='check-box'/>
</div>
<div className='flex flex-row place-items-center'>
<label className='cursor-pointer' htmlFor="Toddler">Toddler</label>&nbsp;
<input type="checkbox" name="plan" id="Toddler" value='Toddler' className='check-box'/>
</div>
<div className='flex flex-row place-items-center'>
<label className='cursor-pointer' htmlFor="Interakto">Interakto</label>&nbsp;
<input type="checkbox" name="plan" id="Interakto" value='Interakto' className='check-box'/>
</div>
<div className='flex flex-row place-items-center col-span-2'>
<label className='cursor-pointer md:whitespace-nowrap' htmlFor="Early_Start_program">Early Start Program</label>&nbsp;
<input type="checkbox" name="plan" id="Early_Start_program" value='Early_Start_program' className='check-box'/>
</div>
</div>
</div> */}
<div className='flex flex-col w-full pt-4'>
<label htmlFor="lang" className='text-xl font-bold'>Language</label>
<div className='grid grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-y-2 pt-2'>
{allLanguage && allLanguage.length && allLanguage.map(n => {
return (
<div key={n.lang} className=''>
<label className='cursor-pointer'
htmlFor="assamese">{n.lang}</label>&nbsp;
<input type="checkbox" disabled={n.disabled} name="lang" value={n.lang} checked={n.value}
onChange={handleOnLanguageChange}
className='check-box'/>
</div>
)
})}
</div>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="start_month" className='text-xl font-bold'>Start Month</label>
<select name="start_month" id="start_month"
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0">-Select-</option>
<option value="January"> January</option>
<option value="February"> February</option>
<option value="March"> March</option>
<option value="April"> April</option>
<option value="May"> May</option>
<option value="June"> June</option>
<option value="July"> July</option>
<option value="August"> August</option>
<option value="September"> September</option>
<option value="November"> November</option>
<option value="December"> December</option>
</select>
</div>
<div className='flex flex-col w-full'>
<label htmlFor="start_date" className='text-xl font-bold pt-4'>Start
Date</label>
<input type="date" name="start_date" id="start_date"
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'>
<label htmlFor="end_date" className='text-xl font-bold pt-4'>Subscription Expiry
Date.</label>
<input type="date" name="end_date" id="end_date"
className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'/>
</div>
</div>
}
<div className='flex justify-center pt-8'>
<button type="submit"
className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer'>Save
</button>
{/* <input type="submit" value="Submit Now" className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer' /> */}
</div>
</form>
</div>
</section>
</div>
</main>
)
}

View File

@ -1,6 +1,8 @@
import NextAuth from "next-auth/next";
import CredentialsProvider from "next-auth/providers/credentials";
import { signIn } from "next-auth/react";
import jwt_decode from "jwt-decode";
const pubAPI = process.env.DIRECTUS_PUBLIC_API;
@ -44,8 +46,11 @@ export const options = {
callbacks: {
async jwt({ token, user, account }) {
if (account && user) {
var tokenJwt =user.data.access_token
var roleID = jwt_decode(tokenJwt).role;
return {
...token,
roleID:roleID,
accessToken: user.data.access_token,
expires: Date.now() + user.data.expires,
refreshToken: user.data.refresh_token,
@ -62,6 +67,7 @@ export const options = {
},
async session({ session, token }) {
session.user.roleID = token.roleID;
session.user.accessToken = token.accessToken;
session.user.refreshToken = token.refreshToken;
session.user.expires = token.expires;

View File

@ -1,131 +0,0 @@
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,
annual: event.target.annual.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 (
<main>
<div>
<NavBar />
<section className='container mx-auto px-4 my-16 lg:px-28 xl:px-56 2xl:px-96'>
<div className='flex flex-col justify-center place-items-center bg-[#FFF6F2] pt-6 pb-20 rounded-tl-[50px] rounded-br-[50px]'>
<div className='flex flex-col justify-center place-items-center'>
<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 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" value={school.name} onChange={e => 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]' />
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="school_email_id" className='text-xl font-bold'> Email ID</label>
<input type="text" value={school.school_email_id} onChange={e => 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]' />
</div>
<div className='flex flex-col w-full'>
<label htmlFor="country" className='text-xl font-bold'>Country</label>
<input type="text" value={school.country} onChange={e => setSchool(e.target.value)} name="country" />
</div>
<div className='flex flex-col w-full'>
<label htmlFor="state" className='text-xl font-bold'>State</label>
<input type="text" value={school.state} onChange={e => setSchool(e.target.value)} name="state" />
</div>
<div className='flex flex-col w-full'>
<label htmlFor="Cities" className='text-xl font-bold'>Cities</label>
<input type="text" value={school.cities} onChange={e => setSchool(e.target.value)} name="cities" />
</div>
<div className='flex flex-col w-full'>
<label htmlFor="school_contact_number" className='text-xl font-bold'> Phone</label>
<input type="text" value={school.school_contact_number} onChange={e => setSchool(e.target.value)} name="school_contact_number" />
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="annual" className='text-xl font-bold'>annual</label>
<input type="text" value={school.annual} onChange={e => setSchool(e.target.value)} />
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="toddlers" className='text-xl font-bold'>Toddlers</label>
<input type="text" name="toddlers" value={school.toddlers} onChange={e => setSchool(e.target.value)} />
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="early_start_programme" className='text-xl font-bold'>Early Start Program</label>
<input type="text" name="early_start_programme" value={school.early_start_programme} onChange={e => setSchool(e.target.value)} />
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="interakto" className='text-xl font-bold'>Interakto</label>
<input type="text" name="interakto" value={school.interakto} onChange={e => setSchool(e.target.value)} />
</div>
<div className='flex flex-col w-full'>
<label htmlFor="agreement_expiry_date" className='text-xl font-bold pt-4'>Agreement Expiry Date</label>
<input type="date" name="agreement_expiry_date" value={school.agreement_expiry_date} onChange={e => 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]' />
</div>
<div className='flex justify-center pt-8'>
<input type="submit" value="Save" className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer' />
</div>
</form>
</div>
</section>
</div>
</main>
)
}

View File

@ -2,8 +2,10 @@ import {useId, useState, useEffect, useMemo} from 'react';
import 'react-phone-number-input/style.css'
import NavBar from '../components/NavBar';
import { useRouter } from 'next/router'
import Link from 'next/link'
export default function editSchool() {
export default function EditSchool() {
const router = useRouter();
const [school, setSchool] = useState({});
@ -66,10 +68,10 @@ export default function editSchool() {
<div
className='flex flex-col justify-center place-items-center bg-[#FFF6F2] pt-6 pb-20 rounded-tl-[50px] rounded-br-[50px]'>
<div className='inline-flex p-4 '>
<a href="/add-school-form" className="m-2 inline-flex place-items-center justify-center p-2 pl-4 pr-4 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
<Link href="/add-school-form" className="m-2 inline-flex place-items-center justify-center p-2 pl-4 pr-4 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
<img src="/img/4.svg" alt="" /> &nbsp;
List Users Under This School
</a>
</Link>
<div className="place-items-center justify-center m-2 p-2 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
<span className="text-small">CSV Upload &nbsp;</span>
<input type="file" />
@ -141,7 +143,7 @@ export default function editSchool() {
</div>
<div className='flex flex-col w-full'>
<label htmlFor="agreement_documents" className='text-xl font-bold'>Upload Agreement Document's</label>
<label htmlFor="agreement_documents" className='text-xl font-bold'>Upload Agreement Document&apos;s</label>
<input onChange={e => setSchool(e.target.value)} type="file" name="agreement_documents" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
<div className='flex justify-end pt-2'>
<button className=' bg-[#FE4501] px-4 py-1.5 rounded-lg text-white'>Download Agreement</button>

View File

@ -1,167 +0,0 @@
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 uploadToServer = async (event) => {
const body = new FormData();
body.append("file", agreement.files[0]);
body.append("fName", `${router.query.school}.pdf`);
const response = await fetch("/api/fileUpload", {
method: "POST",
body
});
};
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]);
// console.log(setSchool)
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,
annual: event.target.annual.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 (
<main>
<div>
<NavBar />
<section className='container mx-auto px-4 my-16 lg:px-28 xl:px-56 2xl:px-96'>
<div className='flex flex-col justify-center place-items-center bg-[#FFF6F2] pt-6 pb-20 rounded-tl-[50px] rounded-br-[50px]'>
<div className='flex flex-col justify-center place-items-center'>
<img src="/img/1.svg" alt="" />
<p className='text-2xl md:text-4xl font-bold underline decoration-4 decoration-[#FE4501] pb-10'>Update School Information</p>
</div>
<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" value={school.name} onChange={e => 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]' />
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="school_email_id" className='text-xl font-bold'> Email ID</label>
<input type="text" value={school.school_email_id} onChange={e => 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]' />
</div>
<div className='flex flex-col w-full'>
<label htmlFor="country" className='text-xl font-bold'>Country</label>
<input className='border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' type="text" value={school.country} onChange={e => setSchool(e.target.value)} name="country" />
</div>
<div className='flex flex-col w-full'>
<label htmlFor="state" className='text-xl font-bold'>State</label>
<input type="text" value={school.state} onChange={e => setSchool(e.target.value)} name="state" 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'>
<label htmlFor="Cities" className='text-xl font-bold'>Cities</label>
<input type="text" value={school.cities} onChange={e => setSchool(e.target.value)} name="cities" 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'>
<label htmlFor="school_contact_number" className='text-xl font-bold'> Phone</label>
<input type="text" value={school.school_contact_number} onChange={e => setSchool(e.target.value)} name="school_contact_number" 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="annual" className='text-xl font-bold'>annual</label>
<input type="text" value={school.annual} onChange={e => setSchool(e.target.value)} 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="toddlers" className='text-xl font-bold'>Toddlers</label>
<input type="text" name="toddlers" value={school.toddlers} onChange={e => setSchool(e.target.value)} 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="early_start_programme" className='text-xl font-bold'>Early Start Program</label>
<input type="text" name="early_start_programme" value={school.early_start_programme} onChange={e => setSchool(e.target.value)} 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="interakto" className='text-xl font-bold'>Interakto</label>
<input type="text" name="interakto" value={school.interakto} onChange={e => setSchool(e.target.value)} 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'>
<label htmlFor="agreement_expiry_date" className='text-xl font-bold pt-4'>Agreement Expiry Date</label>
<input type="date" name="agreement_expiry_date" value={school.agreement_expiry_date} onChange={e => 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]' />
</div>
{/* <div className='flex flex-col w-full'>
<label htmlFor="agreement_expiry_date" className='text-xl font-bold pt-4'>Upload Agreement</label>
<input type="file" name="agreement_expiry_date" />
</div> */}
{/* <div className='flex justify-center pt-8'>
<input type="submit" value="Save" className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer' />
</div> */}
</form>
<div class="flex pt-6">
<div class="flex-1 ">
<input id="agreement" type="file" name="myImage" onChange={uploadToServer} />
{/* <button
className="rounded-full bg-[#FE4501] p-2 text-white"
type="submit"
onClick={uploadToServer}
>
Upload Agreement
</button> */}
</div>
<div class="flex-1 ">
<a href={'/uploaded/'+router.query.school+'.pdf'}><button
className="rounded-full bg-[#FE4501] p-2 text-white"
type="submit"
onClick={uploadToServer}
>
Download Agreement
</button></a>
</div>
</div>
</div>
</section>
</div>
</main>
)
}

View File

@ -3,26 +3,12 @@ import 'react-phone-number-input/style.css'
import NavBar from '../components/NavBar';
import { useRouter } from 'next/router'
export default function editUser() {
export default function EditUser() {
const router = useRouter();
// const updateUserData = async (event) => {
// const body = new FormData();
// body.append("file", agreement.files[0]);
// body.append("fName", `${router.query.school}.pdf`);
// const response = await fetch("/api/updateUserDetails", {
// method: "POST",
// body
// });
// };
const [user, setUser] = useState({});
useEffect(()=>{
// console.log(router.query);
// if(router.query.school<1) {
// const { sid } = router.query;
// setSchool(sid)
if(router.query.user && router.query.user>0 ){
fetch(`/api/getUserDetails?user=${router.query.user}`)
.then(res => res.json())

View File

@ -1,402 +0,0 @@
// https://management.beanstalkedu.com/items/school
// import React from 'react';
import {useId, useState, useEffect, useMemo} from 'react';
import Select from 'react-select'
import countryList from 'react-select-country-list'
import 'react-phone-number-input/style.css'
import PhoneInput from 'react-phone-number-input'
import NavBar from '../components/NavBar';
import { useRouter } from 'next/router'
// import { Inter } from 'next/font/google'
const typeParent = "parent"
export default function addUserForm() {
const router = useRouter();
const [allLanguage, setLanguage] = useState([
{lang: "Assamese", value: false},
{lang: "Bengali", value: false},
{lang: "English", value: false},
{lang: "Hindi", value: false},
{lang: "Telegu", value: false},
{lang: "Punjabi", value: false},
{lang: "Malayalam", value: false},
{lang: "Tamil", value: false},
{lang: "Kannada", value: false},
{lang: "Gujrati", value: false},
])
// console.log(allLanguage)
const [currentType, setCurrentType] = useState(typeParent)
const [countryValue, setCountryValue] = useState('')
const options = useMemo(() => countryList().getData(), [])
const [phoneValue, setphoneValue] = useState()
let [individualValue = true, setindividualValue] = useState()
const [allStates, setAllStates] = useState([])
const [allCities, setAllCities] = useState([])
const handleSelectAllStates = stateCode => {
setAllCities([])
fetch(`https://api.siliconpin.com/v3/list/country/city/?country=${countryValue.value}&state=${stateCode.value}`)
.then(res => res.json())
.then(data => {
// console.log("handleSelectAllStates:", data, options)
let newData = data && data.length > 0 && data.map(n => {
return {
label: n.name,
value: n.name
}
})
setAllCities(newData)
})
}
const selectCountry = countryValue => {
setAllStates([])
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${countryValue.value}`).then(res => res.json())
.then(data => {
console.log("countryValue:", data, options)
let newData = data && data.length > 0 && data.map(n => {
return {
label: n.name,
value: n.iso2
}
})
setAllStates(newData)
setAllCities([])
})
setCountryValue(countryValue)
}
const individual = (event) => {
// console.log(event.target.schoolID.value)
setindividualValue(individualValue = false)
}
const [school, setSchool] = useState(null);
useEffect(() => {
fetch(`https://management.beanstalkedu.com/items/school`)
.then(res => res.json())
.then(data => {
setSchool(data)
})
}, [])
const [user, setUser] = useState({});
useEffect(()=>{
if(router.query.user && router.query.user>1){
fetch(`/api/listUsers/${router.query.user}`)
.then(res => res.json())
.then(data => {
setUser(data)
}
)
}
},
[router.query.user]);
console.log(user)
const handleFormsubmit = async (event) => {
event.preventDefault()
console.log(event.target.lang.checked)
const data = {
"status": "published",
type: event.target.type.value,
uname: event.target.uname.value,
country: event.target.country.value,
state: event.target.state.value ? event.target.state.value:"",
city: event.target.city.value ? event.target.city.value:"",
phone: event.target.phone.value,
email: event.target.email.value,
school: event.target.schoolID.value,
klas: event.target.klas.value,
lang: allLanguage,
start_month: event.target.start_month.value,
start_date: event.target.start_date.value,
end_date: event.target.end_date.value,
annual: event.target.annual.value,
early_start_programme: event.target.early_start_programme.value,
toddlers: event.target.toddlers.value,
interakto: event.target.interakto.value,
}
const JSONdata = JSON.stringify(data)
const endpoint = '/api/addUsers'
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSONdata,
}
const response = await fetch(endpoint, options)
const result = await response.json()
// console.log(result)
// alert(`Is this your full name: ${result}`)
}
const handleOnLanguageChange = (e, v) => {
let idx = allLanguage.findIndex(o => o.lang === e.target.value);
let newAllLang = [...allLanguage]
newAllLang[idx].value = true
// console.log(newAllLang)
if ([typeParent, "teacher"].includes(currentType)) {
let counter = 0
newAllLang.forEach((n, idx) => {
if (n.value) {
counter++
}
})
if (counter >= 2) {
newAllLang.forEach((n, idx) => {
newAllLang[idx].disabled = true
})
}
}
setLanguage(newAllLang)
}
const handleTypeOnChange = (e) => {
let newAllLang = [...allLanguage]
newAllLang.forEach((n, idx) => {
newAllLang[idx].value = false
newAllLang[idx].disabled = false
})
const { name, checked } = e.target;
setLanguage({ ...allLanguage, [name]: checked });
// setLanguage(newAllLang)
setCurrentType(e.target.value)
}
return (
<main>
<div>
<NavBar/>
<section className='container mx-auto px-4 my-16 lg:px-28 xl:px-56 2xl:px-96'>
<div
className='flex flex-col justify-center place-items-center bg-[#FFF6F2] pt-6 pb-20 rounded-tl-[50px] rounded-br-[50px]'>
<div className='flex flex-col justify-center place-items-center'>
<img src="/img/2.svg" alt=""/>
<p className='text-2xl md:text-4xl font-bold underline decoration-4 decoration-[#FE4501] pb-10'>Update User Information </p>
</div>
<form onSubmit={handleFormsubmit} action="" className='w-full px-6 md:px-20'>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="class" className='text-xl font-bold'>Type</label>
<input type="text" value="wvgfbhvwhvf" name="type" onChange={handleTypeOnChange} className=' bg-white 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'>
<label htmlFor="name" className='text-xl font-bold'> Name</label>
<input type="text" name="uname"
className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
placeholder='Enter your Name'/>
</div>
<div className='flex flex-col w-full'>
<label htmlFor="email" className='text-xl font-bold'>Email</label>
<input type="email" name="email" placeholder='ex. xyz@email.com'
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'>
<label htmlFor="country" className='text-xl font-bold'>Country</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="country" instanceId={useId()} options={options} value={countryValue}
onChange={selectCountry}/>
</div>
{allStates && allStates.length > 0 &&
<div className='flex flex-col w-full'>
<label htmlFor="state" className='text-xl font-bold'>State</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="state" options={allStates} value={allStates[0].name}
onChange={handleSelectAllStates}/>
</div>}
{
allCities && allCities.length > 0 &&
<div className='flex flex-col w-full'>
<label htmlFor="city" className='text-xl font-bold'>City</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="city" options={allCities} value={allCities[0].name}
// onChange={() => {}}
/>
</div>}
<div className='flex flex-col w-full'>
<label htmlFor="phone" className='text-xl font-bold'> Phone</label>
<PhoneInput
className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="phone" placeholder="Enter phone number" value={phoneValue}
onChange={setphoneValue}/>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="" className='text-xl font-bold'>School name</label>
<select name="schoolID" onChange={individual}
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0"> individual</option>
{school && school.data.map(data =>
<option value={data.id} key={data.id}>{data.name}</option>
)}
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="class" className='text-xl font-bold'>Class</label>
<select name="klas"
className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0">-Select-</option>
<option value="IK1">IK1</option>
<option value="IK2">IK2</option>
<option value="IK3">IK3</option>
<option value="PG">PG</option>
</select>
</div>
{individualValue &&
<div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="annual" className='text-xl font-bold'>annual</label>
<select name="annual" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0">-NA-</option>
<option value="Jan">Jan</option>
<option value="Feb">Feb</option>
<option value="Mar">Mar</option>
<option value="Apr">Apr</option>
<option value="May">May</option>
<option value="Jun">Jun</option>
<option value="Jul">Jul</option>
<option value="Aug">Aug</option>
<option value="Sept">Sept</option>
<option value="Oct">Oct</option>
<option value="Nov">Nov</option>
<option value="Dec">Dec</option>
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="early_start_programme" className='text-xl font-bold'>Early Start Programme</label>
<select name="early_start_programme" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0">-NA-</option>
<option value="Jan">Jan</option>
<option value="Feb">Feb</option>
<option value="Mar">Mar</option>
<option value="Apr">Apr</option>
<option value="May">May</option>
<option value="Jun">Jun</option>
<option value="Jul">Jul</option>
<option value="Aug">Aug</option>
<option value="Sept">Sept</option>
<option value="Oct">Oct</option>
<option value="Nov">Nov</option>
<option value="Dec">Dec</option>
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="toddlers" className='text-xl font-bold'>Toddlers</label>
<select name="toddlers" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0">-NA-</option>
<option value="Jan">Jan</option>
<option value="Feb">Feb</option>
<option value="Mar">Mar</option>
<option value="Apr">Apr</option>
<option value="May">May</option>
<option value="Jun">Jun</option>
<option value="Jul">Jul</option>
<option value="Aug">Aug</option>
<option value="Sept">Sept</option>
<option value="Oct">Oct</option>
<option value="Nov">Nov</option>
<option value="Dec">Dec</option>
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="interakto" className='text-xl font-bold'>Interakto</label>
<select name="interakto" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0">-NA-</option>
<option value="Jan">Jan</option>
<option value="Feb">Feb</option>
<option value="Mar">Mar</option>
<option value="Apr">Apr</option>
<option value="May">May</option>
<option value="Jun">Jun</option>
<option value="Jul">Jul</option>
<option value="Aug">Aug</option>
<option value="Sept">Sept</option>
<option value="Oct">Oct</option>
<option value="Nov">Nov</option>
<option value="Dec">Dec</option>
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="lang" className='text-xl font-bold'>Language</label>
<div className='grid grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-y-2 pt-2'>
{/* <label className='cursor-pointer' htmlFor="Assamese"> Assamese </label> &nbsp; <input type="checkbox" name="lang" value="Assamese" className='check-box'/> <br />
<label className='cursor-pointer' htmlFor="Bengali"> Bengali </label> &nbsp; <input type="checkbox" name="lang" value="Bengali" className='check-box'/> <br />
<label className='cursor-pointer' htmlFor="English"> English </label> &nbsp; <input type="checkbox" name="lang" value="English" className='check-box'/> <br />
<label className='cursor-pointer' htmlFor="Hindi"> Hindi </label> &nbsp; <input type="checkbox" name="lang" value="Hindi" className='check-box'/> <br />
<label className='cursor-pointer' htmlFor="Telegu"> Telegu </label> &nbsp; <input type="checkbox" name="lang" value="Telegu" className='check-box'/> <br />
<label className='cursor-pointer' htmlFor="Punjabi"> Punjabi </label> &nbsp; <input type="checkbox" name="lang" value="Punjabi" className='check-box'/> <br />
<label className='cursor-pointer' htmlFor="Malayalam"> Malayalam </label> &nbsp; <input type="checkbox" name="lang" value="Malayalam" className='check-box'/> <br />
<label className='cursor-pointer' htmlFor="Tamil"> Tamil </label> &nbsp; <input type="checkbox" name="lang" value="Tamil" className='check-box'/> <br />
<label className='cursor-pointer' htmlFor="Kannada"> Kannada </label> &nbsp; <input type="checkbox" name="lang" value="Kannada" className='check-box'/> <br />
<label className='cursor-pointer' htmlFor="Gujrati"> Gujrati </label> &nbsp; <input type="checkbox" name="lang" value="Gujrati" className='check-box'/> <br /> */}
{allLanguage && allLanguage.length && allLanguage.map(n => {
return (
<div key={n.lang} className=''>
<label className='cursor-pointer'
htmlFor="assamese">{n.lang}</label>&nbsp;
<input type="checkbox" disabled={n.disabled} name="lang" value={n.lang} checked={n.value}
onChange={handleOnLanguageChange}
className='check-box'/>
</div>
)
})}
</div>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="start_month" className='text-xl font-bold'>Start Month</label>
<select name="start_month" id="start_month" className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0">-Select-</option>
<option value="Jan"> Jan</option>
<option value="Feb"> Feb</option>
<option value="Mar"> Mar</option>
<option value="Apr"> Apr</option>
<option value="May"> May</option>
<option value="Jun"> Jun</option>
<option value="Jul"> Jul</option>
<option value="Aug"> Aug</option>
<option value="Sept"> Sept</option>
<option value="Nov"> Nov</option>
<option value="Dec"> Dec</option>
</select>
</div>
<div className='flex flex-col w-full'>
<label htmlFor="start_date" className='text-xl font-bold pt-4'>Start
Date</label>
<input type="date" name="start_date" id="start_date"
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'>
<label htmlFor="end_date" className='text-xl font-bold pt-4'>Subscription Expiry
Date.</label>
<input type="date" name="end_date" id="end_date"
className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'/>
</div>
</div>
}
<div className='flex justify-center pt-8'>
<button type="submit"
className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer'>Update
</button>
{/* <input type="submit" value="Submit Now" className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer' /> */}
</div>
</form>
</div>
</section>
</div>
</main>
)
}

View File

@ -10,12 +10,7 @@ export default function Home() {
<main>
<NavBar />
<br />
<button onClick={() => signIn('credentials', { email: 'user5@email.com', password: 'Simple2pass' })}>
Sign in
</button>
<button onClick={() => signOut()}>
Sign out
</button>
</main>
)
}

View File

@ -1,241 +1,161 @@
import NavBar from '../../components/NavBar'
import {useRouter} from "next/router";
import { useId, useState, useEffect, useMemo } from 'react';
import Select from 'react-select'
import countryList from 'react-select-country-list'
import {useId, useState, useEffect, useMemo} from 'react';
import 'react-phone-number-input/style.css'
import PhoneInput from 'react-phone-number-input'
import NavBar from '../../components/NavBar';
import { useRouter } from 'next/router'
import Link from 'next/link'
export default function addSchoolForm() {
const { query } = useRouter();
const [countryValue, setCountryValue] = useState('')
const options = useMemo(() => countryList().getData(), [])
const [phoneValue, setphoneValue] = useState()
const [allStates, setAllStates] = useState([])
const [allCities, setAllCities] = useState([])
const handleSelectAllStates = stateCode => {
setAllCities([])
fetch(`https://api.siliconpin.com/v3/list/country/city/?country=${countryValue.value}&state=${stateCode.value}`)
.then(res => res.json())
.then(data => {
// console.log("handleSelectAllStates:", data, options)
let newData = data && data.length > 0 && data.map(n => {
return {
label: n.name,
value: n.name
}
export default function SchoolSlug() {
const router = useRouter();
const [school, setSchool] = useState({});
useEffect(()=>{
if(router.query.school && router.query.school>0 ){
console.log(router.query);
fetch(`/api/getSchoolDetails?school=${router.query.school}`)
.then(res => res.json())
.then(data => {
console.log(data);
setSchool(data[0])
// console.log(school)
})
setAllCities(newData)
})
}
const selectCountry = countryValue => {
setAllStates([])
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${countryValue.value}`)
.then(res => res.json())
.then(data => {
// console.log("countryValue:", data, options)
let newData = data && data.length > 0 && data.map(n => {
return {
label: n.name,
value: n.iso2
}
})
setAllStates(newData)
setAllCities([])
})
setCountryValue(countryValue)
}
// 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,
annual: event.target.annual.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)
}, [router.query.school]);
const result = await response.json()
// alert(`Is this your full name: ${result.data}`)
alert(`School Saved`)
const updateSchoolData = async (event) => {
event.preventDefault()
const data = {
schoolId: router.query.school,
sname: event.target.sname.value,
status: event.target.status.value,
country: event.target.country.value,
state: event.target.state.value,
city: event.target.city.value,
annual: event.target.annual.value,
toddlers: event.target.toddlers.value,
early_start_programme: event.target.early_start_programme.value,
interakto: event.target.interakto.value,
agg_expiry: event.target.agg_expiry.value,
usage_expiry: event.target.usage_expiry.value,
phone: event.target.phone.value,
email: event.target.email.value,
}
const [school, setUser] = useState([]);
const fetchData = async () => {
const response = await fetch("https://management.beanstalkedu.com/items/school?filter[status][_eq]=published&");
const data = await response.json();
return setUser(data.data[0]);
}
// console.log(school.name)
useEffect(() => {
fetchData();
},[])
return (
<main>
<div>
<NavBar />
<div>
<h1>Items page</h1>
<p>{query.id}</p>
<p>{query.name}</p>
</div>
<section className='container mx-auto px-4 my-16 lg:px-28 xl:px-56 2xl:px-96'>
<div className='flex flex-col justify-center place-items-center bg-[#FFF6F2] pt-6 pb-20 rounded-tl-[50px] rounded-br-[50px]'>
<div className='flex flex-col justify-center place-items-center'>
<img src="/img/1.svg" alt="" />
<p className='text-2xl md:text-4xl font-bold underline decoration-4 decoration-[#FE4501] pb-10'>Update School Information</p>
</div>
<form onSubmit={handleSubmit} 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"value={school.name} 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>
<input type="text" 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]' />
</div>
<div className='flex flex-col w-full'>
<label htmlFor="country" className='text-xl font-bold'>Country</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="country" instanceId={useId()} options={options} value={countryValue}
onChange={selectCountry}/>
const JSONdata = JSON.stringify(data)
console.log(data)
const endpoint = '/api/editSchool'
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(`User data updated`)
}
return (
<main>
<div>
<NavBar/>
<section className='container mx-auto px-4 my-16 lg:px-28 xl:px-56 2xl:px-96'>
<div
className='flex flex-col justify-center place-items-center bg-[#FFF6F2] pt-6 pb-20 rounded-tl-[50px] rounded-br-[50px]'>
<div className='inline-flex p-4 '>
<Link href="/add-school-form" className="m-2 inline-flex place-items-center justify-center p-2 pl-4 pr-4 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
<img src="/img/4.svg" alt="" /> &nbsp;
List Users Under This School
</Link>
<div className="place-items-center justify-center m-2 p-2 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
<span className="text-small">CSV Upload &nbsp;</span>
<input type="file" />
</div>
{/* <img src="/img/2.svg" alt=""/> */}
</div>
<p className='text-2xl font-bold underline decoration-4 decoration-[#FE4501] pb-10'>Update School Information </p>
<form onSubmit={updateSchoolData} action="" className='w-full px-6 md:px-20'>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="sname" className='text-xl font-bold'>School Name</label>
<input value={school.sname} onChange={e => setSchool(e.target.value)} type="text" name="sname" className=' bg-white 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="status" className='text-xl font-bold'>Status</label>
<input value={school.status} onChange={e => setSchool(e.target.value)} type="text" name="status" className=' bg-white 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'>
<label htmlFor="phone" className='text-xl font-bold'>School contact Number</label>
<input value={school.phone} onChange={e => setSchool(e.target.value)} type="text" name="phone" 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'>
<label htmlFor="email" className='text-xl font-bold'> School contact Email ID</label>
<input value={school.email} onChange={e => setSchool(e.target.value)} type="text" name="email" 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'>
<label htmlFor="country" className='text-xl font-bold'>Country</label>
<input value={school.country} onChange={e => setSchool(e.target.value)} type="text" name="country" className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
</div>
{allStates && allStates.length > 0 &&
<div className='flex flex-col w-full'>
<label htmlFor="state" className='text-xl font-bold'>State</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="state" options={allStates} value={allStates[0].name}
onChange={handleSelectAllStates}/>
</div>}
{
allCities && allCities.length > 0 &&
<div className='flex flex-col w-full'>
<label htmlFor="Cities" className='text-xl font-bold'>Cities</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="cities" options={allCities} value={allCities[0].name}
// onChange={() => {}}
/>
</div>}
<div className='flex flex-col w-full'>
<label htmlFor="phone" className='text-xl font-bold'> Phone</label>
<PhoneInput className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' name="phone" placeholder="Enter phone number" value={phoneValue} onChange={setphoneValue}/>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="annual" className='text-xl font-bold'>annual</label>
<select name="annual" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0" >-NA-</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="toddlers" className='text-xl font-bold'>Toddlers</label>
<select name="toddlers" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0" >-NA-</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="early_start_programme" className='text-xl font-bold'>Early Start Program</label>
<select name="early_start_programme" className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0" >-NA-</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="interakto" className='text-xl font-bold'>Interakto</label>
<select name="interakto" className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="na">-NA-</option>
<option value="January"> January</option>
<option value="February"> February</option>
<option value="March"> March</option>
<option value="April"> April</option>
<option value="May"> May</option>
<option value="June"> June</option>
<option value="July"> July</option>
<option value="August"> August</option>
<option value="September"> September</option>
<option value="November"> November</option>
<option value="December"> December</option>
</select>
</div>
<div className='flex flex-col w-full'>
<label htmlFor="agreement_expiry_date" className='text-xl font-bold pt-4'>Agreement Expiry Date</label>
<input type="date" name="agreement_expiry_date" id="agreement_expiry_date" 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'>
<label htmlFor="school_agreement" className='text-xl font-bold pt-4'>Upload School Agreement</label>
<input type="file" name="school_agreement" id="school_agreement" className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
</div> */}
<div className='flex justify-center pt-8'>
{/* <a href="/school-list"><button type='submit' className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer'>Submit Now</button></a> */}
<input type="submit" value="Update" className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer' />
</div>
</form>
</div>
</section>
<input value={school.state} onChange={e => setSchool(e.target.value)} type="text" name="state" 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'>
<label htmlFor="city" className='text-xl font-bold'>Cities</label>
<input value={school.city} onChange={e => setSchool(e.target.value)} type="text" name="city" 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'>
<label htmlFor="annual" className='text-xl font-bold'>Annual</label>
<input value={school.annual} onChange={e => setSchool(e.target.value)} type="text" name="annual" placeholder='' 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'>
<label htmlFor="toddlers" className='text-xl font-bold'>Toddlers</label>
<input value={school.toddlers} onChange={e => setSchool(e.target.value)} type="text" name="toddlers" className=' bg-white 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'>
<label htmlFor="early_start_programme" className='text-xl font-bold'>Early Start Program</label>
<input value={school.early_start_programme} onChange={e => setSchool(e.target.value)} type="text" name="early_start_programme" className=' bg-white 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'>
<label htmlFor="interakto" className='text-xl font-bold'>Interakto</label>
<input value={school.interakto} onChange={e => setSchool(e.target.value)} type="text" name="interakto" className=' bg-white 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'>
<label htmlFor="usage_expiry" className='text-xl font-bold'> Usage Expiry Date: (YYYY-MM-DD)</label>
<input value={school.usage_expiry} onChange={e => setSchool(e.target.value)} type="text" name="usage_expiry" className=' bg-white 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'>
<label htmlFor="agg_expiry" className='text-xl font-bold'> Agreement Expiry Date: (YYYY-MM-DD)</label>
<input value={school.agg_expiry} onChange={e => setSchool(e.target.value)} type="text" name="agg_expiry" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
</div>
<div className='flex justify-center pt-8'>
<button type="submit"
className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer'>Update
</button>
</div>
</form>
</div>
<div className='flex flex-col w-full'>
<label htmlFor="agreement_documents" className='text-xl font-bold'>Upload Agreement Document&apos;s</label>
<input onChange={e => setSchool(e.target.value)} type="file" name="agreement_documents" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
<div className='flex justify-end pt-2'>
<button className=' bg-[#FE4501] px-4 py-1.5 rounded-lg text-white'>Download Agreement</button>
</div>
</main>
)
}
</div>
</section>
</div>
</main>
)
}

View File

@ -50,7 +50,7 @@ const fetchData = async () => {
</thead>
<tbody>
{school.map(data=>
<tr className="border-b-2 whitespace-normal">
<tr key={data.id} className="border-b-2 whitespace-normal">
<td className=" p-2">{data.id}</td>
<td className=" p-2">{data.sname}</td>
<td className="p-2">{data.city}</td>

View File

@ -1,241 +0,0 @@
import NavBar from '../../components/NavBar'
import {useRouter} from "next/router";
import { useId, useState, useEffect, useMemo } from 'react';
import Select from 'react-select'
import countryList from 'react-select-country-list'
import 'react-phone-number-input/style.css'
import PhoneInput from 'react-phone-number-input'
export default function addSchoolForm() {
const { query } = useRouter();
const [countryValue, setCountryValue] = useState('')
const options = useMemo(() => countryList().getData(), [])
const [phoneValue, setphoneValue] = useState()
const [allStates, setAllStates] = useState([])
const [allCities, setAllCities] = useState([])
const handleSelectAllStates = stateCode => {
setAllCities([])
fetch(`https://api.siliconpin.com/v3/list/country/city/?country=${countryValue.value}&state=${stateCode.value}`)
.then(res => res.json())
.then(data => {
// console.log("handleSelectAllStates:", data, options)
let newData = data && data.length > 0 && data.map(n => {
return {
label: n.name,
value: n.name
}
})
setAllCities(newData)
})
}
const selectCountry = countryValue => {
setAllStates([])
fetch(`https://api.siliconpin.com/v3/list/country/state/?country=${countryValue.value}`)
.then(res => res.json())
.then(data => {
// console.log("countryValue:", data, options)
let newData = data && data.length > 0 && data.map(n => {
return {
label: n.name,
value: n.iso2
}
})
setAllStates(newData)
setAllCities([])
})
setCountryValue(countryValue)
}
// 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,
annual: event.target.annual.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`)
}
const [school, setUser] = useState([]);
const fetchData = async () => {
const response = await fetch("https://management.beanstalkedu.com/items/school?filter[status][_eq]=published");
const data = await response.json();
return setUser(data.data[0]);
}
// console.log(school.name)
useEffect(() => {
fetchData();
},[])
return (
<main>
<div>
<NavBar />
<div>
<h1>Items page</h1>
<p>{query.id}</p>
<p>{query.name}</p>
</div>
<section className='container mx-auto px-4 my-16 lg:px-28 xl:px-56 2xl:px-96'>
<div className='flex flex-col justify-center place-items-center bg-[#FFF6F2] pt-6 pb-20 rounded-tl-[50px] rounded-br-[50px]'>
<div className='flex flex-col justify-center place-items-center'>
<img src="/img/1.svg" alt="" />
<p className='text-2xl md:text-4xl font-bold underline decoration-4 decoration-[#FE4501] pb-10'>Update School Information</p>
</div>
<form onSubmit={handleSubmit} 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"value={school.name} 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>
<input type="text" 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]' />
</div>
<div className='flex flex-col w-full'>
<label htmlFor="country" className='text-xl font-bold'>Country</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="country" instanceId={useId()} options={options} value={countryValue}
onChange={selectCountry}/>
</div>
{allStates && allStates.length > 0 &&
<div className='flex flex-col w-full'>
<label htmlFor="state" className='text-xl font-bold'>State</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="state" options={allStates} value={allStates[0].name}
onChange={handleSelectAllStates}/>
</div>}
{
allCities && allCities.length > 0 &&
<div className='flex flex-col w-full'>
<label htmlFor="Cities" className='text-xl font-bold'>Cities</label>
<Select
className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'
name="cities" options={allCities} value={allCities[0].name}
// onChange={() => {}}
/>
</div>}
<div className='flex flex-col w-full'>
<label htmlFor="phone" className='text-xl font-bold'> Phone</label>
<PhoneInput className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' name="phone" placeholder="Enter phone number" value={phoneValue} onChange={setphoneValue}/>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="annual" className='text-xl font-bold'>annual</label>
<select name="annual" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0" >-NA-</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="toddlers" className='text-xl font-bold'>Toddlers</label>
<select name="toddlers" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0" >-NA-</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="early_start_programme" className='text-xl font-bold'>Early Start Program</label>
<select name="early_start_programme" className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="0" >-NA-</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>
</div>
<div className='flex flex-col w-full pt-4'>
<label htmlFor="interakto" className='text-xl font-bold'>Interakto</label>
<select name="interakto" className='bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
<option value="na">-NA-</option>
<option value="January"> January</option>
<option value="February"> February</option>
<option value="March"> March</option>
<option value="April"> April</option>
<option value="May"> May</option>
<option value="June"> June</option>
<option value="July"> July</option>
<option value="August"> August</option>
<option value="September"> September</option>
<option value="November"> November</option>
<option value="December"> December</option>
</select>
</div>
<div className='flex flex-col w-full'>
<label htmlFor="agreement_expiry_date" className='text-xl font-bold pt-4'>Agreement Expiry Date</label>
<input type="date" name="agreement_expiry_date" id="agreement_expiry_date" 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'>
<label htmlFor="school_agreement" className='text-xl font-bold pt-4'>Upload School Agreement</label>
<input type="file" name="school_agreement" id="school_agreement" className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
</div> */}
<div className='flex justify-center pt-8'>
{/* <a href="/school-list"><button type='submit' className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer'>Submit Now</button></a> */}
<input type="submit" value="Update" className='bg-[#FE4501] hover:shadow-2xl hover:shadow-[#F2B705] p-2.5 rounded-lg px-10 rounded-tl-full rounded-br-full hover:scale-110 active:scale-75 duration-200 text-xl font-bold text-white cursor-pointer' />
</div>
</form>
</div>
</section>
</div>
</main>
)
}

View File

@ -1,8 +1,7 @@
import React, { useEffect, useState } from "react";
import Link from 'next/link'
import Image from 'next/image'
import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'] })
import NavBar from '../components/NavBar'
export default function Modal() {
const [user, setUser] = useState([]);
@ -26,14 +25,14 @@ const fetchData = async () => {
<div className="flex flex-row justify-end bg-[#FFF6F2] p-2 gap-x-4 border-x-2 border-t-2 rounded-t-xl">
<div className="flex flex-row justify-center place-items-center">
<input type="text" className="md:w-32 md:focus:w-96 duration-[1s] border-2 border-[#FE4501] w-full rounded-l-full p-2 focus:outline-none focus:border-[#F2B705] bg-[#FFF6F2] focus:bg-white text-center" placeholder="Search User" />
<a href="" className="bg-[#FE4501] rounded-r-full p-2 px-4 border-2 border-[#FE4501] text-white font-bold ">
<Link href="" className="bg-[#FE4501] rounded-r-full p-2 px-4 border-2 border-[#FE4501] text-white font-bold ">
<svg className="hover:scale-110 active:scale-75 duration-300" width="24px" height="24px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#ffffff"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill="#ffffff" fill-rule="evenodd" d="M4 9a5 5 0 1110 0A5 5 0 014 9zm5-7a7 7 0 104.2 12.6.999.999 0 00.093.107l3 3a1 1 0 001.414-1.414l-3-3a.999.999 0 00-.107-.093A7 7 0 009 2z"></path> </g></svg>
</a>
</Link>
</div>
<a href="/add-user-form" className="inline-flex place-items-center p-2 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
<Link href="/add-user-form" className="inline-flex place-items-center p-2 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
<svg className="font-bold" width="25px" height="25px" viewBox="0 0 21 21" xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#ffffff"><g id="SVGRepo_bgCarrier" stroke-width="2"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g fill="none" fill-rule="evenodd" stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" transform="translate(3 2)"> <path d="m7.5.5c1.65685425 0 3 1.34314575 3 3v2c0 1.65685425-1.34314575 3-3 3s-3-1.34314575-3-3v-2c0-1.65685425 1.34314575-3 3-3z"></path> <path d="m14.5 2.5v4"></path> <path d="m16.5 4.5h-4"></path> <path d="m14.5 14.5v-.7281753c0-3.1864098-3.6862915-5.2718247-7-5.2718247s-7 2.0854149-7 5.2718247v.7281753c0 .5522847.44771525 1 1 1h12c.5522847 0 1-.4477153 1-1z"></path> </g> </g></svg>
Add User
</a>
</Link>
</div>
<div className='flex overflow-x-scroll xl:justify-center'>
<table className=" text-center border-2 p-2 w-full">
@ -52,7 +51,7 @@ const fetchData = async () => {
<tbody>
{user.map
(data=>
<tr className="border-b-2 whitespace-normal text-left">
<tr key={data.id} className="border-b-2 whitespace-normal text-left">
<td className="border-x-2 p-2 text-center">{data.uname}</td>
<td className="border-x-2 p-2 text-center">{data.phone}</td>
<td className="border-x-2 p-2 text-center">{data.email}</td>

View File

@ -1,8 +1,5 @@
import React, { useEffect, useState } from "react";
import Image from 'next/image'
import { Inter } from 'next/font/google'
const inter = Inter({ subsets: ['latin'] })
import Link from 'next/link'
import NavBar from '../components/NavBar'
export default function Modal() {
const [user, setUser] = useState([]);
@ -30,10 +27,10 @@ const fetchData = async () => {
<svg className="hover:scale-110 active:scale-75 duration-300" width="24px" height="24px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#ffffff"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill="#ffffff" fill-rule="evenodd" d="M4 9a5 5 0 1110 0A5 5 0 014 9zm5-7a7 7 0 104.2 12.6.999.999 0 00.093.107l3 3a1 1 0 001.414-1.414l-3-3a.999.999 0 00-.107-.093A7 7 0 009 2z"></path> </g></svg>
</a>
</div>
<a href="/add-user-form" className="inline-flex place-items-center p-2 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
<Link href="/add-user-form" className="inline-flex place-items-center p-2 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
<svg className="font-bold" width="25px" height="25px" viewBox="0 0 21 21" xmlns="http://www.w3.org/2000/svg" fill="#ffffff" stroke="#ffffff"><g id="SVGRepo_bgCarrier" stroke-width="2"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g fill="none" fill-rule="evenodd" stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" transform="translate(3 2)"> <path d="m7.5.5c1.65685425 0 3 1.34314575 3 3v2c0 1.65685425-1.34314575 3-3 3s-3-1.34314575-3-3v-2c0-1.65685425 1.34314575-3 3-3z"></path> <path d="m14.5 2.5v4"></path> <path d="m16.5 4.5h-4"></path> <path d="m14.5 14.5v-.7281753c0-3.1864098-3.6862915-5.2718247-7-5.2718247s-7 2.0854149-7 5.2718247v.7281753c0 .5522847.44771525 1 1 1h12c.5522847 0 1-.4477153 1-1z"></path> </g> </g></svg>
Add User
</a>
</Link>
</div>
<div className='flex overflow-x-scroll xl:justify-center'>
<table className=" text-center border-2 p-2 w-full">
@ -52,7 +49,7 @@ const fetchData = async () => {
<tbody>
{user.map
(data=>
<tr className="border-b-2 whitespace-normal text-left">
<tr key={data.id} className="border-b-2 whitespace-normal text-left">
<td className="border-x-2 p-2 text-center">{data.uname}</td>
<td className="border-x-2 p-2 text-center">{data.phone}</td>
<td className="border-x-2 p-2 text-center">{data.email}</td>

View File

@ -2245,6 +2245,11 @@ jws@^3.2.2:
jwa "^1.4.1"
safe-buffer "^5.0.1"
jwt-decode@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/jwt-decode/-/jwt-decode-3.1.2.tgz#3fb319f3675a2df0c2895c8f5e9fa4b67b04ed59"
integrity sha512-UfpWE/VZn0iP50d8cz9NrZLM9lSWhcJ+0Gt/nm4by88UL+J1SiKN8/5dkjMmbEzwL2CAe+67GsegCbIKtbp75A==
language-subtag-registry@~0.3.2:
version "0.3.22"
resolved "https://registry.yarnpkg.com/language-subtag-registry/-/language-subtag-registry-0.3.22.tgz#2e1500861b2e457eba7e7ae86877cbd08fa1fd1d"