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

feature: inserido responsividade a aplicação #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[1031/100656.336:ERROR:directory_reader_win.cc(43)] FindFirstFile: O sistema n�o pode encontrar o caminho especificado. (0x3)
2 changes: 0 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import React from "react";
import Inicio from "./pages/inicio";
import Registrar from "./pages/registrar";
import Routes from "./routes";
import { GlobalStyle } from "./styles/global.styled";

Expand Down
9 changes: 9 additions & 0 deletions src/components/Card/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import React from "react";
import { Container } from "./styled";

/**
* Componente card que renderiza um psicologo
*
* @param {*} imageUrl - url da image
* @param {*} nome - nome do psicologo
* @param {*} plano - tipo de plano
* @param {*} endereco - nome da rua
*
*/
export default function Card({ imagemUrl, nome, plano, endereco, ...rest }) {
return (
<Container {...rest} type="button">
Expand Down
12 changes: 10 additions & 2 deletions src/components/Card/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export const Container = styled.button`
bottom: 180px;
margin-left: auto;
margin-right: auto;
width: 128px;
height: 128px;
width: 100%;
height: 100%;
max-height: 128px;
max-width: 128px;
filter: drop-shadow(0px 4px 4px rgba(0, 0, 0, 0.25));
border-radius: 50%;
}
Expand Down Expand Up @@ -49,4 +51,10 @@ export const Container = styled.button`
color: #333333;
}
}

@media (max-width: 768px) {
img {
bottom: 200px;
}
}
`;
7 changes: 7 additions & 0 deletions src/components/Modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import React from "react";
import { Container, Contato, Plano, Descricao, NomePsicologo } from "./styled";
import MaterialModal from "@material-ui/core/Modal";

/**
* Componente modal que renderiza um psicologo selecionado pelo usuário
*
* @param {*} psicologo - objeto contendo os dados do psicologo
* @param {*} abrir - flag com status do modal
* @param {*} fecharModal - função que fecha o modal
*/
export default function Modal({ psicologo, abrir, fecharModal }) {
return (
<MaterialModal
Expand Down
10 changes: 9 additions & 1 deletion src/components/Modal/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const Container = styled.div`

img {
position: absolute;
background: steelblue;
max-width: 200px;
width: 100%;
left: 0;
Expand Down Expand Up @@ -59,6 +58,15 @@ export const Container = styled.div`
color: #7c7c7c;
}
}

@media (max-width: 768px) {
padding: 0 10px 0 10px;

img {
max-width: 100px;
bottom: 350px;
}
}
`;

export const Contato = styled.h2`
Expand Down
5 changes: 1 addition & 4 deletions src/components/Select.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React, { useRef, useEffect } from "react";
import ReactSelect, {
OptionTypeBase,
Props as SelectProps,
} from "react-select";
import ReactSelect from "react-select";
import { useField } from "@unform/core";

const Select = ({ name, ...rest }) => {
Expand Down
23 changes: 17 additions & 6 deletions src/pages/inicio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@ import { ReactComponent as Logo } from "../../assets/logo.svg";
export default function Inicio() {
return (
<Container>
<Logo />
<InputBuscar placeholder="Digite seu endereço" />
<BotaoBuscar href="/pesquisar">Pesquisar</BotaoBuscar>
<BotaoRegistrar href="/registrar">
Quero cadastrar um novo profissional
</BotaoRegistrar>
<div
style={{
display: "flex",
flexDirection: "column",
maxWidth: 612,
width: "100%",
alignItems: "center",
padding: 10,
}}
>
<Logo />
<InputBuscar placeholder="Digite seu endereço" />
<BotaoBuscar href="/pesquisar">Pesquisar</BotaoBuscar>
<BotaoRegistrar href="/registrar">
Quero cadastrar um novo profissional
</BotaoRegistrar>
</div>
</Container>
);
}
3 changes: 1 addition & 2 deletions src/pages/inicio/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const Container = styled.div`
align-items: center;
justify-content: center;
height: 100vh;
position: relative;
`;
export const BotaoBuscar = styled.a`
background: #0f4c81;
Expand All @@ -34,7 +33,7 @@ export const BotaoRegistrar = styled.a`
margin-top: 20px;
`;
export const InputBuscar = styled.input`
width: 612px;
width: 100%;
height: 61px;
background: #ffffff;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.25);
Expand Down
19 changes: 16 additions & 3 deletions src/pages/pesquisar/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import React, { useState, useEffect } from "react";
import { Container, BotaoBuscar, InputBuscar, Logo } from "./styled";
import { Container, InputBuscar, Logo, ContainerHeader } from "./styled";
import logo from "../../assets/logo.svg";
import Card from "../../components/Card";
import axios from "axios";
import Modal from "../../components/Modal";

export default function Pesquisar() {
//hooks são funcoes que armazenam logicas que facilita a utilização
//de determinadas lógicas

//armazena a lista de psicologos
const [psicologos, setPsicologos] = useState([]);

//armazena o psicologo selecionado pelo usuário
const [psicologo, setPsicologo] = useState({});

//flag que armazena o estado do modal, `visivel` ou `oculto`
const [modal, setModal] = useState(false);

//funcao que busca os psicologos cadastrados
//*utlizado dados fake, pois ainda não foi implementado o back-end*
function buscarPsicologos() {
axios
.get("https://randomuser.me/api/?nat=br&results=13")
.then((response) => {
//seta a lista de psicologos dentro do array `psicologos`
setPsicologos(response.data.results);
});
}
Expand All @@ -27,16 +38,18 @@ export default function Pesquisar() {
setModal(false);
}

//hook executado todas as vezes que a tela e aberta
useEffect(() => {
buscarPsicologos();
}, []);

return (
<Container>
<header>
<div style={{ display: "flex", flexDirection: "column" }}>
<ContainerHeader>
<Logo src={logo} />
<InputBuscar placeholder="Digite seu endereço" />
</div>
</ContainerHeader>
</header>

<main>
Expand Down
14 changes: 8 additions & 6 deletions src/pages/pesquisar/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ export const Container = styled.div`
main {
display: flex;
flex-direction: column;
padding: 10px;
padding: 100px 10px 50px 10px;
}
}
`;

export const InputBuscar = styled.input`
width: 612px;
width: 100%;
height: 61px;
background: #ffffff;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.25);
Expand All @@ -51,14 +51,16 @@ export const InputBuscar = styled.input`
::placeholder {
color: #e5e5e5;
}

@media (max-width: 768px) {
width: 100%;
}
`;

export const Logo = styled.img`
align-self: flex-start;
width: 173px;
height: 44px;
`;
export const ContainerHeader = styled.div`
display: flex;
flex-direction: column;
width: 100%;
max-width: 612px;
`;
17 changes: 16 additions & 1 deletion src/pages/registrar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ import Select from "../../components/Select";
import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import * as Yup from "yup";
import { useHistory } from "react-router-dom";

export default function Registrar() {
//hook de navegaçãos
const history = useHistory();

async function handleSubmit(data, { reset }) {
try {
//yup e uma ferramenta utilizada para validação dos campos de um formulario
const schema = Yup.object().shape({
nome: Yup.string().required("Informe o nome"),
email: Yup.string()
Expand All @@ -31,11 +36,21 @@ export default function Registrar() {
await schema.validate(data, {
abortEarly: false,
});

//apresenta mensagem de sucesso
toast.success("Cadastrado com sucesso");
reset();

setTimeout(() => {
//reseta valores do formulario
reset();
//navega para tela inicial
history.push("/");
}, 2000);
} catch (err) {
if (err instanceof Yup.ValidationError) {
const mensagem = err.inner[0].message;
//apresenta mensagem de erro, caso algum campo do
//formulario não esteja conforme solicitado
toast.error(mensagem);
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/pages/registrar/styled.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ export const Container = styled.div`
color: #cccccc;
}
}

@media (max-width: 600px) {
form {
width: 350px;
}
}
`;
export const ButtaoCadastrar = styled.button`
width: 179px;
Expand All @@ -72,11 +66,11 @@ export const ContainerDuasColunas = styled.div`
display: flex;
.cidade {
width: 100%;
margin-right: 20px;
margin-right: 10px;
}
.uf {
width: 50%;
margin-left: 20px;
margin-left: 10px;
}
`;
export const Logo = styled.img`
Expand Down
5 changes: 4 additions & 1 deletion src/routes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import React from "react";
import { BrowserRouter as Router, Switch, Route, Link } from "react-router-dom";
import { BrowserRouter as Router, Switch, Route } from "react-router-dom";
import Inicio from "./pages/inicio";
import Pesquisar from "./pages/pesquisar";
import Registrar from "./pages/registrar";

/**
* Local destinado a declaracão e configuração de uma rota(tela)
*/
export default function Routes() {
return (
<Router>
Expand Down