mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add new org creation page
This commit is contained in:
parent
0c6ec386c2
commit
1b3df392b7
2 changed files with 55 additions and 9 deletions
|
|
@ -1,13 +1,45 @@
|
||||||
import React from 'react'
|
import React from "react";
|
||||||
import Layout from '../../components/ui/layout'
|
import Layout from "../../components/ui/layout";
|
||||||
import { Title } from '../../components/ui/styles/title'
|
import { Title } from "../../components/ui/styles/title";
|
||||||
|
import { createNewOrganization } from "../../services/orgs";
|
||||||
|
|
||||||
const Organizations = () => {
|
const Organizations = () => {
|
||||||
|
const [name, setName] = React.useState("");
|
||||||
|
const [description, setDescription] = React.useState("");
|
||||||
|
const [email, setEmail] = React.useState("");
|
||||||
|
|
||||||
|
const handleNameChange = (e: any) => {
|
||||||
|
setName(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDescriptionChange = (e: any) => {
|
||||||
|
setDescription(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEmailChange = (e: any) => {
|
||||||
|
setEmail(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async (e: any) => {
|
||||||
|
e.preventDefault();
|
||||||
|
console.log({ name, description, email });
|
||||||
|
const status = await createNewOrganization({ name, description, email });
|
||||||
|
alert(JSON.stringify(status));
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout>
|
<Layout>
|
||||||
<Title>New Organization</Title>
|
<Title>New Organization</Title>
|
||||||
|
Name: <input onChange={handleNameChange} type="text" />
|
||||||
|
<br />
|
||||||
|
Description: <input onChange={handleDescriptionChange} type="text" />
|
||||||
|
<br />
|
||||||
|
Email Address: <input onChange={handleEmailChange} type="text" />
|
||||||
|
<br />
|
||||||
|
<button onClick={handleSubmit}>Create</button>
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default Organizations
|
export default Organizations;
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,25 @@ export async function getUserOrganizations() {
|
||||||
.catch((error) => console.log("error", error));
|
.catch((error) => console.log("error", error));
|
||||||
}
|
}
|
||||||
|
|
||||||
// export async function createNewOrganization(user_id) {}
|
export async function createNewOrganization(body: any) {
|
||||||
|
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
|
||||||
|
|
||||||
|
const requestOptions: any = {
|
||||||
|
method: "POST",
|
||||||
|
headers: HeadersConfig,
|
||||||
|
redirect: "follow",
|
||||||
|
credentials: "include",
|
||||||
|
body: JSON.stringify(body),
|
||||||
|
};
|
||||||
|
|
||||||
|
return fetch(`${getAPIUrl()}orgs/`, requestOptions)
|
||||||
|
.then((result) => result.json())
|
||||||
|
.catch((error) => console.log("error", error));
|
||||||
|
}
|
||||||
|
|
||||||
// export async function getOrganizationData(org_id) {}
|
// export async function getOrganizationData(org_id) {}
|
||||||
|
|
||||||
export async function deleteOrganizationFromBackend(org_id:any) {
|
export async function deleteOrganizationFromBackend(org_id: any) {
|
||||||
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
|
const HeadersConfig = new Headers({ "Content-Type": "application/json" });
|
||||||
|
|
||||||
const requestOptions: any = {
|
const requestOptions: any = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue