Skip to content

Commit

Permalink
feat(web): add user schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
umitcan07 committed Apr 28, 2024
1 parent fecade9 commit 0345a4c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion bruno/environments/local.bru
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
vars {
base_url: http://localhost
base_url: http://127.0.0.1
port: 8000
}
4 changes: 2 additions & 2 deletions bruno/login.bru
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ post {

body:json {
{
"username": "username16",
"password": "pass16"
"username": "username17",
"password": "pass17"
}
}

Expand Down
7 changes: 3 additions & 4 deletions bruno/signup.bru
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ post {

body:json {
{
"fullName": "asdsa",
"username": "username16",
"email": "[email protected]",
"password": "pass16"
"username": "username200",
"email": "[email protected]",
"password": "pass200"
}
}
2 changes: 1 addition & 1 deletion web/src/routes/Login.data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const loginAction = async ({ request }: { request: Request }) => {
const formData = await request.formData();
const response = await fetch(`${BACKEND_URL}/user/login`, {
method: "POST",
// mode: "no-cors",
mode: "no-cors",
headers: {
"Content-Type": "application/json",
},
Expand Down
16 changes: 4 additions & 12 deletions web/src/routes/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import {
TextInput,
Container,
Button,
useMantineTheme,
Checkbox,
} from "@mantine/core";
import { Link, Form, useSubmit, useFormAction } from "react-router-dom";
import { TextInput, Container, Checkbox } from "@mantine/core";
import { Link, Form } from "react-router-dom";
import { href } from "../router";
import { button, buttonInnerRing } from "../components/Button";
import { makeLoader, typesafeBrowserRouter } from "react-router-typesafe";
import { useActionData } from "react-router-typesafe";
import { useState } from "react";
import { useLoaderData, redirect, useActionData } from "react-router-typesafe";
import { Checkmark } from "../components/Checkmark";
import type { loginAction, loginLoader } from "./Login.data";
import type { loginAction } from "./Login.data";

export const Login = () => {
const c = useActionData<typeof loginAction>();
console.log(c);
console.log(c?.error);
const [isKeepMeLoggedIn, setIsKeepMeLoggedIn] = useState(true);
return (
Expand Down
2 changes: 1 addition & 1 deletion web/src/routes/Register.data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const registerAction = async ({ request }: { request: Request }) => {
const formData = await request.formData();
const response = await fetch(`${BACKEND_URL}/user/signup`, {
method: "POST",
// mode: "no-cors",
mode: "no-cors",
headers: {
"Content-Type": "application/json",
},
Expand Down
23 changes: 23 additions & 0 deletions web/src/schema/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export type User = {
id: number;
username: string;
email: string;
password: string;
date_joined: string;
last_login: string | null;
};
export type UserCreate = {
username: string;
email: string;
password: string;
};

export type UserLogin = {
username: string;
password: string;
};

export type UserResponse = {
token: string;
user: User;
};

0 comments on commit 0345a4c

Please sign in to comment.