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
Empty file added back-end-semana-01/.gitignore
Empty file.
40 changes: 40 additions & 0 deletions back-end-semana-01/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//Exercício 1

if(process.argv[4] === true) {console.log("Envie apenas um argumento")}
//console.log( `Ei ${process.argv[2]}! Você tem ${process.argv[3]} anos.` )

if(process.argv[4] === false) {console.log("Envie dois argumentos")}
//console.log( `Ei ${process.argv[2]}! Você tem ${Number(process.argv[3]) } anos. Em 7 anos você terá ${Number(process.argv[3]) + 7} anos.` )

// Exercício 2

/*
switch(process.argv[2]){
case "soma":
console.log( `${process.argv[3]} + ${process.argv[4]} = ${ Number(process.argv[3]) + Number(process.argv[4]) } ` )
break;
case "sub":
console.log( `${process.argv[3]} - ${process.argv[4]} = ${ Number(process.argv[3]) - Number(process.argv[4]) } ` )
break;

case "mult":
console.log( `${process.argv[3]} x ${process.argv[4]} = ${ Number(process.argv[3]) * Number(process.argv[4]) } ` )
break;

case "div":
console.log( `${process.argv[3]} / ${process.argv[4]} = ${ Number(process.argv[3]) / Number(process.argv[4]) } ` )
break;

default:
console.log("Comando não identificado! Use soma, sub, mult ou div")

}

*/

//Exercício 3

const tarefas = ['Dobrar roupas']

tarefas.push(process.argv[2])
console.log( '\x1b[36m%s\x1b[0m', tarefas);
12 changes: 12 additions & 0 deletions back-end-semana-01/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "back-end-semana-01",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "clear && node ./index.js"
},
"author": "Rafael Cacilhas",
"license": "ISC"
}
27 changes: 9 additions & 18 deletions semana-10/labex/src/Components/Paginas/AdminHomePage.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@

import React, {useEffect, useState} from "react";
import {useHistory} from 'react-router-dom';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';
import Card from '@mui/material/Card';
import CardMedia from '@mui/material/CardMedia';
import { CardActionArea } from '@mui/material';
import React, {useEffect} from "react";
import {useHistory} from 'react-router-dom';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';

import TripDetailsPage from "./TripDetailsPage"
import CreateTripPage from "./CreateTripPage"

export default function AdminHomePage() {

const [pag,setPag] = useState("nada")


const history = useHistory()
Expand All @@ -26,9 +22,6 @@ export default function AdminHomePage() {
}, [history])


const renderizaPagina = () => {
return <TripDetailsPage />
}

return (

Expand Down Expand Up @@ -60,14 +53,12 @@ return (
</Box>


<Box sx={{ height: 400, marginTop: 10 }}>
<h2>quede a pag?</h2>
{renderizaPagina}
<Box sx={{ height: 800, marginTop: 10 }}>
<CreateTripPage />
</Box>




</Box>
)
</Box> )
}
195 changes: 194 additions & 1 deletion semana-10/labex/src/Components/Paginas/CreateTripPage.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,203 @@
import React, {useState} from "react";
import axios from "axios";
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';



/* No material a tag é
inputProps = {{ pattern: "[a-z]"}}
*/


export default function CreateTripPage() {

const [form,setForm] = useState({nome:"", planeta:"",data:"", descrição:"", duração:"",})

const criarViagem = () => {

const token = window.localStorage.getItem("token")
const nome = form.nome
const planeta = form.planeta
const data = form.data
const descrição = form.descrição
const duração = form.duração


const URL = 'https://us-central1-labenu-apis.cloudfunctions.net/labeX/rafael-cacilhas-maryam/trips'

const header = {
headers:{
'Content-Type': 'application/json',
'auth': `${token}`
}
}

const body = {
"name" : {nome},
"planet" : {planeta},
"date" : {data},
"description" : {descrição},
"durationInDays" : {duração}
}

axios.post(URL, body,header)
.then( (resposta ) => {
console.log('Deu certo:', resposta.data);
}).catch( (erro) => {
console.log('Deu errado:', erro);
})

}

const mudaForm = (event) => {
const nome = event.target.name
const valor = event.target.value

/* Ou:
const {name,value} = event.target
*/

setForm({ ...form, [nome]: valor });
}



return (
<div>


<h1>CreateTripPage</h1>
<Box
sx={ {
flexGrow: 1,
display: 'flex',
flexDirection: 'column',
justifyContent: 'space-around',
alignItems: 'center',
margin: 0,
marginBottom: 10,
fontFamily: '"Montserrat"',
height: '50vh',
}}>


<Box
sx={ {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}>

<Box
sx={ { marginLeft: 0, marginTop: 5, fontFamily: '"Montserrat"', }}>
<Typography variant="h2" component="div" >
Criar viagem
</Typography>
</Box>

<Typography variant="h7" component="div" >
<ul>
<li>Nome: mínimo de 5 letras</li>
<li>Data: início em 2022</li>
<li>Duração: mínimo de 50 dias</li>
</ul> </Typography>
</Box>

<Box
sx={ {
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
fontFamily: '"Montserrat"',
}}>


<Box
sx={ { marginBottom: 10, marginTop:0, fontFamily: '"Montserrat"', }}>



<form onSubmit={criarViagem}>
<input
required
name = "nome"
type = "text"
value = {form.nome}
onChange = {mudaForm}
placeholder = {'Nome'}
/>

<br/>
<select
required
name = "planeta"
id = "planeta"
value = {form.planeta}
onChange = {mudaForm}
>

<option> Mercúrio </option>
<option> Vênus </option>
<option> Terra </option>
<option> Marte </option>
<option> Júpiter </option>
<option> Saturno </option>
<option> Urano </option>
<option> Neturno </option>
<option disabled> Plutão </option>

</select>

<br/>
<input
required
pattern = ""
name = "data"
id = "data"
type = "date"
value = {form.mail}
onChange = {mudaForm}
/>


<br/>
<input
required
name = "duração"
pattern = ""
id = "duração"
type = "text"
value = {form.duração}
onChange = {mudaForm}
placeholder = {'Duração (dias)'}
/>

<br/>
<input
required
name = "descrição"
pattern = ""
id = "descrição"
type = "text"
value = {form.descrição}
onChange = {mudaForm}
placeholder = {'Uma breve descrição'}
/>


</form>
</Box>


<Button onClick={criarViagem} size='900' variant="contained"><h2>Criar</h2></Button>

</Box>

</Box>



</div>
)
}
10 changes: 1 addition & 9 deletions semana-10/labex/src/Components/Paginas/HomePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Img = styled.img`
transform: rotate(-45deg);
display: inline;

max-width: 100vw;
max-width: 90vw;


position: absolute;
Expand Down Expand Up @@ -90,14 +90,6 @@ export default function HomePage() {

const history = useHistory()

const gotoHome = () => {
history.push("/")
}

const gotoAdmin = () => {
history.push("/admin")
}

const gotoViagens = () => {
history.push("/viagens")
}
Expand Down
Loading