diff --git a/src/pages/add-school-form.jsx b/src/pages/add-school-form.jsx index d770c42..4196638 100644 --- a/src/pages/add-school-form.jsx +++ b/src/pages/add-school-form.jsx @@ -10,7 +10,10 @@ export default function addSchoolForm() { "status":"published", name: event.target.schoolName.value, country: event.target.country.value, - + anual: event.target.anual.value, + toddlers: event.target.toddlers.value, + early_start_programme: event.target.early_start_programme.value, + interakto: event.target.interakto.value, } const JSONdata = JSON.stringify(data) const endpoint = 'https://management.beanstalkedu.com/items/school' @@ -23,8 +26,8 @@ export default function addSchoolForm() { } const response = await fetch(endpoint, options) - const result = await response.json() - alert(`Is this your full name: ${result.data}`) + // const result = await response.json() + // alert(`Is this your full name: ${result.data}`) } return (
@@ -39,7 +42,7 @@ export default function addSchoolForm() {
- +
@@ -47,7 +50,7 @@ export default function addSchoolForm() {
- @@ -65,25 +68,25 @@ export default function addSchoolForm() {
- +
- - @@ -118,7 +121,7 @@ export default function addSchoolForm() {
- + {/* */}
@@ -127,5 +130,4 @@ export default function addSchoolForm() {
) - } - \ No newline at end of file + } \ No newline at end of file diff --git a/src/pages/add-user-form.tsx b/src/pages/add-user-form.jsx similarity index 69% rename from src/pages/add-user-form.tsx rename to src/pages/add-user-form.jsx index f2cc127..c7d6f75 100644 --- a/src/pages/add-user-form.tsx +++ b/src/pages/add-user-form.jsx @@ -1,40 +1,38 @@ -import React, { useState } from 'react'; +// https://management.beanstalkedu.com/items/school +// import React from 'react'; +import React, { useState, useEffect } from 'react'; import Image from 'next/image' import NavBar from '../components/NavBar' -import { Inter } from 'next/font/google' - -const inter = Inter({ subsets: ['latin'] }) - - function Postformvalue(props) { - const [formvalue, setFormvalue]= useState({name:'',school:'', plan:'', class:'', lang:'', start_month:'', start_date:'', end_date:'', }); - - const handleInput =(e)=>{ - const { name, value}= e.target; - setFormvalue({...formvalue, [name]:value}); - console.log(formvalue); - } - const handleFormsubmit= async (e)=>{ - e.preventDefault(); - - await fetch('http://localhost/devopsdeveloper/ReactFormvalue/', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - name:formvalue.name, - school: formvalue.school, - plan: formvalue.plan, - class: formvalue.class, - lang: formvalue.lang, - start_month: formvalue.start_month, - start_date: formvalue.start_date, - end_date: formvalue.end_date - - }) - }); - console.log("success"); - - } +// import { Inter } from 'next/font/google' +export default function addUserForm (){ + const [school, setData] = useState(""); + useEffect(() => { + fetch('https://management.beanstalkedu.com/items/school') + .then( (response) => response.json() ) + .then( (data) => setData(data) ) + }, []); + console.log(school) + const handleFormsubmit = async (event) => { + event.preventDefault() + const data = { + "status":"published", + user: event.target.user.value, + // user: event.target.user.value, + } + const JSONdata = JSON.stringify(data) + const endpoint = 'https://management.beanstalkedu.com/items/enrolled_user' + 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}`) + } return (
@@ -47,16 +45,25 @@ const inter = Inter({ subsets: ['latin'] })
- - + + +
+
+ +
- +
- @@ -66,7 +73,7 @@ const inter = Inter({ subsets: ['latin'] })
- @@ -76,7 +83,7 @@ const inter = Inter({ subsets: ['latin'] })
- @@ -92,7 +99,7 @@ const inter = Inter({ subsets: ['latin'] })
- @@ -109,11 +116,11 @@ const inter = Inter({ subsets: ['latin'] })
- +
- +
@@ -126,4 +133,3 @@ const inter = Inter({ subsets: ['latin'] })
) } -export default Postformvalue; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 650cc57..ca244f6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,6 +18,6 @@ "@/*": ["./src/*"] } }, - "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/pages/add-school-form.jsx", "src/pages/add-school-form.jsx"], + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "src/pages/add-school-form.jsx", "src/pages/add-school-form.jsx", "src/pages/add-user-form.jsx"], "exclude": ["node_modules"] }