diff --git a/src/components/App.js b/src/components/App.js
deleted file mode 100644
index 441630f..0000000
--- a/src/components/App.js
+++ /dev/null
@@ -1,42 +0,0 @@
-import { BrowserRouter, Switch, Route } from 'react-router-dom';
-import React, { useState, useEffect } from 'react';
-import UserContext from '../contexts/UserContexts';
-import ProgressContext from '../contexts/ProgressContexts';
-import Home from './Home/Home';
-import Register from './Register/Register';
-import Habits from './Habits/Habits';
-import Today from './Today/Today';
-import Historic from './Historic/Historic';
-import '../css/reset.css';
-import '../css/style.css';
-
-export default function App(){
- const [user, setUser] = useState("");
- const [progress, setProgress] = useState(0);
-
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- )
-}
\ No newline at end of file
diff --git a/src/components/Footer.js b/src/components/Footer.js
deleted file mode 100644
index 7a3f439..0000000
--- a/src/components/Footer.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import styled from 'styled-components';
-import { Link } from 'react-router-dom';
-import { CircularProgressbar, buildStyles } from 'react-circular-progressbar';
-import 'react-circular-progressbar/dist/styles.css';
-import ProgressContext from '../contexts/ProgressContexts';
-import { useContext } from 'react';
-
-
-export default function Footer () {
- const { progress } = useContext(ProgressContext);
-
- return(
-
-
- Hábitos
-
-
-
-
-
-
-
- Histórico
-
-
- )
-}
-
-const Bottom = styled.footer`
- position: fixed;
- bottom: 0;
- left: 0;
- width: 100%;
- height: 70px;
- padding: 0 36px;
- background-color: #fff;
- display: flex;
- justify-content: space-between;
- align-items: center;
- p{
- font-family: 'Lexend Deca', sans-serif;
- color: #52B6FF;
- font-size: 18px;
- }
- div{
- width: 91px;
- height: 91px;
- margin-bottom: 50px;
- border-radius: 50%;
- background-color: #52B6FF;
- font-family: 'Lexend Deca', sans-serif;
- color: #fff;
- font-size: 18px;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 6px;
- }
-`;
-
-
-
diff --git a/src/components/Habits/Habits.js b/src/components/Habits/Habits.js
deleted file mode 100644
index a421f53..0000000
--- a/src/components/Habits/Habits.js
+++ /dev/null
@@ -1,341 +0,0 @@
-import styled from 'styled-components';
-import { useState, useEffect, useContext } from 'react';
-import Header from '../Header'
-import Footer from '../Footer';
-import axios from 'axios';
-import UserContext from '../../contexts/UserContexts';
-import { TrashOutline } from 'react-ionicons';
-import Loader from "react-loader-spinner";
-
-export default function Habits (){
- const { user, setUser }= useContext(UserContext);
- const [day, setDay ]= useState([
- {weekday: "D", isClicked: false, id: 0},
- {weekday: "S", isClicked: false, id: 1},
- {weekday: "T", isClicked: false, id: 2},
- {weekday: "Q", isClicked: false, id: 3},
- {weekday: "Q", isClicked: false, id: 4},
- {weekday: "S", isClicked: false, id: 5},
- {weekday: "S", isClicked: false, id: 6}
- ])
- const [habitName,setHabitName] = useState ("");
- const [addHabits, setAddHabits] = useState(false);
- const [items, setItems] = useState([]);
- const [loading, setLoading] = useState(false);
- const config = {
- headers: {
- "Authorization": `Bearer ${user.token}`
- }
- }
- const body = {
- name: habitName,
- days: day.filter((d,i) => d.isClicked === true).map((d,i) => d.id)
- }
-
- useEffect(() =>{
- if(localStorage.getItem('user')){
- setUser(JSON.parse(localStorage.getItem('user')))
- }
- }, [])
-
- useEffect(() => {
- const request = axios.get("https://mock-api.bootcamp.respondeai.com.br/api/v2/trackit/habits", config);
-
- request.then(resposta => {
- setItems(resposta.data);
- });
-
- request.catch(error => alert("Erro! Tente novamente :/"))
- }, []);
-
-
- return(
- <>
-
-
-
-
- Meus hábitos
-
- setAddHabits(true)}>
- +
-
-
-
-
- setHabitName(e.target.value)}
- />
-
- {day.map((d,i) =>
- clickDay(d)}
- key = {i}
- >
- {d.weekday}
- )}
-
-
- setAddHabits(false)}
- >
- Cancelar
-
-
- {!day.find((d,i) => d.isClicked)?
- alert("Selecione pelo menos um dia da semana"):
- sendHabit(day, setLoading, setHabitName, setItems, setAddHabits, setDay, config, body, items)
- }}>
- {loading === true? "": "Salvar"}
-
-
-
-
-
-
- {items.length === 0? "Você não tem nenhum hábito cadastrado ainda. Adicione um hábito para começar a trackear!": ""}
-
-
- {items.map((h,i)=>
-
-
- {h.name}
- deleteHabit(h.id, user.token, config, setItems)}
- />
-
-
- {day.map((d,i) => sameDay(h.days, d.id)? {...d, isChoose: true}: d).map((c,i)=>{c.weekday})}
-
-
- )}
-
-
-
- >
- )
-
- function clickDay (d){
- d.isClicked = !(d.isClicked);
- setDay([...day]);
- }
-
- function sameDay(h, d){
- for (let i = 0; i < h.length; i++){
- if(h[i] === d){
- return true;
- }
-
- }
- return false;
- }
-
- function sendHabit (day, setLoading, setHabitName, setItems, setAddHabits, setDay, config, body, items){
- if (!day.find((d,i) => d.isClicked)){
- alert("Selecione pelo menos um dia da semana");
- return;
- }
- else{
- setLoading(true);
-
- const request = axios.post("https://mock-api.bootcamp.respondeai.com.br/api/v2/trackit/habits", body, config);
-
- request.then(resposta => {
- setHabitName("");
- setItems([...items, resposta.data]);
- setLoading(false);
- setAddHabits(false);
- setDay ([
- {weekday: "D", isClicked: false, id: 0},
- {weekday: "S", isClicked: false, id: 1},
- {weekday: "T", isClicked: false, id: 2},
- {weekday: "Q", isClicked: false, id: 3},
- {weekday: "Q", isClicked: false, id: 4},
- {weekday: "S", isClicked: false, id: 5},
- {weekday: "S", isClicked: false, id: 6}]);
- })
-
- request.catch(error => {
- alert("Erro! Tente novamente :/");
- setLoading (false);
- })
- }
- }
-
- function deleteHabit (id, token, config, setItems) {
- let resultado = window.confirm("Você gostaria de apagar esse hábito?");
- if(resultado){
- const deleteAPI = axios.delete(`https://mock-api.bootcamp.respondeai.com.br/api/v2/trackit/habits/${id}`, {
- headers: {
- "Authorization": `Bearer ${token}`
- },
- });
-
- deleteAPI.then(response => deleteSuccess (setItems));
-
- deleteAPI.catch(error => alert("Erro! Tente novamente :/"));
- }
- }
-
- function deleteSuccess (setItems){
- const request = axios.get("https://mock-api.bootcamp.respondeai.com.br/api/v2/trackit/habits", config);
-
- request.then(response => {
- setItems(response.data);
- });
-
- request.catch(error => alert("Erro! Tente novamente :/"))
- ;
- }
-}
-
-const Habit = styled.div`
- margin: auto;
- margin-top: 100px;
- width: 90%;
- display: flex;
- justify-content: space-between;
- align-items: center;
-
- h2{
- font-family: 'Lexend Deca', sans-serif;
- font-size: 23px;
- color: #126BA5;
- }
- div{
- width: 40px;
- height: 35px;
- background-color: #52B6FF;
- border-radius: 5px;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 27px;
- color: #fff;
- display: flex;
- justify-content: center;
- align-items: center;
- }
-`;
-
-const Text = styled.p`
- margin: 20px auto;
- width: 90%;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 18px;
- color: #666;
-`;
-
-const NewHabit = styled.div`
- margin: 20px auto;
- width: 90%;
- background-color: #FFFFFF;
- height: 180px;
- border-radius: 5px;
- display: ${props => props.display === true? "flex": "none"};
- flex-direction: column;
- align-items: center;
-
- input{
- width: 90%;
- height: 45px;
- margin-top: 18px;
- border: 1px solid #D5D5D5;
- border-radius: 5px;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 20px;
- color: #AFAFAF;
- ::-webkit-input-placeholder {
- color: #DBDBDB;
- padding: 11px;
- }
- }
-`;
-
-const Weekday = styled.div`
- display: flex;
- width: 90%;
- margin-top: 8px;
-`;
-
-const Day = styled.div`
- width: 30px;
- height: 30px;
- margin-right: 4px;
- display: flex;
- justify-content: center;
- align-items: center;
- border: 1px solid #D5D5D5;
- border-radius: 5px;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 20px;
- color: ${props => props.state? "#fff": "#DBDBDB"};
- background-color: ${props => props.state? "#DBDBDB": "#fff"};
-`;
-
-const Buttons = styled.div`
- width: 90%;
- margin-top: 36px;
- display: flex;
- align-items: center;
- justify-content: flex-end;
-
- p{
- font-family: 'Lexend Deca', sans-serif;
- font-size: 16px;
- color: #52B6FF;
- }
-
- div{
- height: 35px;
- width: 85px;
- padding: 8px 18px;
- margin-left: 23px;
- background-color: #52B6FF;
- border-radius: 5px;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 16px;
- color: #fff;
- display: flex;
- justify-content: center;
- align-items: center;
- }
-`;
-
-const OldHabits = styled.div`
- width: 90%;
- height: 91px;
- margin: auto;
- padding: 13px 15px;
- border-radius: 5px;
- background-color: #fff;
- display: ${props => props.display? "blocked": "none"};
- margin-bottom: 10px;
- p{
- color: #666666;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 20px;
- }
- span{
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 8px;
- }
-`;
-
-const Div = styled.div`
- height: 110px;
-`;
\ No newline at end of file
diff --git a/src/components/Header.js b/src/components/Header.js
deleted file mode 100644
index c49dd2c..0000000
--- a/src/components/Header.js
+++ /dev/null
@@ -1,42 +0,0 @@
-import styled from 'styled-components';
-import UserContext from '../contexts/UserContexts';
-import { useContext } from 'react';
-
-export default function Header (){
- const { user }= useContext(UserContext);
- const { image } = user;
-
- return(
-
- TrackIt
-
-
- )
-}
-
-const Top = styled.header`
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 70px;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 18px;
- background-color: #126BA5;
- box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.15);
- z-index: 2;
-
- h1{
- font-family: 'Playball', cursive;
- font-size: 40px;
- color: #fff;
- }
-
- img{
- border-radius: 50%50%;
- height: 51px;
- width: 51px;
- }
-`;
diff --git a/src/components/Historic/CalendarClick.js b/src/components/Historic/CalendarClick.js
deleted file mode 100644
index 417807c..0000000
--- a/src/components/Historic/CalendarClick.js
+++ /dev/null
@@ -1,49 +0,0 @@
-import styled from 'styled-components';
-import HabitsCheck from './HabitsCheck';
-
-
-export default function CalendarClick ({ state, setstate, information }){
- return(
-
-
-
Hábitos do dia {information[0]}
- {information.length === 0? "" : information[1].map((n,i) => )}
- setstate(!state)}>Fechar
-
-
- )
-}
-
-const DayClick = styled.div`
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: red;
- display: ${props => props.state? "blocked" : "none"};
- background-color: rgba(255,255,255,0.7);
- z-index: 0;
- div{
- width: 90%;
- margin: auto;
- margin-top: 155px;
- padding: 13px 13px 17px 15px;
- background-color: #fff;
- border-radius: 5px;
- }
- h2{
- font-family: 'Lexend Deca', sans-serif;
- font-size: 23px;
- color: #126BA5;
- margin-bottom: 10px;
- }
-`;
-
-const Close = styled.div`
- font-family: 'Lexend Deca', sans-serif;
- font-size: 16px;
- color: #52B6FF;
- text-align: center;
- margin-top: 10px!important;
-`;
diff --git a/src/components/Historic/HabitsCheck.js b/src/components/Historic/HabitsCheck.js
deleted file mode 100644
index 7d27c33..0000000
--- a/src/components/Historic/HabitsCheck.js
+++ /dev/null
@@ -1,67 +0,0 @@
-import styled from 'styled-components';
-import { CheckmarkOutline } from 'react-ionicons'
-import { CloseOutline } from 'react-ionicons'
-
-export default function HabitsCheck ({habitName, done}){
- return(
- <>
-
-
- - {habitName}
- {done? "Hábito concluído!": "Hábito não concluído :("}
-
-
- {done?
- :
-
- }
-
-
- >
- )
-}
-
-const Done = styled.div`
- margin-top: 0px!important;
- padding: 0px!important;
-
- p{
- font-family: 'Lexend Deca', sans-serif;
- font-size: 16px;
- color: ${props => props.state? "#8FC549": "#666"};
- margin: 5px;
- }
- h3{
- font-family: 'Lexend Deca', sans-serif;
- font-size: 18px;
- color: #126BA5;
- }
-`;
-
-const Check = styled.div`
- margin-top: 5px!important;
- padding: 20px!important;
- width: 30px!important;
- height: 30px;
- background-color: ${props=> props.state?"#8FC549": "#CFCFCF"}!important;
- display: flex;
- justify-content: center;
- align-items: center;
-
-`
-const AllHabits = styled.div`
- margin-top: 0px!important;
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 0px!important;
- margin-bottom: 10px!important;
-`
diff --git a/src/components/Historic/Historic.js b/src/components/Historic/Historic.js
deleted file mode 100644
index 7332c0c..0000000
--- a/src/components/Historic/Historic.js
+++ /dev/null
@@ -1,119 +0,0 @@
-import Header from '../Header';
-import styled from 'styled-components';
-import Footer from '../Footer';
-import Calendar from 'react-calendar';
-import 'react-calendar/dist/Calendar.css';
-import dayjs from 'dayjs';
-import { useState, useEffect, useContext } from 'react'
-import UserContext from '../../contexts/UserContexts';
-import axios from 'axios';
-import CalendarClick from './CalendarClick';
-
-
-export default function Historic () {
- const [date, setDate] = useState(new Date());
- const { user }= useContext(UserContext);
- const [items, setItems] = useState([]);
- const now = dayjs().format('DD/MM/YYYY');
- const days = items.map((d, i) => d.day);
- const [state, setstate] = useState(false);
- const [information, setInformation] = useState([]);
- const mark = items.map((d, i) => d.day)
- const config = {
- headers: {
- "Authorization": `Bearer ${user.token}`
- }
- }
-
- useEffect(() => {
- const request = axios.get("https://mock-api.bootcamp.respondeai.com.br/api/v2/trackit/habits/history/daily", config);
-
- request.then(resposta => {
- setItems(resposta.data);
- });
-
- request.catch(error => alert("Erro! Tente novamente :/"))
- }, []);
-
- return(
- <>
-
-
- Histórico
-
- {clickWeekday (days, value, setstate, items, setInformation)}}
- tileClassName=
- {({ date, view }) => markedDays(days, date, items)}
- />
-
-
-
- >
- )
- function clickWeekday (days, value, setState, items, setInfomation){
- if(days.find(x => x === dayjs(value).format('DD/MM/YYYY'))){
- setState(true)
- let chosen = [];
- chosen = items.find((item,i) => item.day === dayjs(value).format('DD/MM/YYYY'))
- let habitChosen = [];
-
- for(let i = 0; i < chosen.habits.length; i++){
- habitChosen.push({name: chosen.habits[i].name, done: chosen.habits[i].done})
- }
-
- setInfomation([dayjs(value).format('DD/MM/YYYY'), habitChosen])}
- }
-
- function markedDays(days, date, items) {
-
- let habit = [];
- let doneHabit = [];
-
- if(days.find(x => x === dayjs(date).format('DD/MM/YYYY'))){
-
- if(dayjs(date).format('DD/MM/YYYY') === now){
- return 'today';
- }
-
- else{
- for(let i = 0; i < items.length; i++){
- if(items[i].day === dayjs(date).format('DD/MM/YYYY'))
- habit = items[i].habits;
- for (let j = 0; j < habit.length; j++){
- doneHabit.push(habit[i].done)
- }
- }
- return `${doneHabit.reduce((acc, item) => acc && item, true)}`
- }
- }
- }
-}
-
-const Habit = styled.div`
- margin: auto;
- margin-top: 100px;
- width: 90%;
- display: flex;
- justify-content: space-between;
- align-items: center;
- h2{
- font-family: 'Lexend Deca', sans-serif;
- font-size: 23px;
- color: #126BA5;
- }
-`;
-
-const Div = styled.div`
- height: 110px;
-`
diff --git a/src/components/Home/Home.js b/src/components/Home/Home.js
deleted file mode 100644
index 1a762cc..0000000
--- a/src/components/Home/Home.js
+++ /dev/null
@@ -1,120 +0,0 @@
-import { useState, useContext, useEffect } from 'react';
-import styled from 'styled-components';
-import { Link, useHistory } from 'react-router-dom';
-import Loader from "react-loader-spinner";
-import Logo from '../Logo'
-import UserContext from '../../contexts/UserContexts';
-import axios from 'axios';
-
-export default function Home (){
- const [email,setEmail] = useState ("");
- const [password, setPassword] = useState ("");
- const [loading, setLoading] = useState(false);
- const { setUser }= useContext(UserContext);
- const body = {
- email,
- password
- }
- let history = useHistory();
-
- useEffect(() =>{
- if(localStorage.getItem('user')){
- setUser(JSON.parse(localStorage.getItem('user')))
- history.push("/hoje");
- }}, [])
-
- return (
- <>
-
-
-
- setEmail(e.target.value)}
- />
- setPassword(e.target.value)}
- />
- login (setLoading, body, setUser)}>
- {loading === true? "": "Entrar"}
-
-
-
-
-
- Não tem uma conta? Cadastre-se!
-
- >
- )
-
- function login (setLoading, body, setUser){
- const request = axios.post("https://mock-api.bootcamp.respondeai.com.br/api/v2/trackit/auth/login", body);
- setLoading(true);
-
- request.then(response => {
- const user = JSON.stringify(response.data)
- localStorage.setItem('user', user);
- setUser(JSON.parse(localStorage.getItem('user')));
- history.push("/hoje")});
-
- request.catch(error => {
- alert("Erro! Email e/ou senha incorreto(s)");
- setLoading(false);
- })
- }
-}
-
-const Data = styled.div`
- display: flex;
- flex-direction: column;
- padding: 25px 36px;
-
- input{
- height: 45px;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 20px;
- color: #AFAFAF;
- border: 1px solid #D5D5D5;
- border-radius: 5px;
- margin-bottom: 6px;
- ::-webkit-input-placeholder {
- color: #DBDBDB;
- padding: 11px;
- }
- }
-
- div{
- cursor: pointer;
- height: 45px;
- font-size: 21px;
- font-family: 'Lexend Deca', sans-serif;
- color: #fff;
- background-color: #52B6FF;
- border-radius: 5px;
- display: flex;
- justify-content: center;
- align-items: center;
- }
-`;
-
-const Register = styled.p`
- cursor: pointer;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 14px;
- color: #52B6FF;
- text-decoration-line: underline;
- text-align: center;
-`;
\ No newline at end of file
diff --git a/src/components/Logo.js b/src/components/Logo.js
deleted file mode 100644
index 0ce9a04..0000000
--- a/src/components/Logo.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import Image from '../images/logo.png';
-import styled from 'styled-components';
-
-export default function Logo() {
- return(
-
-
-
- )
-}
-
-const LogoImage = styled.div`
- display: flex;
- justify-content: center;
- margin-bottom: 10px;
- margin-top: 68px;
-
- img{
- width: 180px;
- height: 180px;
- }
-`;
\ No newline at end of file
diff --git a/src/components/Register/Register.js b/src/components/Register/Register.js
deleted file mode 100644
index 63e3a77..0000000
--- a/src/components/Register/Register.js
+++ /dev/null
@@ -1,129 +0,0 @@
-import { useState } from 'react';
-import styled from 'styled-components';
-import { Link, useHistory } from 'react-router-dom';
-import axios from 'axios';
-import Loader from "react-loader-spinner";
-import Logo from '../Logo'
-
-
-export default function Register(){
-
- const [email,setEmail] = useState ("");
- const [password, setPassword] = useState ("");
- const [name, setName] = useState ("");
- const [image, setImage] = useState ("");
- const [loading, setLoading] = useState(false);
- const body= {
- email,
- name,
- image,
- password
- }
-
- let history = useHistory();
-
- return(
- <>
-
-
-
- setEmail(e.target.value)}
- />
- setPassword(e.target.value)}
- />
- setName(e.target.value)}
- />
- setImage(e.target.value)}
- />
- signUp(body, setLoading)}>
- {loading === true? "": "Cadastrar"}
-
-
-
-
-
- Já tem uma conta? Faça login!
-
- >
- )
- function signUp(body, setLoading) {
- const request = axios.post("https://mock-api.bootcamp.respondeai.com.br/api/v2/trackit/auth/sign-up", body);
- setLoading(true);
-
- request.then(response => history.push("/"));
-
- request.catch(error => {
- alert("Erro! Preencha novamente os campos.")
- setLoading(false);
- })
- }
-}
-
-const Data = styled.div`
- display: flex;
- flex-direction: column;
- padding: 25px 36px;
-
- input{
- height: 45px;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 20px;
- color: #AFAFAF;
- border: 1px solid #D5D5D5;
- border-radius: 5px;
- margin-bottom: 6px;
- ::-webkit-input-placeholder {
- color: #DBDBDB;
- padding: 11px;
- }
- }
-
- div{
- cursor: pointer;
- height: 45px;
- font-size: 21px;
- font-family: 'Lexend Deca', sans-serif;
- color: #fff;
- background-color: #52B6FF;
- border-radius: 5px;
- display: flex;
- justify-content: center;
- align-items: center;
- }
-`;
-
-const Login = styled.p`
- cursor: pointer;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 14px;
- color: #52B6FF;
- text-decoration-line: underline;
- text-align: center;
- margin-bottom: 30px;
-`;
\ No newline at end of file
diff --git a/src/components/Today/Today.js b/src/components/Today/Today.js
deleted file mode 100644
index 1198214..0000000
--- a/src/components/Today/Today.js
+++ /dev/null
@@ -1,193 +0,0 @@
-import Header from '../Header'
-import styled from 'styled-components';
-import Footer from '../Footer';
-import dayjs from 'dayjs';
-import { CheckmarkOutline } from 'react-ionicons';
-import { useState, useEffect, useContext } from 'react';
-import axios from 'axios';
-import UserContext from '../../contexts/UserContexts';
-import ProgressContext from '../../contexts/ProgressContexts';
-
-export default function Today (){
- const now = dayjs().format('DD/MM/YYYY');
- const weekday = dayjs().day();
- const weekdayName = [
- {name: "Domingo", id: 0},
- {name: "Segunda", id: 1},
- {name: "Terça", id: 2},
- {name: "Quarta", id: 3},
- {name: "Quinta", id: 4},
- {name: "Sexta", id: 5},
- {name: "Sábado", id: 6}
- ];
- const found = weekdayName.find( e => e.id === weekday);
- const [items, setItems] = useState([]);
- const { user, setUser }= useContext(UserContext);
- const {progress, setProgress} = useContext(ProgressContext);
- const config = {
- headers: {
- "Authorization": `Bearer ${user.token}`
- }
- }
-
- useEffect(() =>{
- if(localStorage.getItem('user')){
- setUser(JSON.parse(localStorage.getItem('user')))
- }}, [])
-
- useEffect(() => {
- const request = axios.get("https://mock-api.bootcamp.respondeai.com.br/api/v2/trackit/habits/today", config);
-
- request.then(resposta => {
- setItems(resposta.data);
- });
-
- request.catch(error => alert("Erro! Tente novamente :/"))
- }, []);
-
- //Barra de progresso
- let done = 0;
- for(let i = 0; i < items.length; i++){
- if(items[i].done === true){
- done += 1;
- }
- }
-
- setProgress(Math.round(done*100/items.length))
- //Fim da barra de progresso
-
- return(
- <>
-
-
-
-
- {found.name}, {now}
-
-
- i.done ===true)}>
- {
- !items.find(i => i.done ===true)?
- "Nenhum hábito concluído ainda":
- `${progress}% dos hábitos concluídos`
- }
-
- {items.map((t, i) =>
-
-
- {t.name}
- Sequência atual:
- {t.currentSequence} dias
-
- Seu recorde:
- {t.highestSequence} dias
-
-
- addOrRemoveHabits(t.done, t.id, t)}
- >
-
-
-
- )}
-
-
- < Footer />
- >
- )
-
- function addOrRemoveHabits (done, id, item){
- if(done === false){
- const request = axios.post(`https://mock-api.bootcamp.respondeai.com.br/api/v2/trackit/habits/${id}/check`, {}, config);
-
- request.then(resposta =>
- setItems([...items.filter((i => i.id !== id)), {...item, done: true, currentSequence: item.currentSequence + 1}]))
-
- request.catch(error => alert(error))
- }
- else{
- const request = axios.post(`https://mock-api.bootcamp.respondeai.com.br/api/v2/trackit/habits/${id}/uncheck`, {}, config);
-
- request.then(resposta =>
- setItems([{...item, done: false, currentSequence: item.currentSequence -1},...items.filter((i => i.id !== id))]))
-
- request.catch(error => alert(error))
- }
- }
-}
-
-const Date = styled.div`
- margin: auto;
- margin-top: 100px;
- width: 90%;
- display: flex;
- justify-content: space-between;
- align-items: center;
-
- h2{
- font-family: 'Lexend Deca', sans-serif;
- font-size: 23px;
- color: #126BA5;
- }
-`;
-
-const Text = styled.p`
- margin: 20px auto;
- width: 90%;
- font-family: 'Lexend Deca', sans-serif;
- font-size: 18px;
- color: ${props => props.value? "#666": "#8FC549"};
-`;
-
-const Habits = styled.div`
- width: 90%;
- margin: auto;
- padding: 13px 13px 17px 15px;
- background-color: #fff;
- border-radius: 5px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 10px;
-`;
-
-const Checkmark = styled.div`
- width: 69px;
- height: 69px;
- display: flex;
- justify-content: center;
- align-items: center;
- background-color: ${props => props.state? "#8FC549": "#EBEBEB"};
- border: 1px solid #E7E7E7;
- border-radius: 5px;
-`;
-
-const Task = styled.div`
- font-family: 'Lexend Deca', sans-serif;
-
- h1{
- color: #666;
- margin-bottom: 7px;
- font-size: 20px;
- }
- span, p{
- font-size: 13px;
- margin-bottom: 5px;
- }
- p{
- color: #666;
- }
-`;
-
-const Div = styled.div`
- height: 110px;
-`;
-
-const Days = styled.span`
- color: ${props => props.state? "#8FC549": "#666"};
-`
\ No newline at end of file
diff --git a/src/contexts/ProgressContexts.js b/src/contexts/ProgressContexts.js
deleted file mode 100644
index 81a9955..0000000
--- a/src/contexts/ProgressContexts.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import { createContext } from 'react';
-
-const ProgressContext = createContext();
-
-export default ProgressContext;
\ No newline at end of file
diff --git a/src/contexts/UserContexts.js b/src/contexts/UserContexts.js
deleted file mode 100644
index 0421804..0000000
--- a/src/contexts/UserContexts.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import { createContext } from 'react';
-
-const UserContext = createContext();
-
-export default UserContext;
\ No newline at end of file
diff --git a/src/index.js b/src/index.js
deleted file mode 100644
index e2f748f..0000000
--- a/src/index.js
+++ /dev/null
@@ -1,5 +0,0 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
-import App from './components/App';
-
-ReactDOM.render(, document.querySelector(".root"));