main2
parent
27657679d7
commit
4ea8d4d839
BIN
data/appUser.db
BIN
data/appUser.db
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
uname,status,user,type,year,start_month,start_date,end_date,plan,klas,lang,phone,pass,anual,early_start_programme,toddlers,interakto,email,country,state,city,address,school
|
||||
uname,status,user,type,year,start_month,start_date,end_date,plan,klas,lang,phone,pass,annual,early_start_programme,toddlers,interakto,email,country,state,city,address,school
|
||||
name 1,published,,parent,,Feb,2023-05-14,2024-05-13,,IK2,,70000000011,,Jan,Feb,Mar,Jul,1@email.com,IN,WB,Habra,sample road near landmark,individual
|
||||
name 5,published,,parent,,Feb,2023-05-14,2024-05-13,,IK2,,70000000011,,Jan,Feb,Mar,Jul,5@email.com,IN,WB,Habra,sample road near landmark,individual
|
||||
name 4,published,,parent,,Feb,2023-05-14,2024-05-13,,IK2,,70000000011,,Jan,Feb,Mar,Jul,4@email.com,IN,WB,Habra,sample road near landmark,individual
|
||||
|
|
|
|
@ -0,0 +1 @@
|
|||
<svg width="20px" height="20px" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" 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 d="M7.5 4.5L11.5 6.5V14.5H3.5V6.5L7.5 4.5ZM7.5 4.5V0M0 14.5H15M1.5 14.5V8.5H3.5M13.5 14.5V8.5H11.5M6.5 14.5V11.5H8.5V14.5M7.5 0.5H10.5V2.5H7.5M7.5 9.5C6.94772 9.5 6.5 9.05228 6.5 8.5C6.5 7.94772 6.94772 7.5 7.5 7.5C8.05228 7.5 8.5 7.94772 8.5 8.5C8.5 9.05228 8.05228 9.5 7.5 9.5Z" stroke="#ffffff"></path> </g></svg>
|
After Width: | Height: | Size: 595 B |
|
@ -29,7 +29,7 @@ export default function Modal() {
|
|||
country: event.target.country.value,
|
||||
state: event.target.state.value,
|
||||
cities: event.target.cities.value,
|
||||
anual: event.target.anual.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,
|
||||
|
@ -119,8 +119,8 @@ export default function Modal() {
|
|||
<label htmlFor="phone" className='text-xl font-bold'> Phone</label>
|
||||
</div>
|
||||
<div className='flex flex-col w-full pt-4'>
|
||||
<label htmlFor="anual" className='text-xl font-bold'>Anual</label>
|
||||
<select name="anual" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
|
||||
<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>
|
||||
|
|
|
@ -52,23 +52,23 @@ export default function addSchoolForm() {
|
|||
event.preventDefault()
|
||||
const data = {
|
||||
"status":"published",
|
||||
name: event.target.schoolName.value,
|
||||
sname: event.target.sname.value,
|
||||
country: event.target.country.value,
|
||||
state: event.target.state.value,
|
||||
cities: event.target.cities.value,
|
||||
anual: event.target.anual.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,
|
||||
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,
|
||||
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 JSONdata = JSON.stringify(data)
|
||||
console.log(data)
|
||||
const endpoint = 'https://management.beanstalkedu.com/items/school'
|
||||
const endpoint = '/api/addSchool'
|
||||
const options = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -96,11 +96,11 @@ export default function addSchoolForm() {
|
|||
<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" placeholder='School Name' className='border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
|
||||
<input type="text" name="sname" 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]' />
|
||||
<label htmlFor="email" className='text-xl font-bold'> Email ID</label>
|
||||
<input type="text" name="email" id="email" 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>
|
||||
|
@ -120,10 +120,10 @@ export default function addSchoolForm() {
|
|||
{
|
||||
allCities && allCities.length > 0 &&
|
||||
<div className='flex flex-col w-full'>
|
||||
<label htmlFor="Cities" className='text-xl font-bold'>Cities</label>
|
||||
<label htmlFor="cyti" 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="cities" options={allCities} value={allCities[0].name}
|
||||
name="city" options={allCities} value={allCities[0].name}
|
||||
// onChange={() => {}}
|
||||
/>
|
||||
</div>}
|
||||
|
@ -132,8 +132,8 @@ export default function addSchoolForm() {
|
|||
<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="anual" className='text-xl font-bold'>Anual</label>
|
||||
<select name="anual" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
|
||||
<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>
|
||||
|
@ -168,7 +168,7 @@ export default function addSchoolForm() {
|
|||
</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>
|
||||
<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>
|
||||
|
@ -203,8 +203,12 @@ export default function addSchoolForm() {
|
|||
</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]' />
|
||||
<label htmlFor="agg_expiry" className='text-xl font-bold pt-4'>Agreement Expiry Date</label>
|
||||
<input type="date" name="agg_expiry" id="agg_expiry" 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="usage_expiry" className='text-xl font-bold pt-4'>Usage Expiry Date</label>
|
||||
<input type="date" name="usage_expiry" id="usage_expiry" 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>
|
||||
|
|
|
@ -102,7 +102,7 @@ export default function addUserForm() {
|
|||
start_month: event.target.start_month.value,
|
||||
start_date: event.target.start_date.value,
|
||||
end_date: event.target.end_date.value,
|
||||
anual: event.target.anual.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,
|
||||
|
@ -242,8 +242,8 @@ export default function addUserForm() {
|
|||
{individualValue &&
|
||||
<div>
|
||||
<div className='flex flex-col w-full pt-4'>
|
||||
<label htmlFor="anual" className='text-xl font-bold'>Anual</label>
|
||||
<select name="anual" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
|
||||
<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>
|
||||
|
|
|
@ -98,7 +98,7 @@ export default function addUserForm() {
|
|||
start_month: event.target.start_month.value,
|
||||
start_date: event.target.start_date.value,
|
||||
end_date: event.target.end_date.value,
|
||||
anual: event.target.anual.value,
|
||||
annual: event.target.annual.value,
|
||||
}
|
||||
const JSONdata = JSON.stringify(data)
|
||||
const endpoint = '/api/addUsers'
|
||||
|
@ -234,8 +234,8 @@ export default function addUserForm() {
|
|||
{individualValue &&
|
||||
<div>
|
||||
<div className='flex flex-col w-full pt-4'>
|
||||
<label htmlFor="anual" className='text-xl font-bold'>Anual</label>
|
||||
<select name="anual"
|
||||
<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>
|
||||
|
@ -256,8 +256,8 @@ export default function addUserForm() {
|
|||
<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="Anual">Anual</label>
|
||||
<input type="checkbox" name="plan" id="Anual" value='Anual' className='check-box'/>
|
||||
<label className='cursor-pointer' htmlFor="annual">annual</label>
|
||||
<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>
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
export default function handler(req, res) {
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
|
||||
// console.log(req.body)
|
||||
// Open a new database connection
|
||||
let sname, status, phone, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, agg_expiry, usage_expiry = "";
|
||||
|
||||
if(req.body.sname) sname =req.body.sname;
|
||||
// if(req.body.status) status =req.body.status;
|
||||
if(req.body.status) status ="published";
|
||||
if(req.body.phone) phone =req.body.phone;
|
||||
if(req.body.annual) annual =req.body.annual;
|
||||
if(req.body.early_start_programme) early_start_programme =req.body.early_start_programme;
|
||||
if(req.body.toddlers) toddlers =req.body.toddlers;
|
||||
if(req.body.interakto) interakto =req.body.interakto;
|
||||
if(req.body.email) email =req.body.email;
|
||||
if(req.body.country) country =req.body.country;
|
||||
if(req.body.state) state =req.body.state;
|
||||
if(req.body.city) city =req.body.city;
|
||||
if(req.body.address) address =req.body.address;
|
||||
if(req.body.agg_expiry) agg_expiry =req.body.agg_expiry;
|
||||
if(req.body.usage_expiry) usage_expiry =req.body.usage_expiry;
|
||||
|
||||
const db = new sqlite3.Database('data/appUser.db');
|
||||
db.run(`INSERT INTO school (sname, status, phone, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, agg_expiry, usage_expiry ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [ sname, status, phone, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, agg_expiry, usage_expiry],
|
||||
function(err) {
|
||||
if (err) {
|
||||
return console.log(err.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
db.close();
|
||||
|
||||
|
||||
res.status(200).json({ msg: 'ok' });
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ export default function handler(req, res) {
|
|||
|
||||
console.log(req.body)
|
||||
// Open a new database connection
|
||||
let uname, status, type, start_month, start_date, end_date, plan, klas, lang, phone, pass, anual, early_start_programme, toddlers, interakto, email, country, state, city, address, school="";
|
||||
let uname, status, type, start_month, start_date, end_date, plan, klas, lang, phone, pass, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, school="";
|
||||
|
||||
if(req.body.uname) uname =req.body.uname;
|
||||
if(req.body.status) status =req.body.status;
|
||||
|
@ -15,10 +15,9 @@ export default function handler(req, res) {
|
|||
if(req.body.plan) plan =req.body.plan;
|
||||
if(req.body.klas) klas =req.body.klas;
|
||||
if(req.body.lang) lang =req.body.lang;
|
||||
if(req.body.lang) lang =req.body.lang;
|
||||
if(req.body.phone) phone =req.body.phone;
|
||||
if(req.body.pass) pass =req.body.pass;
|
||||
if(req.body.anual) anual =req.body.anual;
|
||||
if(req.body.annual) annual =req.body.annual;
|
||||
if(req.body.early_start_programme) early_start_programme =req.body.early_start_programme;
|
||||
if(req.body.toddlers) toddlers =req.body.toddlers;
|
||||
if(req.body.interakto) interakto =req.body.interakto;
|
||||
|
@ -29,7 +28,7 @@ export default function handler(req, res) {
|
|||
if(req.body.address) address =req.body.address;
|
||||
if(req.body.school) school =req.body.school;
|
||||
const db = new sqlite3.Database('data/appUser.db');
|
||||
db.run(`INSERT INTO user (uname, status, type, start_month, start_date, end_date, plan, klas, lang, phone, pass, anual, early_start_programme, toddlers, interakto, email, country, state, city, address, school ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [ uname, status, type, start_month, start_date, end_date, plan, klas, lang, phone, pass, anual, early_start_programme, toddlers, interakto, email, country, state, city, address, school],
|
||||
db.run(`INSERT INTO user (uname, status, type, start_month, start_date, end_date, plan, klas, lang, phone, pass, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, school ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [ uname, status, type, start_month, start_date, end_date, plan, klas, lang, phone, pass, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, school],
|
||||
function(err) {
|
||||
if (err) {
|
||||
return console.log(err.message);
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
export default function handler(req, res) {
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
|
||||
console.log(req.body)
|
||||
|
||||
// Open a new database connection
|
||||
let sname, status, phone, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, agg_expiry, usage_expiry = "";
|
||||
|
||||
if(req.body.sname) sname =req.body.sname;
|
||||
if(req.body.status) status =req.body.status;
|
||||
// if(req.body.status) status ="published";
|
||||
if(req.body.phone) phone =req.body.phone;
|
||||
if(req.body.annual) annual =req.body.annual;
|
||||
if(req.body.early_start_programme) early_start_programme =req.body.early_start_programme;
|
||||
if(req.body.toddlers) toddlers =req.body.toddlers;
|
||||
if(req.body.interakto) interakto =req.body.interakto;
|
||||
if(req.body.email) email =req.body.email;
|
||||
if(req.body.country) country =req.body.country;
|
||||
if(req.body.state) state =req.body.state;
|
||||
if(req.body.city) city =req.body.city;
|
||||
if(req.body.address) address =req.body.address;
|
||||
if(req.body.agg_expiry) agg_expiry =req.body.agg_expiry;
|
||||
if(req.body.usage_expiry) usage_expiry =req.body.usage_expiry;
|
||||
|
||||
const db = new sqlite3.Database('data/appUser.db');
|
||||
console.log(req.body.userId)
|
||||
db.run(`UPDATE school SET sname = ?, status = ?, phone = ?, annual = ?, early_start_programme = ?, toddlers = ?, interakto = ?, email = ?, country = ?, state = ?, city = ?, address = ?, agg_expiry = ?, usage_expiry = ? WHERE id = ? `, [ sname, status, phone, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, agg_expiry, usage_expiry, req.body.schoolId],
|
||||
function(err) {
|
||||
if (err) {
|
||||
res.status(400).json({ msg: 'Err400D' });
|
||||
return console.log(err.message);
|
||||
}
|
||||
res.status(200).json({ msg: 'ok' });
|
||||
}
|
||||
);
|
||||
db.close();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ export default function handler(req, res) {
|
|||
|
||||
console.log(req.body)
|
||||
// Open a new database connection
|
||||
let uname, status, type, start_month, start_date, end_date, klas, lang, phone, pass, anual, early_start_programme, toddlers, interakto, email, country, state, city, address, school="";
|
||||
let uname, status, type, start_month, start_date, end_date, klas, lang, phone, pass, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, school="";
|
||||
|
||||
if(req.body.uname) uname =req.body.uname;
|
||||
if(req.body.status) status =req.body.status;
|
||||
|
@ -15,7 +15,7 @@ export default function handler(req, res) {
|
|||
if(req.body.lang) lang =req.body.lang;
|
||||
if(req.body.phone) phone =req.body.phone;
|
||||
if(req.body.pass) pass =req.body.pass;
|
||||
if(req.body.anual) anual =req.body.anual;
|
||||
if(req.body.annual) annual =req.body.annual;
|
||||
if(req.body.early_start_programme) early_start_programme =req.body.early_start_programme;
|
||||
if(req.body.toddlers) toddlers =req.body.toddlers;
|
||||
if(req.body.interakto) interakto =req.body.interakto;
|
||||
|
@ -27,7 +27,7 @@ export default function handler(req, res) {
|
|||
if(req.body.school) school =req.body.school;
|
||||
const db = new sqlite3.Database('data/appUser.db');
|
||||
console.log(req.body.userId)
|
||||
db.run(`UPDATE user SET uname = ?, status = ?, type = ?, start_month = ?, start_date = ?, end_date = ?, klas = ?, lang = ?, phone = ?, anual = ?, early_start_programme = ?, toddlers = ?, interakto = ?, email = ?, country = ?, state = ?, city = ?, address = ?, school = ? WHERE id = ? `, [ uname, status, type, start_month, start_date, end_date, klas, lang, phone, anual, early_start_programme, toddlers, interakto, email, country, state, city, address, school, req.body.userId],
|
||||
db.run(`UPDATE user SET uname = ?, status = ?, type = ?, start_month = ?, start_date = ?, end_date = ?, klas = ?, lang = ?, phone = ?, annual = ?, early_start_programme = ?, toddlers = ?, interakto = ?, email = ?, country = ?, state = ?, city = ?, address = ?, school = ? WHERE id = ? `, [ uname, status, type, start_month, start_date, end_date, klas, lang, phone, annual, early_start_programme, toddlers, interakto, email, country, state, city, address, school, req.body.userId],
|
||||
function(err) {
|
||||
if (err) {
|
||||
res.status(400).json({ msg: 'Err400D' });
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
import csv from 'csv-parser';
|
||||
import fs from 'fs';
|
||||
import sqlite3 from 'sqlite3';
|
||||
|
||||
export default function handler(req,res) {
|
||||
|
||||
|
||||
const DB_NAME = 'data/appUser.db';
|
||||
const TABLE_NAME = 'school';
|
||||
|
||||
const db = new sqlite3.Database(DB_NAME);
|
||||
|
||||
const query = `SELECT * FROM ${TABLE_NAME}`;
|
||||
|
||||
function getAllRows(tableName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const sql = `SELECT * FROM ${tableName} WHERE id = ?`;
|
||||
db.all(sql, [req.query.school], (err, rows) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
const data = rows;
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
};
|
||||
async function doSomething() {
|
||||
try {
|
||||
const returnData = await getAllRows('school');
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
res.status(200).json(returnData)
|
||||
// console.log(data);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
doSomething();
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
import csv from 'csv-parser';
|
||||
import fs from 'fs';
|
||||
import sqlite3 from 'sqlite3';
|
||||
|
||||
export default function handler(req,res) {
|
||||
|
||||
console.log(req.body.school)
|
||||
// const {
|
||||
// query: { name, keyword },
|
||||
// method,
|
||||
// } = req;
|
||||
// console.log(name, keyword, method);
|
||||
|
||||
const DB_NAME = 'data/appUser.db';
|
||||
const TABLE_NAME = 'school';
|
||||
|
||||
// Open a connection to the SQLite database
|
||||
const db = new sqlite3.Database(DB_NAME);
|
||||
|
||||
const query = `SELECT * FROM ${TABLE_NAME}`;
|
||||
|
||||
function getAllRows(tableName) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const sql = `SELECT * FROM ${tableName}`;
|
||||
db.all(sql, [], (err, rows) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
const data = rows;
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
};
|
||||
async function doSomething() {
|
||||
try {
|
||||
const returnData = await getAllRows(TABLE_NAME);
|
||||
res.setHeader('Content-Type', 'application/json')
|
||||
res.status(200).json(returnData)
|
||||
// console.log(data);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
doSomething();
|
||||
// const returnData = getAllRows('user');
|
||||
// console.log(getAllRows('user'));
|
||||
// const returnData= db.run('SELECT * FROM user');
|
||||
|
||||
// fs.createReadStream('data/user.csv')
|
||||
// .pipe(csv())
|
||||
// .on('data', (data) => {
|
||||
// const values = Object.values(data);
|
||||
// const placeholders = values.map(() => '?').join(',');
|
||||
// const sql = `INSERT INTO ${TABLE_NAME} (${Object.keys(data).join(',')}) VALUES (${placeholders})`;
|
||||
// db.run(sql, values, (err) => {
|
||||
// if (err) {
|
||||
// console.error(err);
|
||||
// }
|
||||
// });
|
||||
// })
|
||||
// .on('end', () => {
|
||||
// console.log(`Data inserted successfully into table ${TABLE_NAME}`);
|
||||
|
||||
// // Close the database connection
|
||||
// db.close();
|
||||
// });
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
export default function handler(req, res) {
|
||||
// const sqlite3 = require('sqlite3').verbose();
|
||||
|
||||
console.log(req.body)
|
||||
// console.log(req.body)
|
||||
const sqlite3 = require('sqlite3');
|
||||
const argon2 = require('argon2');
|
||||
const jwt = require('jsonwebtoken');
|
||||
|
@ -10,8 +10,9 @@ const jwt = require('jsonwebtoken');
|
|||
const db = new sqlite3.Database('data/appUser.db');
|
||||
|
||||
// Fetch the user record
|
||||
const username = 'example_user';
|
||||
const sql = 'SELECT pass FROM user_table WHERE username = ?';
|
||||
const username = req.body.email;
|
||||
// console.log(username)
|
||||
const sql = 'SELECT * FROM user WHERE email = ?';
|
||||
db.get(sql, [username], async (err, userRecord) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
|
@ -19,8 +20,9 @@ db.get(sql, [username], async (err, userRecord) => {
|
|||
}
|
||||
|
||||
if (userRecord) {
|
||||
const storedHash = userRecord.password_hash;
|
||||
const providedPassword = 'example_password';
|
||||
const storedHash = userRecord.pass;
|
||||
console.log(storedHash)
|
||||
const providedPassword = req.body.password;
|
||||
|
||||
try {
|
||||
// Verify the provided password with the stored hash
|
||||
|
@ -28,19 +30,37 @@ db.get(sql, [username], async (err, userRecord) => {
|
|||
|
||||
if (isPasswordValid) {
|
||||
// Passwords match, generate JWT token
|
||||
const secretKey = process.env.JWT_SEC;
|
||||
const tokenPayload = { username: username };
|
||||
const secretKey = process.env.TOKEN_HEADER_KEY;
|
||||
const tokenPayload = {
|
||||
email:userRecord.email,
|
||||
role: userRecord.type,
|
||||
iat: Math.floor(Date.now() / 1000),
|
||||
exp: Math.floor(Date.now() / 1000) + 3600*24*7,
|
||||
|
||||
};
|
||||
const jwtToken = jwt.sign(tokenPayload, secretKey, { algorithm: 'HS256' });
|
||||
const jwtTokenData ={
|
||||
data:{
|
||||
access_token:jwtToken,
|
||||
role: userRecord.type,
|
||||
email: userRecord.email,
|
||||
expires: 3600*24*7,
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
// Return the JWT token
|
||||
res.status(200).json(jwtTokenData);
|
||||
console.log(jwtToken);
|
||||
} else {
|
||||
console.log('Invalid password');
|
||||
res.status(400).json({err:'400P'});
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
} else {
|
||||
res.status(400).json({err:'400U'});
|
||||
console.log('User not found');
|
||||
}
|
||||
|
||||
|
@ -48,5 +68,5 @@ db.get(sql, [username], async (err, userRecord) => {
|
|||
db.close();
|
||||
});
|
||||
|
||||
res.status(200).json({ name: 'John Doe' });
|
||||
// res.status(200).json({ name: 'John Doe' });
|
||||
}
|
|
@ -33,7 +33,7 @@ export default function addSchoolForm() {
|
|||
country: event.target.country.value,
|
||||
state: event.target.state.value,
|
||||
cities: event.target.cities.value,
|
||||
anual: event.target.anual.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,
|
||||
|
@ -100,8 +100,8 @@ export default function addSchoolForm() {
|
|||
<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="anual" className='text-xl font-bold'>Anual</label>
|
||||
<input type="text" value={school.anual} onChange={e => setSchool(e.target.value)} />
|
||||
<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>
|
||||
|
|
|
@ -6,62 +6,43 @@ import { useRouter } from 'next/router'
|
|||
export default function editSchool() {
|
||||
const router = useRouter();
|
||||
|
||||
// const updateSchoolData = 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 [school, setSchool] = useState({});
|
||||
|
||||
useEffect(()=>{
|
||||
// console.log(router.query);
|
||||
// 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?school=${router.query.school}`)
|
||||
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.data[0])
|
||||
// console.log(data.data)
|
||||
|
||||
console.log(data);
|
||||
setSchool(data[0])
|
||||
// console.log(school)
|
||||
})
|
||||
}
|
||||
// console.log(data.data)
|
||||
|
||||
|
||||
}, [router.query.school]);
|
||||
|
||||
const updateSchoolData = async (event) => {
|
||||
event.preventDefault()
|
||||
const data = {
|
||||
// schoolId: router.query.school,
|
||||
name: event.target.name.value,
|
||||
// status: event.target.status.value,
|
||||
// uname: event.target.uname.value,
|
||||
// country: event.target.country.value,
|
||||
// state: event.target.state.value,
|
||||
// city: event.target.city.value,
|
||||
// address: event.target.address.value,
|
||||
// start_date: event.target.start_date.value,
|
||||
// end_date: event.target.end_date.value,
|
||||
// school: event.target.school.value,
|
||||
// anual: event.target.anual.value,
|
||||
// toddlers: event.target.toddlers.value,
|
||||
// early_start_programme: event.target.early_start_programme.value,
|
||||
// email: event.target.email.value,
|
||||
// phone: event.target.phone.value,
|
||||
// klas: event.target.klas.value
|
||||
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 JSONdata = JSON.stringify(data)
|
||||
// console.log(data)
|
||||
const endpoint = 'https://management.beanstalkedu.com/items/school'
|
||||
console.log(data)
|
||||
const endpoint = '/api/editSchool'
|
||||
const options = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -70,9 +51,10 @@ export default function editSchool() {
|
|||
body: JSONdata,
|
||||
}
|
||||
const response = await fetch(endpoint, options)
|
||||
|
||||
const result = await response.json()
|
||||
// alert(`Is this your full name: ${result.data}`)
|
||||
alert(`School data updated`)
|
||||
alert(`User data updated`)
|
||||
|
||||
}
|
||||
|
||||
|
@ -83,55 +65,81 @@ export default function editSchool() {
|
|||
<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 School Information </p>
|
||||
<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">
|
||||
<img src="/img/4.svg" alt="" />
|
||||
List Users Under This School
|
||||
</a>
|
||||
<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 </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="school_name" className='text-xl font-bold'>School Name</label>
|
||||
<input value={school.name} onChange={e => setSchool(e.target.value)} type="text" name="school_name" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
|
||||
<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="mobile" className='text-xl font-bold'>Mobile Number</label>
|
||||
<input onChange={e => setSchool(e.target.value)} type="text" name="mobile" className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
|
||||
<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'>Email ID</label>
|
||||
<input 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]' />
|
||||
<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 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]' />
|
||||
<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>
|
||||
<div className='flex flex-col w-full'>
|
||||
<label htmlFor="State" className='text-xl font-bold'>State</label>
|
||||
<input 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]' />
|
||||
<label htmlFor="state" className='text-xl font-bold'>State</label>
|
||||
<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="cities" className='text-xl font-bold'>Cities</label>
|
||||
<input onChange={e => setSchool(e.target.value)} type="text" name="cities" className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
|
||||
<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 onChange={e => setSchool(e.target.value)} type="email" name="annual" placeholder='' className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'/>
|
||||
<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 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]' />
|
||||
<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_program" className='text-xl font-bold'>Early Start Program</label>
|
||||
<input onChange={e => setSchool(e.target.value)} type="text" name="early_start_program" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
|
||||
<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 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]' />
|
||||
<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="agreement_expiry_date" className='text-xl font-bold'> Agreement Expiry Date: (YYYY-MM-DD)</label>
|
||||
<input onChange={e => setSchool(e.target.value)} type="text" name="agreement_expiry_date" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
|
||||
<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'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]' />
|
||||
|
@ -142,15 +150,10 @@ export default function editSchool() {
|
|||
</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>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ export default function addSchoolForm() {
|
|||
country: event.target.country.value,
|
||||
state: event.target.state.value,
|
||||
cities: event.target.cities.value,
|
||||
anual: event.target.anual.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,
|
||||
|
@ -110,8 +110,8 @@ export default function addSchoolForm() {
|
|||
<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="anual" className='text-xl font-bold'>Anual</label>
|
||||
<input type="text" value={school.anual} onChange={e => setSchool(e.target.value)} className='border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
|
||||
<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>
|
||||
|
|
|
@ -23,7 +23,7 @@ export default function editUser() {
|
|||
// if(router.query.school<1) {
|
||||
// const { sid } = router.query;
|
||||
// setSchool(sid)
|
||||
if(router.query.user && router.query.user>1 ){
|
||||
if(router.query.user && router.query.user>0 ){
|
||||
fetch(`/api/getUserDetails?user=${router.query.user}`)
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
|
@ -49,7 +49,7 @@ export default function editUser() {
|
|||
start_date: event.target.start_date.value,
|
||||
end_date: event.target.end_date.value,
|
||||
school: event.target.school.value,
|
||||
anual: event.target.anual.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,
|
||||
|
@ -145,8 +145,8 @@ export default function editUser() {
|
|||
<input value={user.klas} onChange={e => setUser(e.target.value)} type="text" name="klas" 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="anual" className='text-xl font-bold'>anual</label>
|
||||
<input value={user.anual} onChange={e => setUser(e.target.value)} type="text" name="anual" className=' border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]' />
|
||||
<label htmlFor="annual" className='text-xl font-bold'>annual</label>
|
||||
<input value={user.annual} onChange={e => setUser(e.target.value)} type="text" name="annual" 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 Programme</label>
|
||||
|
|
|
@ -121,7 +121,7 @@ export default function addUserForm() {
|
|||
start_month: event.target.start_month.value,
|
||||
start_date: event.target.start_date.value,
|
||||
end_date: event.target.end_date.value,
|
||||
anual: event.target.anual.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,
|
||||
|
@ -258,8 +258,8 @@ export default function addUserForm() {
|
|||
{individualValue &&
|
||||
<div>
|
||||
<div className='flex flex-col w-full pt-4'>
|
||||
<label htmlFor="anual" className='text-xl font-bold'>Anual</label>
|
||||
<select name="anual" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
|
||||
<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>
|
||||
|
|
|
@ -58,7 +58,7 @@ export default function addSchoolForm() {
|
|||
country: event.target.country.value,
|
||||
state: event.target.state.value,
|
||||
cities: event.target.cities.value,
|
||||
anual: event.target.anual.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,
|
||||
|
@ -150,8 +150,8 @@ export default function addSchoolForm() {
|
|||
<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="anual" className='text-xl font-bold'>Anual</label>
|
||||
<select name="anual" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
|
||||
<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>
|
||||
|
|
|
@ -5,11 +5,11 @@ import { Inter } from 'next/font/google'
|
|||
const inter = Inter({ subsets: ['latin'] })
|
||||
import NavBar from '../../components/NavBar'
|
||||
export default function Modal() {
|
||||
const [school, setUser] = useState([]);
|
||||
const [school, setSchool] = useState([]);
|
||||
const fetchData = async () => {
|
||||
const response = await fetch("https://management.beanstalkedu.com/items/school?filter[status][_eq]=published");
|
||||
const response = await fetch("/api/listSchlools");
|
||||
const data = await response.json();
|
||||
return setUser(data.data);
|
||||
return setSchool(data);
|
||||
}
|
||||
console.log(school)
|
||||
|
||||
|
@ -33,14 +33,7 @@ const fetchData = async () => {
|
|||
<svg width="20px" height="20px" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" 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 d="M7.5 4.5L11.5 6.5V14.5H3.5V6.5L7.5 4.5ZM7.5 4.5V0M0 14.5H15M1.5 14.5V8.5H3.5M13.5 14.5V8.5H11.5M6.5 14.5V11.5H8.5V14.5M7.5 0.5H10.5V2.5H7.5M7.5 9.5C6.94772 9.5 6.5 9.05228 6.5 8.5C6.5 7.94772 6.94772 7.5 7.5 7.5C8.05228 7.5 8.5 7.94772 8.5 8.5C8.5 9.05228 8.05228 9.5 7.5 9.5Z" stroke="#ffffff"></path> </g></svg>
|
||||
Add School
|
||||
</a> */}
|
||||
<a href="/add-school-form" className="inline-flex place-items-center justify-center p-2 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
|
||||
<svg width="20px" height="20px" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" 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 d="M7.5 4.5L11.5 6.5V14.5H3.5V6.5L7.5 4.5ZM7.5 4.5V0M0 14.5H15M1.5 14.5V8.5H3.5M13.5 14.5V8.5H11.5M6.5 14.5V11.5H8.5V14.5M7.5 0.5H10.5V2.5H7.5M7.5 9.5C6.94772 9.5 6.5 9.05228 6.5 8.5C6.5 7.94772 6.94772 7.5 7.5 7.5C8.05228 7.5 8.5 7.94772 8.5 8.5C8.5 9.05228 8.05228 9.5 7.5 9.5Z" stroke="#ffffff"></path> </g></svg>
|
||||
List Users Under This School
|
||||
</a>
|
||||
<div className="inline-flex place-items-center justify-center p-2 bg-[#FE4501] text-white font-bold rounded-full whitespace-nowrap">
|
||||
<span className="text-small">CSV Upload</span>
|
||||
<input type="file" />
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div className='flex xl:justify-center overflow-x-scroll pb-4 w-full'>
|
||||
|
@ -48,14 +41,10 @@ const fetchData = async () => {
|
|||
<thead className=''>
|
||||
<tr className='bg-[#FFF6F2] text-[#1D1D1D] text-xl whitespace-nowrap'>
|
||||
<th className=" p-2">ID</th>
|
||||
<th className=" p-2">School Name</th>
|
||||
<th className=" p-2">Country</th>
|
||||
<th className=" p-2">Annual</th>
|
||||
<th className=" p-2"><abbr title="Subscription End Date" className="no-underline">S.E.D</abbr></th>
|
||||
<th className=" p-2"><abbr title="Early Start Program" className="no-underline">E.S.P</abbr> </th>
|
||||
<th className=" p-2">Toddlers</th>
|
||||
<th className=" p-2">Interakto</th>
|
||||
<th className=" p-2"> Name</th>
|
||||
<th className=" p-2">City</th>
|
||||
<th className=" p-2">Status</th>
|
||||
<th className=" p-2">Expiry</th>
|
||||
<th className=" p-2 inline-flex"> <img src="/img/3.svg" alt="" />Edit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -63,16 +52,14 @@ const fetchData = async () => {
|
|||
{school.map(data=>
|
||||
<tr className="border-b-2 whitespace-normal">
|
||||
<td className=" p-2">{data.id}</td>
|
||||
<td className=" p-2">{data.name}</td>
|
||||
<td className="p-2">{data.country}</td>
|
||||
<td className="p-2">{data.anual}</td>
|
||||
<td className="p-2">{data.agreement_expiry_date}</td>
|
||||
<td className="p-2">{data.early_start_programme}</td>
|
||||
<td className="p-2">{data.toddlers}</td>
|
||||
<td className="p-2">{data.interakto}</td>
|
||||
<td className=" p-2">{data.sname}</td>
|
||||
<td className="p-2">{data.city}</td>
|
||||
<td className="p-2">{data.status}</td>
|
||||
<td className="p-2"><a href={'/edit-school?school='+data.id} className="flex justify-center place-items-center">
|
||||
<svg width="35px" height="35px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="#166435"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path opacity="0.15" d="M8 16H12L18 10L14 6L8 12V16Z" fill="#166435"></path> <path d="M14 6L8 12V16H12L18 10M14 6L17 3L21 7L18 10M14 6L18 10M10 4L4 4L4 20L20 20V14" stroke="#166435" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg></a> </td>
|
||||
<td className="p-2">{data.usage_expiry}</td>
|
||||
<td className="p-2">
|
||||
<a href={'/edit-school?school='+data.id} className="flex justify-center place-items-center">
|
||||
<svg width="35px" height="35px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="#166435"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path opacity="0.15" d="M8 16H12L18 10L14 6L8 12V16Z" fill="#166435"></path> <path d="M14 6L8 12V16H12L18 10M14 6L17 3L21 7L18 10M14 6L18 10M10 4L4 4L4 20L20 20V14" stroke="#166435" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path> </g></svg></a>
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
|
|
|
@ -58,7 +58,7 @@ export default function addSchoolForm() {
|
|||
country: event.target.country.value,
|
||||
state: event.target.state.value,
|
||||
cities: event.target.cities.value,
|
||||
anual: event.target.anual.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,
|
||||
|
@ -150,8 +150,8 @@ export default function addSchoolForm() {
|
|||
<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="anual" className='text-xl font-bold'>Anual</label>
|
||||
<select name="anual" className=' bg-white border-2 border-[#FE4501] p-2 rounded-md focus:outline-none focus:border-2 focus:border-[#F2B705]'>
|
||||
<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>
|
||||
|
|
Loading…
Reference in New Issue