diff --git a/data/appSchool-test.db b/data/appSchool-test.db
new file mode 100644
index 0000000..7a2b6d4
Binary files /dev/null and b/data/appSchool-test.db differ
diff --git a/data/appUser.db b/data/appUser.db
index ed60910..90783dd 100644
Binary files a/data/appUser.db and b/data/appUser.db differ
diff --git a/data/user.csv b/data/user.csv
index ea1aa68..d32a2b8 100644
--- a/data/user.csv
+++ b/data/user.csv
@@ -6,3 +6,6 @@ name 3,published,,parent,,Apr,2023-05-14,2024-05-13,,IK2,,70000000011,,Feb,Sept,
name 2,published,,parent,,Apr,2023-05-14,2024-05-13,,IK2,,70000000011,,Feb,Sept,Oct,Jul,2@email.com,IN,WB,Habra,sample road near landmark,individual
name 6,published,,parent,,Jun,2023-05-14,2024-05-13,,IK3,,70000000011,,Mar,Sept,Jul,Apr,6@email.com,BD,55,Lalmonirhat,sample road near landmark,individual
teacher name,published,,teacher,,Apr,2023-05-15,2024-05-13,,IK2,,99999 99933,,Mar,0,0,0,t1@email.com,IN,WB,Barasat,,individual
+suvankar,published,,teacher,,Apr,2023-05-15,2024-05-13,,IK2,,0,,Mar,0,0,0,suvvv@email.com,IN,WB,Barasat,,individual
+teacher name,published,,teacher,,Apr,2023-05-15,2024-05-13,,IK2,,99999 99933,,Mar,0,0,0,t1@email.com,IN,WB,Barasat,,individual
+Name 11,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
diff --git a/public/favicon.ico b/public/favicon.ico
index 718d6fe..be44021 100644
Binary files a/public/favicon.ico and b/public/favicon.ico differ
diff --git a/public/next.svg b/public/next.svg
deleted file mode 100644
index 5174b28..0000000
--- a/public/next.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/public/vercel.svg b/public/vercel.svg
deleted file mode 100644
index d2f8422..0000000
--- a/public/vercel.svg
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/src/pages/add-school-form-test.jsx b/src/pages/add-school-form-test.jsx
new file mode 100644
index 0000000..febda55
--- /dev/null
+++ b/src/pages/add-school-form-test.jsx
@@ -0,0 +1,170 @@
+import NavBar from '../components/NavBar'
+import { signIn, signOut, useSession } from 'next-auth/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'
+
+export default function AddSchool() {
+ 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-test", {
+ method: "POST",
+ body
+ });
+ };
+ const [countryValue, setCountryValue] =useState('')
+ const options = useMemo(() => countryList().getData(), [])
+ const [phoneValue, setphoneValue] = useState()
+ const [allStates, setAllStates] = useState([])
+ const [allCities, setAllCities] = useState([])
+ const { data: session } = useSession()
+
+ 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.name.value,
+ location: event.target.location.value,
+ expiry: event.target.expiry.value,
+ status: event.target.status.value,
+ annual: event.target.annual.value,
+ toddlers: event.target.toddlers.value,
+ address: event.target.address.value,
+ interakto: event.target.interakto.value,
+ email: event.target.email.value,
+ pin: event.target.pin.value,
+ // phone: event.target.phone.value,
+ // email: event.target.email.value,
+
+ }
+ const JSONdata = JSON.stringify(data)
+ console.log(data)
+ const endpoint = '/api/addSchool-test'
+ 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`)
+ }
+ if (session) {
+ return (
+
+
+
+
+
+
+

+
School Registration Form
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+ return (
+ <>
+ Not signed in
+
+ >
+ )
+
+ }
\ No newline at end of file
diff --git a/src/pages/add-user-form.jsx b/src/pages/add-user-form.jsx
index cdf6860..9f12c55 100644
--- a/src/pages/add-user-form.jsx
+++ b/src/pages/add-user-form.jsx
@@ -179,7 +179,7 @@ export default function addUserForm() {
-
+
diff --git a/src/pages/api/addSchool-test.js b/src/pages/api/addSchool-test.js
new file mode 100644
index 0000000..604c7ff
--- /dev/null
+++ b/src/pages/api/addSchool-test.js
@@ -0,0 +1,34 @@
+export default function handler(req, res) {
+ const sqlite3 = require('sqlite3').verbose();
+
+ // console.log(req.body)
+ // Open a new database connection
+ let name, location, expiry, status, toddlers, address, annual, interakto, email, pin = "";
+
+ // if(req.body.name) name =req.body.name;
+ // if(req.body.status) status =req.body.status;
+ // if(req.body.status) status ="published";
+ if(req.body.name) name =req.body.name;
+ if(req.body.location) location =req.body.location;
+ if(req.body.expiry) expiry =req.body.expiry;
+ if(req.body.status) status =req.body.status;
+ if(req.body.toddlers) toddlers =req.body.toddlers;
+ if(req.body.address) address =req.body.address;
+ if(req.body.annual) annual =req.body.annual;
+ if(req.body.state) state =req.body.state;
+ if(req.body.interakto) interakto =req.body.interakto;
+ if(req.body.email) email =req.body.email;
+ if(req.body.pin) pin =req.body.pin;
+ // if(req.body.usage_expiry) usage_expiry =req.body.usage_expiry;
+ console.log(address)
+ const db = new sqlite3.Database('data/appSchool-test.db');
+ db.run(`INSERT INTO school (sname, city, usage_expiry, status, toddlers, address, annual, interakto, email, pin ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ? )`, [ name, location, expiry, status, toddlers, address, annual, interakto, email, pin ],
+ function(err) {
+ if (err) {
+ return console.log(err.message);
+ }
+ }
+ );
+ db.close();
+ res.status(200).json({ msg: 'ok' });
+ }
\ No newline at end of file
diff --git a/src/pages/api/fileUpload-test.js b/src/pages/api/fileUpload-test.js
new file mode 100644
index 0000000..c19e1cf
--- /dev/null
+++ b/src/pages/api/fileUpload-test.js
@@ -0,0 +1,38 @@
+import formidable from "formidable";
+import fs from "fs";
+
+export const config = {
+ api: {
+ bodyParser: false
+ }
+};
+
+const post = async (req, res) => {
+ const form = new formidable.IncomingForm();
+ form.parse(req, async function (err, fields, files) {
+ console.log(fields)
+ await saveFile(files.file,fields.fName? fields.fName:files.file.originalFilename );
+ return res.status(201).send("");
+ });
+};
+
+const saveFile = async (file,fName) => {
+ console.log(file.filepath)
+ console.log(fName)
+ const data = fs.readFileSync(file.filepath);
+ fs.writeFileSync(`./public/uploaded/${fName}`, data);
+ fs.unlinkSync(file.filepath);
+ return;
+};
+
+export default (req, res) => {
+ req.method === "POST"
+ ? post(req, res)
+ : req.method === "PUT"
+ ? console.log("PUT")
+ : req.method === "DELETE"
+ ? console.log("DELETE")
+ : req.method === "GET"
+ ? console.log("GET")
+ : res.status(404).send("");
+};
diff --git a/src/pages/api/fileUpload.js b/src/pages/api/fileUpload.js
index 843ab77..c19e1cf 100644
--- a/src/pages/api/fileUpload.js
+++ b/src/pages/api/fileUpload.js
@@ -10,15 +10,15 @@ export const config = {
const post = async (req, res) => {
const form = new formidable.IncomingForm();
form.parse(req, async function (err, fields, files) {
- // console.log(fields)
+ console.log(fields)
await saveFile(files.file,fields.fName? fields.fName:files.file.originalFilename );
return res.status(201).send("");
});
};
const saveFile = async (file,fName) => {
- // console.log(file.filepath)
- // console.log(fName)
+ console.log(file.filepath)
+ console.log(fName)
const data = fs.readFileSync(file.filepath);
fs.writeFileSync(`./public/uploaded/${fName}`, data);
fs.unlinkSync(file.filepath);
diff --git a/src/pages/api/listSchlools-test.js b/src/pages/api/listSchlools-test.js
new file mode 100644
index 0000000..1978e87
--- /dev/null
+++ b/src/pages/api/listSchlools-test.js
@@ -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/appSchool-test.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();
+// });
+
+
+
+}
+
diff --git a/src/pages/api/searchUser.js b/src/pages/api/searchUser.js
new file mode 100644
index 0000000..a0fb38d
--- /dev/null
+++ b/src/pages/api/searchUser.js
@@ -0,0 +1,79 @@
+import csv from 'csv-parser';
+import fs from 'fs';
+import sqlite3 from 'sqlite3';
+
+export default function handler(req,res) {
+
+ // const query = req.query;
+ const { searchQry, limit } = req.query;
+ console.log(searchQry)
+// const {
+// query: { name, keyword },
+// method,
+// } = req;
+// console.log(name, keyword, method);
+
+ const DB_NAME = 'data/appUser.db';
+ const TABLE_NAME = 'user';
+
+ // Open a connection to the SQLite database
+ const db = new sqlite3.Database(DB_NAME);
+
+ const query = `SELECT * FROM ${TABLE_NAME}`;
+
+ function getAllRows(tableName, searchQry, pageSize) {
+ const sql = `SELECT * FROM ${tableName} WHERE uname LIKE '%${searchQry}%'`;
+
+ return new Promise((resolve, reject) => {
+ db.all(sql, [], (err, rows) => {
+ if (err) {
+ reject(err);
+ return;
+ }
+
+ resolve(rows);
+ });
+ // let tData={data:rows,page:7}
+ // const data = tData;
+ // resolve(data);
+ });
+ };
+ async function doSomething() {
+ try {
+ const returnData = await getAllRows('user',searchQry,limit);
+ 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();
+// });
+
+
+
+}
+
diff --git a/src/pages/edit-school.jsx b/src/pages/edit-school.jsx
index c3e74f4..fd8aec5 100644
--- a/src/pages/edit-school.jsx
+++ b/src/pages/edit-school.jsx
@@ -17,6 +17,8 @@ export default function EditSchool() {
method: "POST",
body
});
+
+
};
const uploadCsv = async (event) => {
// alert('p')
@@ -166,6 +168,7 @@ export default function EditSchool() {
+
diff --git a/src/pages/file-upload.jsx b/src/pages/file-upload.jsx
new file mode 100644
index 0000000..055825d
--- /dev/null
+++ b/src/pages/file-upload.jsx
@@ -0,0 +1,91 @@
+import { signIn, signOut, useSession } from 'next-auth/react'
+import {useId, useState, useEffect, useMemo} from 'react';
+import { useRouter } from 'next/router'
+export default function fileUpload() {
+ const [school, setSchool] = useState([]);
+ const { data: session} = useSession()
+ const fetchData = async () => {
+ const response = await fetch("/api/listSchlools-test");
+ const data = await response.json();
+
+ return setSchool(data);
+ }
+// console.log(school)
+ useEffect(() => {
+ fetchData();
+ },[])
+ const uploadToServer = async (event) => {
+ const body = new FormData();
+ body.append("file", agreement.files[0]);
+ body.append("fName", `${+new Date()}.pdf`);
+ const response = await fetch("/api/fileUpload-test", {
+ method: "POST",
+ body
+ });
+ };
+ function fInput() {
+ let x = document.getElementById('myInput').value
+ document.getElementById('print').innerHTML = "You Typed :-" + x;
+ }
+ var dt = Date();
+ var unix = Math.floor(+new Date()/1000);
+ function myFunction() {
+ document.getElementById('demo').innerHTML = "Time :-"+dt+ " & Unix Time :-"+unix;
+ document.getElementById('demo').style.color = "red"
+ }
+ // console.log(+new Date())
+ // console.log(Math.floor(Date.now() / 1000))
+ return (
+
+
+
+ )
+}
\ No newline at end of file
diff --git a/src/pages/school-list/schoollist-2.jsx b/src/pages/school-list/schoollist-2.jsx
new file mode 100644
index 0000000..b8cf988
--- /dev/null
+++ b/src/pages/school-list/schoollist-2.jsx
@@ -0,0 +1,96 @@
+// import SchoolEditForm from '../../components/SchoolEditForm'
+import { signIn, signOut, useSession } from 'next-auth/react'
+import React, { useEffect, useState } from "react";
+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 [school, setSchool] = useState([]);
+ const { data: session} = useSession()
+const fetchData = async () => {
+ const response = await fetch("/api/listSchlools-test");
+ const data = await response.json();
+ return setSchool(data);
+ }
+ console.log(school)
+ useEffect(() => {
+ fetchData();
+ },[])
+
+if (session) {
+ return (
+
+
+
+
+
+
+
+
+
+ | Name |
+ Email |
+ Location |
+ Status |
+ Expiry |
+ Toddlers |
+ Interakto |
+ Address |
+ Pin |
+ Anual |
+
+ Edit
+ |
+
+
+
+ {school.map(data=>
+
+ | {data.sname} |
+ {data.email} |
+ {data.city} |
+ {/* {data.city} | */}
+ {data.status} |
+ {data.usage_expiry} |
+ {data.toddlers} |
+ {data.interakto} |
+ {data.address} |
+ {data.pin} |
+ {data.annual} |
+
+
+
+
+ |
+
+ )}
+
+ {/* */}
+
+
+
+
+
+ )
+}
+{/*
*/}
+ return (
+ <>
+ Not signed in
+
+ >
+ )
+
+}