Skip to content

Commit

Permalink
Feat/form-de-avaliação
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel0109 committed Mar 1, 2023
1 parent 4179404 commit d32509a
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/assets/imgs/thumbs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/assets/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,14 @@ background-image: url(../imgs/movingMarker.svg);
}
.marker-test.shadowed{
opacity: 0.5 !important;
}
.formButton{
background-color: var(--items-bg);
z-index: 1001;
position: absolute;
top: -50px;
right: 0;
padding: 8px;
border-radius: 50em;

}
56 changes: 56 additions & 0 deletions src/components/Form/Form.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import styles from './styles.module.scss'
import { useContext, useState } from 'react'
import { FormContext } from "../../hooks/useForm";
import { GrClose } from 'react-icons/gr'



export function Form() {
const {activateForm } = useContext(FormContext)

const [selectedOption, setSelectedOption] = useState(null);

const handleSubmit = (e) => {
e.preventDefault();
console.log(selectedOption);
}


return (

<>
<div className="fixed bottom-0 translate-x-1/2 right-1/2 w-11/12 z-[402]">
<div className={styles.formCard}>
<div className="flex justify-end">
<button onClick={() => activateForm()}>
<GrClose />
</button>
</div>
<h1 className="text-xl text-center font-semibold mb-3">Essa informação<br/> foi útil para você?</h1>
<form className='flex flex-col' onSubmit={handleSubmit}>
<div className='flex justify-evenly'>
<label className={styles.thumbContainer}>
<input type="radio" value="thumbsUp" checked={selectedOption === "positivo"} onChange={() => setSelectedOption("positivo")} />
<span className={styles.thumbUp}></span>
</label>
<label className={styles.thumbContainer}>
<input type="radio" value="thumbsDown" checked={selectedOption === "negativo"} onChange={() => setSelectedOption("negativo")} />
<span className={styles.thumbDown}></span>
</label>
</div>
<div className='mt-5'>
<p className="text-sm text-center font-semibold mb-3">Quer deixar um comentário?</p>
<input className='rounded-md w-full p-2 pb-8 bg-[#cccccc]/25' type="text" name="" id="" placeholder='Digite algo aqui...' />

</div>
<button className='block bg-black text-white text-bold uppercase p-1 rounded-md mt-3' type="submit">Enviar</button>
</form>

</div>
</div>

</>
)


}
75 changes: 75 additions & 0 deletions src/components/Form/styles.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
.formCard {
background-color: var(--white);
border-top-left-radius: 8px;
border-top-right-radius: 8px;
padding: 20px;
padding-bottom: 5rem;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
overflow: scroll;


}

.routeList {

li:last-child {
border-bottom: none !important;
}

.routeName {
display: flex;
align-items: center;

.shortName {
display: flex;
background-color: var(--items-bg);
border-radius: 3px;
padding: 4px 3px;

p {
color: var(--text-color);
}
}
}
}

.directionBanner {
background-color: var(--gray-100);
text-align: center;
padding: 8px;
margin-bottom: 25px;
}
.thumbContainer{
display: block;
position: relative;
margin-block: 20px ;
input{
display: none;
}
}
.thumbUp:after{
content: url(../../assets/imgs/thumbs.svg);
position: absolute;
top: -10px;
left: -18px;
padding: 4px;
width: 35px;
display: block;
height: 35px;
border-radius: 50em;
border: 2px solid black;

}
.thumbDown:after{
content: url(../../assets/imgs/thumbs.svg);
position: absolute;
top: -10px;
left: -18px;
padding: 4px;
width: 35px;
display: block;
height: 35px;
border-radius: 50em;
border: 2px solid black;
transform: rotate(180deg);
}
1 change: 0 additions & 1 deletion src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ThemeContext } from '../../hooks/getTheme'
import { RoutesContext } from '../../hooks/getRoutes'
import { NameContext } from '../../hooks/getName'
import { api } from '../../services/api'
import { GPSContext } from '../../hooks/getGPS'
import { MovingMarkerContext } from '../../hooks/getMovingMarkers'

export function Header(props) {
Expand Down
33 changes: 26 additions & 7 deletions src/components/InfoCard/InfoCard.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@

import { useState, useEffect, useContext } from "react"
import { api } from '../../services/api'


import { Oval } from 'react-loader-spinner'
import { GrClose } from 'react-icons/gr'
import styles from './styles.module.scss'
import bus from '../../assets/imgs/bus.svg'
import busSppo from '../../assets/imgs/busSppo.svg'
import pin from '../../assets/imgs/pin.svg'
import { useState, useEffect, useContext } from "react"

import { MovingMarkerContext } from '../../hooks/getMovingMarkers'
import { FormContext } from "../../hooks/useForm";
import { ThemeContext } from '../../hooks/getTheme'
import { CodeContext } from '../../hooks/getCode'
import { TripContext } from '../../hooks/getTrips'
import { RoutesContext } from '../../hooks/getRoutes'
import { Oval } from 'react-loader-spinner'
import { ThemeContext } from '../../hooks/getTheme'
import { api } from '../../services/api'
import { GrClose } from 'react-icons/gr'
import { MovingMarkerContext } from '../../hooks/getMovingMarkers'
import { info } from 'autoprefixer'



export function InfoCard() {
const [name, setName] = useState()
Expand All @@ -21,6 +27,7 @@ export function InfoCard() {
const { routes, isParent, getMultiplePages, plataforms, setRoutes, stopId, locationType } = useContext(RoutesContext)
const {setTracked} = useContext(MovingMarkerContext)
const { setTrip } = useContext(TripContext);
const { activateForm } = useContext(FormContext)


useEffect(() => {
Expand All @@ -39,8 +46,15 @@ export function InfoCard() {
return (

<>

{isParent ? <div className="fixed bottom-0 translate-x-1/2 right-1/2 w-11/12 z-[401]">

<div className={styles.routesCard}>
<button className='formButton inputShadow' onClick={() => activateForm()}>
<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M21.8289 9.34643C21.5163 8.97112 21.1251 8.669 20.683 8.46139C20.2409 8.25378 19.7586 8.14574 19.2701 8.14491H14.197L14.82 6.55399C15.0791 5.85742 15.1655 5.10838 15.0715 4.37113C14.9776 3.63388 14.7062 2.93042 14.2806 2.32109C13.8551 1.71176 13.2881 1.21476 12.6283 0.872708C11.9684 0.530659 11.2355 0.353774 10.4923 0.357227C10.2783 0.357674 10.0689 0.419835 9.88937 0.536258C9.7098 0.652681 9.56763 0.818425 9.47988 1.01362L6.30919 8.14491H3.69475C2.80957 8.14491 1.96065 8.49654 1.33473 9.12246C0.708814 9.74837 0.357178 10.5973 0.357178 11.4825V19.2702C0.357178 20.1553 0.708814 21.0043 1.33473 21.6302C1.96065 22.2561 2.80957 22.6077 3.69475 22.6077H17.8572C18.638 22.6075 19.394 22.3335 19.9936 21.8334C20.5933 21.3334 20.9986 20.639 21.1391 19.8709L22.5521 12.0832C22.6394 11.6019 22.62 11.1073 22.495 10.6344C22.37 10.1614 22.1426 9.72175 21.8289 9.34643ZM5.9198 20.3827H3.69475C3.39969 20.3827 3.11672 20.2655 2.90808 20.0568C2.69944 19.8482 2.58223 19.5652 2.58223 19.2702V11.4825C2.58223 11.1874 2.69944 10.9044 2.90808 10.6958C3.11672 10.4872 3.39969 10.37 3.69475 10.37H5.9198V20.3827ZM20.3826 11.6827L18.9697 19.4704C18.9223 19.7296 18.7845 19.9635 18.5808 20.1306C18.377 20.2976 18.1206 20.387 17.8572 20.3827H8.14485V9.49106L11.1709 2.68241C11.4824 2.77322 11.7717 2.92761 12.0205 3.13585C12.2693 3.34409 12.4723 3.60165 12.6165 3.89227C12.7608 4.18289 12.8433 4.50026 12.8587 4.82435C12.8741 5.14844 12.8222 5.47221 12.7062 5.77523L12.1166 7.36614C11.9909 7.7024 11.9485 8.06408 11.9929 8.42029C12.0374 8.7765 12.1673 9.11668 12.3717 9.41178C12.5761 9.70689 12.8488 9.94816 13.1667 10.115C13.4845 10.2819 13.838 10.3693 14.197 10.37H19.2701C19.4335 10.3697 19.595 10.4054 19.7431 10.4747C19.8912 10.5439 20.0221 10.6449 20.1268 10.7705C20.2339 10.8943 20.3124 11.0403 20.3567 11.198C20.4009 11.3557 20.4098 11.5212 20.3826 11.6827Z" fill="white" />
</svg>
</button>
{!routes ? <></> : <div className='flex justify-end'>
<button onClick={() => (setRoutes(), setTracked(), infoLinha())}>
<GrClose />
Expand Down Expand Up @@ -98,6 +112,11 @@ export function InfoCard() {
// FINAL CARD COM PARENT STATION
<div className="fixed bottom-0 translate-x-1/2 right-1/2 w-11/12 z-[401]">
<div className={styles.routesCard}>
<button className='formButton inputShadow' onClick={() => activateForm()}>
<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M21.8289 9.34643C21.5163 8.97112 21.1251 8.669 20.683 8.46139C20.2409 8.25378 19.7586 8.14574 19.2701 8.14491H14.197L14.82 6.55399C15.0791 5.85742 15.1655 5.10838 15.0715 4.37113C14.9776 3.63388 14.7062 2.93042 14.2806 2.32109C13.8551 1.71176 13.2881 1.21476 12.6283 0.872708C11.9684 0.530659 11.2355 0.353774 10.4923 0.357227C10.2783 0.357674 10.0689 0.419835 9.88937 0.536258C9.7098 0.652681 9.56763 0.818425 9.47988 1.01362L6.30919 8.14491H3.69475C2.80957 8.14491 1.96065 8.49654 1.33473 9.12246C0.708814 9.74837 0.357178 10.5973 0.357178 11.4825V19.2702C0.357178 20.1553 0.708814 21.0043 1.33473 21.6302C1.96065 22.2561 2.80957 22.6077 3.69475 22.6077H17.8572C18.638 22.6075 19.394 22.3335 19.9936 21.8334C20.5933 21.3334 20.9986 20.639 21.1391 19.8709L22.5521 12.0832C22.6394 11.6019 22.62 11.1073 22.495 10.6344C22.37 10.1614 22.1426 9.72175 21.8289 9.34643ZM5.9198 20.3827H3.69475C3.39969 20.3827 3.11672 20.2655 2.90808 20.0568C2.69944 19.8482 2.58223 19.5652 2.58223 19.2702V11.4825C2.58223 11.1874 2.69944 10.9044 2.90808 10.6958C3.11672 10.4872 3.39969 10.37 3.69475 10.37H5.9198V20.3827ZM20.3826 11.6827L18.9697 19.4704C18.9223 19.7296 18.7845 19.9635 18.5808 20.1306C18.377 20.2976 18.1206 20.387 17.8572 20.3827H8.14485V9.49106L11.1709 2.68241C11.4824 2.77322 11.7717 2.92761 12.0205 3.13585C12.2693 3.34409 12.4723 3.60165 12.6165 3.89227C12.7608 4.18289 12.8433 4.50026 12.8587 4.82435C12.8741 5.14844 12.8222 5.47221 12.7062 5.77523L12.1166 7.36614C11.9909 7.7024 11.9485 8.06408 11.9929 8.42029C12.0374 8.7765 12.1673 9.11668 12.3717 9.41178C12.5761 9.70689 12.8488 9.94816 13.1667 10.115C13.4845 10.2819 13.838 10.3693 14.197 10.37H19.2701C19.4335 10.3697 19.595 10.4054 19.7431 10.4747C19.8912 10.5439 20.0221 10.6449 20.1268 10.7705C20.2339 10.8943 20.3124 11.0403 20.3567 11.198C20.4009 11.3557 20.4098 11.5212 20.3826 11.6827Z" fill="white" />
</svg>
</button>
<p className='text-[#707070] text-sm'>Você está em</p>
<h1 className="text-xl font-semibold mb-3">{name}</h1>
<ul className={styles.routeList}>
Expand Down
7 changes: 7 additions & 0 deletions src/components/SequenceCard/SequenceCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { RoutesContext } from '../../hooks/getRoutes'
import { GrClose } from 'react-icons/gr'
import { ThemeContext } from '../../hooks/getTheme'
import { ShapeContext } from '../../hooks/getShape'
import { FormContext } from "../../hooks/useForm";


export function SequenceCard() {
Expand All @@ -16,6 +17,7 @@ export function SequenceCard() {
const {stopId} = useContext(RoutesContext)
const {theme} = useContext(ThemeContext)
const { setPoints } = useContext(ShapeContext)
const { activateForm } = useContext(FormContext)
function clearMapInfo() {
setTrip('')
setPoints('')
Expand All @@ -26,6 +28,11 @@ export function SequenceCard() {
<>
<div className="fixed bottom-0 translate-x-1/2 right-1/2 w-11/12 z-[401]">
<div className={styles.sequenceCard}>
<button className='formButton inputShadow' onClick={() => activateForm()}>
<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M21.8289 9.34643C21.5163 8.97112 21.1251 8.669 20.683 8.46139C20.2409 8.25378 19.7586 8.14574 19.2701 8.14491H14.197L14.82 6.55399C15.0791 5.85742 15.1655 5.10838 15.0715 4.37113C14.9776 3.63388 14.7062 2.93042 14.2806 2.32109C13.8551 1.71176 13.2881 1.21476 12.6283 0.872708C11.9684 0.530659 11.2355 0.353774 10.4923 0.357227C10.2783 0.357674 10.0689 0.419835 9.88937 0.536258C9.7098 0.652681 9.56763 0.818425 9.47988 1.01362L6.30919 8.14491H3.69475C2.80957 8.14491 1.96065 8.49654 1.33473 9.12246C0.708814 9.74837 0.357178 10.5973 0.357178 11.4825V19.2702C0.357178 20.1553 0.708814 21.0043 1.33473 21.6302C1.96065 22.2561 2.80957 22.6077 3.69475 22.6077H17.8572C18.638 22.6075 19.394 22.3335 19.9936 21.8334C20.5933 21.3334 20.9986 20.639 21.1391 19.8709L22.5521 12.0832C22.6394 11.6019 22.62 11.1073 22.495 10.6344C22.37 10.1614 22.1426 9.72175 21.8289 9.34643ZM5.9198 20.3827H3.69475C3.39969 20.3827 3.11672 20.2655 2.90808 20.0568C2.69944 19.8482 2.58223 19.5652 2.58223 19.2702V11.4825C2.58223 11.1874 2.69944 10.9044 2.90808 10.6958C3.11672 10.4872 3.39969 10.37 3.69475 10.37H5.9198V20.3827ZM20.3826 11.6827L18.9697 19.4704C18.9223 19.7296 18.7845 19.9635 18.5808 20.1306C18.377 20.2976 18.1206 20.387 17.8572 20.3827H8.14485V9.49106L11.1709 2.68241C11.4824 2.77322 11.7717 2.92761 12.0205 3.13585C12.2693 3.34409 12.4723 3.60165 12.6165 3.89227C12.7608 4.18289 12.8433 4.50026 12.8587 4.82435C12.8741 5.14844 12.8222 5.47221 12.7062 5.77523L12.1166 7.36614C11.9909 7.7024 11.9485 8.06408 11.9929 8.42029C12.0374 8.7765 12.1673 9.11668 12.3717 9.41178C12.5761 9.70689 12.8488 9.94816 13.1667 10.115C13.4845 10.2819 13.838 10.3693 14.197 10.37H19.2701C19.4335 10.3697 19.595 10.4054 19.7431 10.4747C19.8912 10.5439 20.0221 10.6449 20.1268 10.7705C20.2339 10.8943 20.3124 11.0403 20.3567 11.198C20.4009 11.3557 20.4098 11.5212 20.3826 11.6827Z" fill="white" />
</svg>
</button>
<div className='flex justify-end'>
<button onClick={() => clearMapInfo()}>
<GrClose />
Expand Down
8 changes: 3 additions & 5 deletions src/hooks/getRoutes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export function RoutesProvider({ children }) {
}
}, [code])

const filteredTrips = [];
async function getMultiplePages(url) {
const filteredTrips = [];
await api
.get(url)
.then(({ data }) => {
Expand All @@ -54,10 +54,8 @@ export function RoutesProvider({ children }) {
.get(url)
.then(({ data }) => {
data.results.forEach((item) => { allStations.push(item) })
if (data.next) {
getStations(data.next)
}
setStations([...allStations])

setStations(allStations)
})

}
Expand Down
25 changes: 25 additions & 0 deletions src/hooks/useForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { createContext, useEffect, useState } from "react";


export const FormContext = createContext()




export function FormProvider({ children }) {
const [activeForm, setActiveForm] = useState(false)

function activateForm() {
if (activeForm) {
setActiveForm(false)
} else {
setActiveForm(true)
}
}

return (
<FormContext.Provider value={{activeForm, setActiveForm, activateForm}}>
{children}
</FormContext.Provider>
)
}
3 changes: 3 additions & 0 deletions src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TripProvider } from './hooks/getTrips'
import { ThemeProvider } from './hooks/getTheme'
import { ShapeProvider } from './hooks/getShape'
import { GPSProvider } from './hooks/getGPS'
import { FormProvider } from './hooks/useForm'
import { MovingMarkerProvider } from './hooks/getMovingMarkers'
import { ToastContainer } from 'react-toastify'
import { BrowserRouter as Router } from 'react-router-dom'
Expand All @@ -27,7 +28,9 @@ ReactDOM.createRoot(document.getElementById('root')).render(
<ThemeProvider>
<GPSProvider>
<MovingMarkerProvider>
<FormProvider>
<App />
</FormProvider>
</MovingMarkerProvider>
</GPSProvider>
</ThemeProvider>
Expand Down
Loading

0 comments on commit d32509a

Please sign in to comment.