Skip to content

Commit

Permalink
Quitar warning y comentarios
Browse files Browse the repository at this point in the history
  • Loading branch information
UO271728 committed May 3, 2022
1 parent a999ed6 commit 53f9fd4
Show file tree
Hide file tree
Showing 14 changed files with 7 additions and 100 deletions.
29 changes: 0 additions & 29 deletions restapi/routes/juguete.router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Console } from "console";
import express, { Request, response, Response } from "express"
import cloudinary from 'cloudinary';
import { ObjectId } from "mongodb";

export const jugueteRouter = express.Router()
const Juguete = require("../models/Juguete");
Expand Down Expand Up @@ -37,9 +35,7 @@ jugueteRouter.get("/withStock", async (req: Request, res: Response) => {
jugueteRouter.get("/:nombre", async (req: Request, res: Response) => {
try {
let filter = { nombre: req.params.nombre }
//console.log(filter);
let juguete = await Juguete.findOne(filter);
//console.log(juguete);
if (juguete) {
res.json(juguete);
}
Expand Down Expand Up @@ -83,7 +79,6 @@ async function borrarImagen(imagen: String) {
*/
jugueteRouter.post("/", async (req: Request, res: Response) => {
try {
console.log("NUEVO JUGUETE");
let nuevoJuguete = {
nombre: req.body.nombre,
descripcion: req.body.descripcion,
Expand Down Expand Up @@ -136,38 +131,14 @@ jugueteRouter.post("/addStock/:nombre", async (req: Request, res: Response) => {
try {
const filter = { nombre: req.params.nombre }
var juguete = await Juguete.findOne(filter);
//console.log(juguete.stock)
//console.log(req.body.stock)
const number: Number = juguete.stock + req.body.stock
const stock = { stock: number }
//console.log(stock)
var jugueteActualizado = await Juguete.findOneAndUpdate(filter, stock, { new: true })
res.send("Stock del juguete añadido correctamente");

} catch (error) {
res.status(500).send("Error al añadir stock al juguete")
}
});
/*
jugueteRouter.post("/subtock/:nombre", async (req:Request,res:Response) => {
try{
const filter = {
nombre: req.params.nombre,
}
var juguete = await JugueteRepository.findJuguete(filter);

const stock = {stock: juguete.stock - req.body.stock}
var jugueteActualizado = await JugueteRepository.updateJuguete(filter,stock);
if(jugueteActualizado){
res.send("Stock del juguete restado correctamente");
} else{
res.status(500).send("No se pudo restar stock al producto")
}
}catch (error){
res.status(500).send("Error al restar stock al juguete")
}
});
*/
export default jugueteRouter;
15 changes: 1 addition & 14 deletions restapi/tests/juguete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ beforeAll(async () => {

cloudinary.configTest();
gestorBd.connectTest();

await prepararBd();

server = app.listen(port, ():void => {
Expand Down Expand Up @@ -75,20 +76,6 @@ describe('juguete ', () => {
const response:Response = await request(app).post('/juguete').send({nombre:name,descripcion:description,precio:price,imagen:imag,categoria:category,stock:stock})
expect(response.statusCode).toBe(200);
expect(response.text).toEqual("Añadido nuevo juguete");

const next:Response = await request(app).get('/juguete/'+name);
expect(next.statusCode).toBe(200);
expect(next.body).toEqual({
id : next.body.id,
nombre: name,
descripcion: description,
precio: price,
imagen: next.body.imagen,
categoria: category,
cantidad: 0,
stock:stock
})

});

it("No se puede añadir un juguete que ya existe", async () => {
Expand Down
4 changes: 1 addition & 3 deletions webapp/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QueryClient, QueryClientProvider, useQuery } from 'react-query'
import {useQuery } from 'react-query'


import { useEffect, useState } from "react"
Expand All @@ -12,7 +12,6 @@ import Navbar from './componentes/Navbar/Navbar';
import { Juguete } from './shared/sharedJuguete';
import Footer from './componentes/Footer/Footer';
import Drawer from '@material-ui/core/Drawer';
import LinearProgess from '@material-ui/core/LinearProgress';
import Grid from '@material-ui/core/Grid';
import AddShoppingCartIcon from '@material-ui/icons/AddShoppingCart';
import Badge from '@material-ui/core/Badge';
Expand Down Expand Up @@ -65,7 +64,6 @@ export async function getJuguetes(): Promise<Juguete[]> {
en la BD y exportando para poder usarlo desde fuera*/
//--------------------------------------------------------------------------------------------------------

const queryClient = new QueryClient()
const App = () => {

const [cartOpen, setCartOpen] = useState(false);
Expand Down
3 changes: 0 additions & 3 deletions webapp/src/Cart/Cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { useAuth0 } from '@auth0/auth0-react';
import {Wrapper} from './Cart.styles';
import { Typography } from "@material-ui/core";

//Types
import { CartItemType } from '../App';

import {Juguete} from '../shared/sharedJuguete';
import LoginButtonCart from '../componentes/Login/LoginButtonCart';

Expand Down
8 changes: 1 addition & 7 deletions webapp/src/CartItem/CartItem.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import Button from '@material-ui/core/Button';

//types
import {CartItemType} from '../App';
import Item from '../Item/Item';
import {Juguete} from '../shared/sharedJuguete';


//Styles
import {Wrapper} from './CartItem.styles';

/*type Props = {
item: CartItemType;
addToCart: (clickedItem: CartItemType) => void;
removeFromCart: (id:number) => void;
}*/

type Props = {
item: Juguete;
Expand Down
8 changes: 0 additions & 8 deletions webapp/src/Item/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
import Button from '@material-ui/core/Button';
//Types
//import { CartItemType } from '../App';
//Styles
import { Wrapper } from './Item.styles';

import { Juguete } from '../shared/sharedJuguete';


import { BrowserRouter, useNavigate } from "react-router-dom";
import getRoleUsuario from "../componentes/Login/LoginButton"
import { Router } from 'express';

/*type Props = {
item: CartItemType;
handleAddToCart: (clickedItem: CartItemType) => void;
}*/
type Props = {
item: Juguete;
handleAddToCart: (clickedItem: Juguete) => void;
Expand Down
6 changes: 1 addition & 5 deletions webapp/src/PayForm/Delivery.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import * as React from "react";
import CartItem from '../CartItem/CartItem';
import { useAuth0 } from '@auth0/auth0-react';
import Button from "@mui/material/Button";
import { Typography } from "@material-ui/core";
import Card from '@mui/material/Card';
import CardActions from '@mui/material/CardActions';
import CardContent from '@mui/material/CardContent';
import CardMedia from '@mui/material/CardMedia';
import Paper from "@mui/material/Paper";
//Types
import { CartItemType } from '../App';

//Types
import {Juguete} from '../shared/sharedJuguete';

type Props = {
Expand Down
5 changes: 0 additions & 5 deletions webapp/src/PayForm/FinalizedOrder.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import * as React from "react";
import CartItem from '../CartItem/CartItem';
import { useAuth0 } from '@auth0/auth0-react';
//Types
import { CartItemType } from '../App';
import {Juguete} from '../shared/sharedJuguete';
import { Typography } from "@material-ui/core";

export default function FinalizedOrder(props: any): JSX.Element {
Expand Down
5 changes: 2 additions & 3 deletions webapp/src/PayForm/ProcesoPago.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ const ProcesoPago: React.FC<Props> = ({ cartItems }) => {
};

const siguientePasoSiPodCalcularEnvio = async () => {
if (localStorage.getItem("direccion") == null || localStorage.getItem("direccion") == "") {
if (localStorage.getItem("direccion") == null || localStorage.getItem("direccion") === "") {
toast.warn("Por favor, inicie sesión con su POD para que podamos obtener su dirección", { position: toast.POSITION.TOP_CENTER })
} else {
let variable = await getGastosEnvio();
if (gastosEnvio == 0.00 || localStorage.getItem("direccion") == "null") {
if (gastosEnvio === 0.00 || localStorage.getItem("direccion") === "null") {
toast.error("Su dirección no fue encontrada, lo sentimos. Para solucionar el problema " +
"modifique la dirección de su POD", { position: toast.POSITION.TOP_CENTER })
} else {
Expand All @@ -112,7 +112,6 @@ const ProcesoPago: React.FC<Props> = ({ cartItems }) => {
const getPaso = (stepIndex: number) => {
switch (stepIndex) {
case 0:
condPedido = true;
return (
<Shipping
cartItems={cartItems}
Expand Down
4 changes: 0 additions & 4 deletions webapp/src/PayForm/Review.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import * as React from "react";
import CartItem from '../CartItem/CartItem';
import { useAuth0 } from '@auth0/auth0-react';
import Button from "@mui/material/Button";
import { Typography } from "@material-ui/core";
import Card from '@mui/material/Card';
import CardActions from '@mui/material/CardActions';
import CardContent from '@mui/material/CardContent';
import CardMedia from '@mui/material/CardMedia';
import Paper from "@mui/material/Paper";
import Grid from '@material-ui/core/Grid';

//Types
import { CartItemType } from '../App';

import {Juguete} from '../shared/sharedJuguete';
import SummaryItem from "./SummaryItem";
Expand Down
6 changes: 1 addition & 5 deletions webapp/src/PayForm/SummaryItem.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import Button from '@material-ui/core/Button';
//types
import {CartItemType} from '../App';
import Item from '../Item/Item';
import {Juguete} from '../shared/sharedJuguete';
import Paper from "@mui/material/Paper";
//Styles
import {Wrapper} from '../CartItem/CartItem.styles';
import { Box} from '@material-ui/core';


/*type Props = {
item: CartItemType;
Expand Down
5 changes: 0 additions & 5 deletions webapp/src/componentes/Pedidos/PedidoItem.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import Button from '@material-ui/core/Button';
//types
import { CartItemType } from '../../App';
import Item from '../../Item/Item';
import { Juguete } from '../../shared/sharedJuguete';
import Paper from "@mui/material/Paper";
//Styles
import { Wrapper } from '../../CartItem/CartItem.styles';
import { Box } from '@material-ui/core';
import './pedidos.css';

/*type Props = {
Expand Down
5 changes: 0 additions & 5 deletions webapp/src/componentes/loginSOLID/LoginForm.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@

import { useState } from "react";
import { LoginButton, useSession } from "@inrupt/solid-ui-react";
import { handleIncomingRedirect, onSessionRestore } from "@inrupt/solid-client-authn-browser";
import { Autocomplete, Button, Container, TextField } from "@mui/material";
import { Wrapper} from '../../App.styles';
import { useEffect } from 'react';
import {CombinedDataProvider, LogoutButton, Text } from "@inrupt/solid-ui-react";
import { Card, CardContent, Typography } from "@material-ui/core";
import {
getSolidDataset,
getThing,
getStringNoLocale,
Thing,
} from "@inrupt/solid-client";
import { FOAF, VCARD } from "@inrupt/lit-generated-vocab-common";
import { Grid } from "@mui/material";
import { useNavigate } from "react-router-dom";

export default function LoginForm() {

Expand Down
4 changes: 0 additions & 4 deletions webapp/src/componentes/loginSOLID/LogoutForm.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
import Home from '../../paginas/Home';
import {useSession } from "@inrupt/solid-ui-react";
import { LocalStorageCache } from "@auth0/auth0-react";

const LogoutForm = () => {

Expand Down

0 comments on commit 53f9fd4

Please sign in to comment.