mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add org_id to a user when signing up
This commit is contained in:
parent
b88ee6643e
commit
2b886ec2c2
5 changed files with 28 additions and 12 deletions
|
|
@ -1,18 +1,19 @@
|
|||
"use client";
|
||||
import React from "react";
|
||||
import { Title } from "../../components/UI/Elements/Styles/Title";
|
||||
import { signup } from "../../services/auth/auth";
|
||||
import { Title } from "../../../../components/UI/Elements/Styles/Title";
|
||||
import { signup } from "../../../../services/auth/auth";
|
||||
|
||||
const SignUp = () => {
|
||||
const SignUp = (params : any) => {
|
||||
const org_slug = params.params.orgslug;
|
||||
const [email, setEmail] = React.useState("");
|
||||
const [password, setPassword] = React.useState("");
|
||||
const [username, setUsername] = React.useState("");
|
||||
|
||||
const handleSubmit = (e: any) => {
|
||||
e.preventDefault();
|
||||
console.log({ email, password, username });
|
||||
alert(JSON.stringify({ email, password, username }));
|
||||
signup({ email, password, username });
|
||||
console.log({ email, password, username, org_slug });
|
||||
alert(JSON.stringify({ email, password, username, org_slug }));
|
||||
signup({ email, password, username, org_slug });
|
||||
};
|
||||
|
||||
const handleEmailChange = (e: any) => {
|
||||
|
|
@ -11,7 +11,7 @@ export const config = {
|
|||
* 4. /examples (inside /public)
|
||||
* 5. all root files inside /public (e.g. /favicon.ico)
|
||||
*/
|
||||
"/((?!api|_next|fonts|login|signup|examples|[\\w-]+\\.\\w+).*)",
|
||||
"/((?!api|_next|fonts|examples|[\\w-]+\\.\\w+).*)",
|
||||
],
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ interface NewAccountBody {
|
|||
username: string;
|
||||
email: string;
|
||||
password: string;
|
||||
org_slug: string;
|
||||
}
|
||||
|
||||
export async function signup(body: NewAccountBody): Promise<any> {
|
||||
|
|
@ -76,7 +77,7 @@ export async function signup(body: NewAccountBody): Promise<any> {
|
|||
redirect: "follow",
|
||||
};
|
||||
|
||||
return fetch(`${getAPIUrl()}users/`, requestOptions)
|
||||
return fetch(`${getAPIUrl()}users/?org_slug=${body.org_slug}`, requestOptions)
|
||||
.then((result) => result.json())
|
||||
.catch((error) => console.log("error", error));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue