Skip to content

Commit

Permalink
feat: add verificação ocupação
Browse files Browse the repository at this point in the history
  • Loading branch information
ialexanderbrito committed Apr 4, 2022
1 parent 1ebb66c commit 67d8864
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 0 deletions.
63 changes: 63 additions & 0 deletions src/components/CardCliente/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useEffect, useState } from 'react';
import { BsClock } from 'react-icons/bs';

import Avvvatars from 'avvvatars-react';
import { ClienteMetadata } from 'types/IContext';

import { getPhoto } from 'services/get/photo';

import styles from './CardCliente.module.scss';

type Props = {
cliente: ClienteMetadata | undefined;
onClick?: () => void;
};

export function CardCliente({ cliente, onClick }: Props) {
const [photo, setPhoto] = useState('');
const [name, setName] = useState('');

async function getPhotoUser(id: string) {
const { data, error, status } = await getPhoto(id);

if (error) {
switch (status) {
default:
throw new Error('Erro ao buscar informações do usuário');
}
}

if (!data) return;

setPhoto(data[0].j[0].src);
setName(data[0].j[0].name);
}

useEffect(() => {
if (cliente) {
getPhotoUser(cliente.client_id);
}
}, [cliente]);

return (
<div className={styles.card} onClick={onClick} key={cliente?.client_id}>
<div className={styles.alert}>
<br />
</div>
<div className={styles.containerImg}>
{photo === '' ? (
<Avvvatars value={cliente?.client_name || ''} size={50} />
) : (
<img src={photo || cliente?.client_avatar || cliente?.client_picture} alt={cliente?.client_name} />
)}
</div>
<div className={styles.containerInfo}>
<h2 className={styles.title}>{name || cliente?.client_name}</h2>
<strong className={styles.info}>
<BsClock color="#FF9000" size={16} style={{ marginRight: '12px' }} />
{cliente?.hour}
</strong>
</div>
</div>
);
}
47 changes: 47 additions & 0 deletions src/components/Verificacao/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Button } from 'components/Button';

import { useAuth } from 'hooks/useAuth';
import { useRegister } from 'hooks/useRegister';

import styles from './Verificacao.module.scss';

export function VerificacaoOcupacao() {
const { user } = useAuth();
const { formikLoginGoogle } = useRegister();

return (
<>
<h2 className={styles.titleHome}>
Oi {user?.user_metadata.name}, vi que você está logado com o Google.
<br /> E eu preciso saber se você é:
</h2>

<form
onSubmit={(e) => {
e.preventDefault();
formikLoginGoogle.handleSubmit(e);
}}
>
<div className={styles.containerButton}>
<Button
type="submit"
onClick={() => {
formikLoginGoogle.setFieldValue('ocupacao', 'barbeiro');
}}
>
Barbeiro
</Button>

<Button
type="submit"
onClick={() => {
formikLoginGoogle.setFieldValue('ocupacao', 'cliente');
}}
>
Cliente
</Button>
</div>
</form>
</>
);
}

0 comments on commit 67d8864

Please sign in to comment.