This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useContext } from 'react'; | |
import { useHistory, useLocation } from 'react-router-dom'; | |
import StoreContext from 'components/Store/Context'; | |
import UIButton from 'components/UI/Button/Button'; | |
import './Login.css'; | |
function initialState() { | |
return { user: '', password: '' }; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useContext } from 'react'; | |
import { Route, Redirect } from 'react-router-dom'; | |
import StoreContext from 'components/Store/Context'; | |
const RoutesPrivate = ({ component: Component, ...rest}) => { | |
const { token } = useContext(StoreContext); | |
return ( | |
<Route |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"promotions": [ | |
{ | |
"id": 1, | |
"title": "Kit Notebook Acer Aspire 3 + Mochila Green, A315-41-R790, AMD Ryzen 3 2200U Dual Core", | |
"price": 1799, | |
"imageUrl": "https://cdn.gatry.com/gatry-static/promocao/imagem_url/2631517face1861bc4f46ae154d387de.png" | |
}, | |
{ | |
"id": 2, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
import axios from 'axios'; | |
const api = axios.create({ | |
baseURL: '/api' | |
}); | |
const initialState = { pending: true, error: null, data: null }; | |
export default function useLazyRest(options = {}) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const jsonServer = require('json-server'); | |
const server = jsonServer.create(); | |
const router = jsonServer.router('db.json'); | |
const middlewares = jsonServer.defaults(); | |
server.use(middlewares); | |
server.use(jsonServer.bodyParser); | |
router.render = (req, res) => { | |
if (req.method === 'GET') { | |
const paths = req._parsedUrl.pathname.split('/').filter(path => Boolean(path)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ajaxCalls = async () => { | |
const r1 = await someajaxPromiseFn1(); | |
const r2 = await someajaxPromiseFn2(r1); | |
const r3 = await someajaxPromiseFn3(r2); | |
setState(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"id": 1, | |
"title": "Kit Notebook Acer Aspire 3 + Mochila Green, A315-41-R790, AMD Ryzen 3 2200U Dual Core", | |
"price": 1799, | |
"imageUrl": "https://cdn.gatry.com/gatry-static/promocao/imagem_url/2631517face1861bc4f46ae154d387de.png", | |
"url": "https://www.amazon.com.br/Notebook-Acer-Mochila-A315-41-R790-Mem%C3%B3ria/dp/B07YDWLV7S/ref=as_li_ss_tl?ie=UTF8&linkCode=sl1&tag=gatry0b-20&linkId=e4a1146599e36741a720a6a952cbc328&language=pt_BR", | |
"comments": [ | |
{ | |
"id": 1, | |
"comment": "TELA HD" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//callback | |
function listarProdutos(data) { | |
console.log(data.produtos); | |
} | |
//callback | |
function removerProduto() { | |
console.log('remover produto da tela'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const credentials = { | |
}; | |
function setCredentials(user) { | |
credentials.user = user; | |
} | |
//to actually open the window.. | |
var win = window.open("window.html"); | |
win.onload = function() { win.callback = setCredentials; }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import UserForm from '../../components/User/Form/Form'; | |
const ScreensUserForm = ({ match: { params } }) => ( | |
<div> | |
<h1> | |
{`${!params.id ? 'Create' : 'Update'}`} User | |
</h1> | |
<UserForm id={params.id} /> | |
</div> |
NewerOlder