Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#45] Agregada verificacion al login #48

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
JoeOsG marked this conversation as resolved.
Show resolved Hide resolved
},
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active"
Expand Down
8,987 changes: 3,090 additions & 5,897 deletions package-lock.json

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existen muchos cambios en el package-lock, estos a qué se deben?

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions src/atoms/Button-primary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ const ButtonAble = styled.button`
cursor: not-allowed;
}
`;
const ButtonPrimary = ({text, disable, className}) => {
const buttonClick = () => {
console.log('Do something');
};
const ButtonPrimary = ({text, disable, className, typeOfButton, handleClick}) => {


return disable ? (
<ButtonAble disabled className={className}>
{text}
</ButtonAble>
) : (
<ButtonAble className={className} onClick={() => buttonClick()}>
<ButtonAble className={className} onClick={() => handleClick()} type={typeOfButton}>
{text}
</ButtonAble>
);
Expand Down
2 changes: 1 addition & 1 deletion src/atoms/Button-secondary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const ButtonSecondary = ({text, disable, buttonClick}) => {
return disable ? (
<ButtonAble disabled>{text}</ButtonAble>
) : (
<ButtonAble onClick={() => buttonClick()}>{text}</ButtonAble>
<ButtonAble onClick={buttonClick}>{text}</ButtonAble>
);
};

Expand Down
6 changes: 3 additions & 3 deletions src/atoms/CoffeeBanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import IconCoffee from '../image/IconCoffee.svg';

const Logo = styled.div`
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
align-items: center;
justify-content: center;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Podemos agregar a la descripción del PR, una captura de la web antes - después de este cambio?

gap: 1rem
`;

const LogoIcon = styled.img`
Expand Down
8 changes: 6 additions & 2 deletions src/molecules/ChoosePayment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const SubHeaderSection = styled.div`
`;

export default function ChoosePayment() {
function handleClick(){
console.log("payment")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El console.log nos servira en el dia a dia de desarrollo, pero no deberia estar en produccion, podemos tambien dejarle asociado in TODO, para darle funcionalidad a dicho handle.

// TODO: ISSUE-01 Crear funcionalidad para elegir el método de pago al hacer click.
console.log("payment")

}

return (
<>
<HeaderSection>
Expand All @@ -29,15 +33,15 @@ export default function ChoosePayment() {
</HeaderSection>

<SubHeaderSection>
<ButtonSecondary text={'tarjeta'} />
<ButtonSecondary text={'tarjeta'} buttonClick={() => handleClick()}/>
<ButtonSecondary text={'efectivo'} />
</SubHeaderSection>

<CardPayment />

<SubHeaderSection>
<ButtonSecondary text={'cancelar'} />
<ButtonPrimary text={'pagar'} />
<ButtonPrimary text={'pagar'} handleClick={() => console.log("payment")} />
</SubHeaderSection>
{/* <Buttons /> */}
</>
Expand Down
4 changes: 3 additions & 1 deletion src/molecules/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import {TopMenu} from './TopMenu';
const Container = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
justify-content: space-evenly;
padding: 0 2rem;
`;

export const Header = () => {
return (
<>
<Container>
<CoffeeBanner />
<TopMenu />
</Container>
</>
);
};
72 changes: 54 additions & 18 deletions src/molecules/LoginForm.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, {useState} from 'react';
import styled from '@emotion/styled';
import React, { useState } from "react";
import styled from "@emotion/styled";

import InputField from '../atoms/InputField';
import Label from '../atoms/Label';
import ButtonPrimary from '../atoms/Button-primary';
import InputEmail from '../atoms/InputEmail';
import InputPassword from '../atoms/InputPassword';
import InputField from "../atoms/InputField";
import Label from "../atoms/Label";
import ButtonPrimary from "../atoms/Button-primary";
import InputEmail from "../atoms/InputEmail";
import InputPassword from "../atoms/InputPassword";

const Container = styled.div`
display: flex;
Expand All @@ -20,20 +20,56 @@ const LoginButtonStyled = styled(ButtonPrimary)`
`;

export const LoginForm = (className) => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");

function validateEmail(emailToValidate) {
const emailRegex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if (!emailRegex.test(emailToValidate)) {
console.log("El email debe contener un @ y .com");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quizás en este punto deberíamos retornar un String, para poder renderizar dicho mensaje de cara al usuario en lugar de sólo verlo por consola.

}
}

function validatePassword(passwordToValidate) {
const passwordRegex = /[0-9]/;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Podriamos utilizar una rgx, que haga todo lo que se valida en los ifs, entonces tenemos una función más limpia:

^(?=.*[0-9]).{5,}$

Entonces, si la password no coincide con el patrón, le retornamos el mensaje al usuario para que vuelva a ingresar la contraseña hasta que sea válida

if (
passwordToValidate.length < 5 &&
(typeof passwordToValidate == `string` ||
!passwordRegex.test(passwordToValidate))
) {
console.log("La contraseña debe tener al menos 5 caracteres y un numero");
}
}

function handleClick() {
event.preventDefault();
validateEmail(email);
validatePassword(password);
}

return (
<Container className={className}>
<InputField>
<Label>Email</Label>
<InputEmail name="email" setValue={setEmail} value={email} />
</InputField>
<InputField>
<Label>Password</Label>
<InputPassword name="password" setValue={setPassword} value={password} />
</InputField>
<LoginButtonStyled disable={false} text={'Ingresar'} />
<form>
<InputField>
<Label>Email</Label>
<InputEmail name="email" setValue={setEmail} value={email} />
</InputField>
<InputField>
<Label>Password</Label>
<InputPassword
name="password"
setValue={setPassword}
value={password}
/>
</InputField>

<LoginButtonStyled
disable={false}
text={"Ingresar"}
typeOfButton={`submit`}
handleClick={handleClick}
/>
</form>
</Container>
);
};
3 changes: 2 additions & 1 deletion src/organisms/Order.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const Footer = styled.div`
margin: 2rem 0;
`;


export const Order = ({orderNumber, orderProducts, clearProducts}) => {
const handleDeleteItem = () => {};

Expand All @@ -50,7 +51,7 @@ export const Order = ({orderNumber, orderProducts, clearProducts}) => {
<Container>
<Header>
<H2>Orden N. {orderNumber}</H2>
<ButtonSecondary buttonClick={() => clearProducts()} disable={false} text={'Vaciar'} />
<ButtonSecondary buttonClick={clearProducts()} disable={false} text={'Vaciar'} />
</Header>

<Items>
Expand Down