Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17,678 changes: 17,578 additions & 100 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
.App {
text-align: center;
}

.App-logo {
margin: 10px auto;
padding: 20px 0;
Expand All @@ -13,6 +9,10 @@
width: 100%;
}

.App-logo:hover {
cursor: pointer;
}

.App-title {
color: var(--theme-body-txt);
margin-top: 0.6rem;
Expand Down
13 changes: 3 additions & 10 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@ import React, { Suspense } from "react";
import { Link, Route, Switch } from "wouter";

import Header from "components/Header";

import Register from 'pages/Register'
import Login from "pages/Login";
import SearchResults from "pages/SearchResults";
import Detail from "pages/Detail";
import ErrorPage from "pages/ErrorPage";

import { UserContextProvider } from "context/UserContext";
import { GifsContextProvider } from "context/GifsContext";
import { Register, Login, SearchResults, Detail, ErrorPage } from 'pages'
import { UserContextProvider, GifsContextProvider } from "context";

import "./App.css";

Expand All @@ -19,7 +12,7 @@ const HomePage = React.lazy(() => import("./pages/Home"));
export default function App() {
return (
<UserContextProvider>
<div className="App">
<div css={{textAlign:"center"}}>
<Suspense fallback={null}>
<section className="App-content">
<Header />
Expand Down
2 changes: 0 additions & 2 deletions src/components/Category/Category.css

This file was deleted.

2 changes: 0 additions & 2 deletions src/components/Category/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React from "react";
import { Link } from "wouter";
import {
CategoryTitle,
CategoryListItem,
CategoryLink,
CategoryList,
} from "./styles";
import "./Category.css";

export default function Category({ name, options = [] }) {
return (
Expand Down
2 changes: 0 additions & 2 deletions src/components/Fav/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import React, { useState } from "react";
import useUser from "hooks/useUser";
import Modal from "components/Modal";
import Login from "components/Login";
import { useLocation } from "wouter";

import "./Fav.css";

export default function Fav({ id }) {
const { isLogged, addFav, favs } = useUser();
const [, navigate] = useLocation();
const [showModal, setShowModal] = useState(false);

const isFaved = favs.some((favId) => favId === id);
Expand Down
17 changes: 8 additions & 9 deletions src/components/Login/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useState } from "react";
import {useLocation} from "wouter"
import React, { useState, useEffect, useCallback } from "react";
import { useLocation } from "wouter"
import useUser from 'hooks/useUser'
import { useEffect } from "react";
import './Login.css'

export default function Login({onLogin}) {
export default function Login({ onLogin }) {
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [, navigate] = useLocation()
Expand All @@ -17,18 +16,18 @@ export default function Login({onLogin}) {
}
}, [isLogged, navigate, onLogin])

const handleSubmit = (e) => {
const handleSubmit = useCallback((e) => {
e.preventDefault();
login({ username, password })
};
}, [login, username, password])

return (
<>
{isLoginLoading && <strong>Checking credentials...</strong>}
{!isLoginLoading &&
<form className='form' onSubmit={handleSubmit}>
<form className='form' onSubmit={handleSubmit} autoComplete={false} >
<label>
username
Username
<input
placeholder="username"
onChange={(e) => setUsername(e.target.value)}
Expand All @@ -37,7 +36,7 @@ export default function Login({onLogin}) {
</label>

<label>
password
Password
<input
type="password"
placeholder="password"
Expand Down
2 changes: 1 addition & 1 deletion src/components/SearchForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function SearchForm({
initialKeyword = '',
initialRating = RATINGS[0]
}) {
const [_, pushLocation] = useLocation()
const [, pushLocation] = useLocation()

const {keyword, rating, changeKeyword, changeRating} = useForm({ initialKeyword, initialRating })

Expand Down
3 changes: 3 additions & 0 deletions src/context/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { GifsContextProvider } from "./GifsContext";
export { default as Context } from "./StaticContext";
export { UserContextProvider } from "./UserContext";
29 changes: 29 additions & 0 deletions src/pages/Login/Login.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import { render } from "@testing-library/react";
import LoginPage from "./index";


describe("<LoginPage />", () => {
test("renders without crashing", async () => {
const { findAllByText } = render(<LoginPage />);
const title = await findAllByText(/Login/i);
expect(title).toBeTruthy();
})

test("renders a form with two inputs", async () => {
const { findByPlaceholderText } = render(<LoginPage />);

const inputEmail = await findByPlaceholderText(/username/i);
const inputPassword = await findByPlaceholderText(/password/i);

expect(inputEmail).toBeInTheDocument();
expect(inputPassword).toBeInTheDocument();
})

test("There is a button to submit the form", async () => {
const { container } = render(<LoginPage />);
const button = container.querySelector("button");

expect(button).toBeInTheDocument();
})
})
9 changes: 6 additions & 3 deletions src/pages/Login/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react'
import Login from 'components/Login'
import { Container } from 'style-components'

export default function LoginPage () {
export default function LoginPage() {
return <>
<h2>Login</h2>
<Login />
<Container>
<h2 style={{textAlign: "center"}} >Login</h2>
<Login />
</Container>
</>
}
7 changes: 5 additions & 2 deletions src/pages/Register/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from 'react'
import Register from 'components/Register'
import { Container } from 'style-components'

export default function RegisterPage () {
return <>
<h2>Register</h2>
<Register />
<Container>
<h2>Register</h2>
<Register />
</Container>
</>
}
6 changes: 6 additions & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export { default as Detail } from './Detail';
export { default as ErrorPage } from './ErrorPage';
export { default as Home } from './Home';
export { default as Login } from './Login';
export { default as Register } from './Register';
export { default as SearchResults } from './SearchResults';
11 changes: 11 additions & 0 deletions src/style-components/Container.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import styled from "@emotion/styled";

const Container = styled.section`
display: flex;
width: 100%;
flex-direction: column;
justify-content: center;
align-items: center;
`;

export default Container;
1 change: 1 addition & 0 deletions src/style-components/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Container } from './Container';
Loading