Skip to content

Commit

Permalink
fix: typescript errors
Browse files Browse the repository at this point in the history
disabled profile reset password
  • Loading branch information
redxzeta committed May 8, 2022
1 parent 7ac5b5f commit a8b68b8
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 184 deletions.
12 changes: 6 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { Provider } from "react-supabase";

import "./App.css";
import About from "./components/about/About";
import ForgotPassword from "./components/accounts/ForgotPassword";
// import ForgotPassword from "./components/accounts/ForgotPassword";
import Register from "./components/accounts/Register";
import SLogin from "./components/accounts/SLogin";
// import Profile from "./components/accounts/profile/Profile";
import ResetPassword from "./components/accounts/settings/resetPassword";
// import ResetPassword from "./components/accounts/settings/resetPassword";
import Donate from "./components/donate/Donate";
import Home from "./components/home/Home";
import Favorites from "./components/pets/Favorites";
Expand All @@ -23,7 +23,7 @@ import Resources from "./components/resources/Resources";
import Tips from "./components/tips/Tips";
import { AuthProvider } from "./context/SupaContext";
import PetAuthProvider from "./context/TokenContext";
import PrivateRoute from "./utils/PrivateRoute";
// import PrivateRoute from "./utils/PrivateRoute";
import { supabase } from "./utils/SupaBaseUtils";

export default function App() {
Expand All @@ -45,15 +45,15 @@ export default function App() {
<Route path="favorites" element={<Favorites />} />
<Route path="register" element={<Register />} />
<Route path="login" element={<SLogin />} />
<Route path="forgot-password" element={<ForgotPassword />} />
<Route
{/* <Route path="forgot-password" element={<ForgotPassword />} /> */}
{/* <Route
path="reset-password"
element={
<PrivateRoute>
<ResetPassword />
</PrivateRoute>
}
/>
/> */}
{/* <Route path="profile" element={<Profile />} /> */}
<Route path="/" element={<Home />} />
<Route path="*" element={<NotFound />} />
Expand Down
2 changes: 2 additions & 0 deletions src/components/accounts/ForgotPassword.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */
// @ts-nocheck
import { Fragment, useState } from "react";
import { Button, Container, Form, Spinner } from "react-bootstrap";
import { Navigate } from "react-router-dom";
Expand Down
28 changes: 17 additions & 11 deletions src/components/accounts/Register.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
import { Fragment } from "react";
import React, { Fragment, useState } from "react";
import { Container, Form } from "react-bootstrap";
import { Navigate } from "react-router-dom";
import { useSignUp } from "react-supabase";

import { useAuth } from "../../context/SupaContext";
import useForm from "../../useHooks/useForm";
import { FetchingButton } from "../layout/Buttons/FetchingButton";
import "./register.css";

const initState = {
type RegisterType = {
email: string;
password: string;
};

const registerFormState: RegisterType = {
email: "",
password: "",
};

const Register = () => {
const [form, handleChange] = useForm(initState);

const [registerForm, setRegisterForm] = useState(registerFormState);
const [{ error, fetching, user }, signUp] = useSignUp();

const onClickSignUp = async () => signUp(form);
const onClickSignUp = async () => signUp(registerForm);

const onSubmit = (e) => {
const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
onClickSignUp();
};

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target;
setRegisterForm((val) => ({ ...val, [name]: value }));
};

const { session } = useAuth();
if (session) return <Navigate to="/" />;
return (
Expand All @@ -43,7 +50,7 @@ const Register = () => {
placeholder="Enter email"
name="email"
onChange={handleChange}
value={form.email}
value={registerForm.email}
/>
<Form.Text className="text-muted">
We will never share your email with anyone else.
Expand All @@ -57,13 +64,12 @@ const Register = () => {
placeholder="Password"
name="password"
onChange={handleChange}
value={form.password}
value={registerForm.password}
/>
</Form.Group>
<FetchingButton
fetching={fetching}
action="Submit"
type="submit"
className="register__button"
/>
{error && (
Expand Down
27 changes: 19 additions & 8 deletions src/components/accounts/SLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
import React, { useState } from "react";
import { Container, Form } from "react-bootstrap";
import { useNavigate } from "react-router-dom";
import { useSignIn } from "react-supabase";

import useForm from "../../useHooks/useForm";
import { FetchingButton } from "../layout/Buttons/FetchingButton";

const initState = {
type LoginType = {
email: string;
password: string;
};

const loginFormState: LoginType = {
email: "",
password: "",
};
const SLogin = () => {
const navigate = useNavigate();
const [form, handleChange] = useForm(initState);
// const [form, handleChange] = useForm(initState);

const [loginForm, setLoginForm] = useState(loginFormState);

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target;
setLoginForm((val) => ({ ...val, [name]: value }));
};

const [{ error, fetching }, signIn] = useSignIn();

const onSubmit = async (e) => {
const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();

const { session } = await signIn(form);
const { session } = await signIn(loginForm);

if (!error && !fetching && session) {
navigate("/");
Expand All @@ -37,7 +49,7 @@ const SLogin = () => {
placeholder="Enter email"
name="email"
onChange={handleChange}
value={form.email}
value={loginForm.email}
/>
<Form.Text className="text-muted">
We will never share your email with anyone else.
Expand All @@ -51,13 +63,12 @@ const SLogin = () => {
placeholder="Password"
name="password"
onChange={handleChange}
value={form.password}
value={loginForm.password}
/>
</Form.Group>
<FetchingButton
fetching={fetching}
action="Submit"
type="submit"
className="register__button"
/>
{error && (
Expand Down
2 changes: 2 additions & 0 deletions src/components/accounts/profile/EditProfileModal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */
// @ts-nocheck
import { useState } from "react";
import { Button, Form, Modal } from "react-bootstrap";
import { useUpsert } from "react-supabase";
Expand Down
2 changes: 2 additions & 0 deletions src/components/accounts/profile/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */
// @ts-nocheck
import { useState } from "react";
import { Button, Col, Container, Image, Row } from "react-bootstrap";
import { Link } from "react-router-dom";
Expand Down
2 changes: 2 additions & 0 deletions src/components/accounts/settings/resetPassword.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable */
// @ts-nocheck
import React, { useState } from "react";
import { Button, Container, Form, Spinner } from "react-bootstrap";
import { Navigate } from "react-router-dom";
Expand Down
Loading

0 comments on commit a8b68b8

Please sign in to comment.