Skip to content

Commit

Permalink
Merge pull request #12 from Edwardb11/feat/addPackage
Browse files Browse the repository at this point in the history
Add packages
  • Loading branch information
Edwardb11 authored Aug 8, 2022
2 parents 7ef766e + 2bdbce7 commit 6431fd4
Show file tree
Hide file tree
Showing 10 changed files with 446 additions and 53 deletions.
7 changes: 6 additions & 1 deletion src/components/Footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Footer = () => {
</Link>
</span>
<span className="my-2">
<Link className="text-blue-700 text-md hover:text-blue-500">
<Link to="/package" className="text-blue-700 text-md hover:text-blue-500">
Agregar
</Link>
</span>
Expand Down Expand Up @@ -47,6 +47,11 @@ const Footer = () => {
¿Quiénes somos?
</Link>
</span>
<span className="my-2">
<Link to="/NoFound" className="text-blue-700 text-md hover:text-blue-500">
404
</Link>
</span>

</div>
</div>
Expand Down
38 changes: 14 additions & 24 deletions src/components/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import { Fragment, useContext, useEffect, useState } from "react";
import { Disclosure, Menu, Transition } from "@headlessui/react";
import { MenuIcon, XIcon } from "@heroicons/react/outline";
import { Link } from "react-router-dom";
import { Link, NavLink } from "react-router-dom";
import User from "../context/userContext";
import setAuthorizationToken from "../utils/setAuthorizationToken";

const navigation = [
{ name: "Inicio", href: "/", current: true },
{ name: "Seguimiento", href: "#", current: false },
{ name: "Agregar", href: "/NoFound", current: false },
{ name: "Agregar", href: "/package", current: false },
];

function classNames(...classes) {
Expand Down Expand Up @@ -62,18 +62,14 @@ export default function NavBar() {
<div className="hidden sm:block sm:ml-6">
<div className="flex space-x-4">
{navigation.map((item) => (
<Link
<NavLink
// activeClassName="bg-gray-900 text-white"
className="text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium"
aria-current="page"
to={item.href}
className={classNames(
item.current
? "bg-gray-900 text-white"
: "text-gray-300 hover:bg-gray-700 hover:text-white",
"px-3 py-2 rounded-md text-sm font-medium"
)}
aria-current={item.current ? "page" : undefined}
>
{item.name}
</Link>
</NavLink>
))}
</div>
</div>
Expand Down Expand Up @@ -123,7 +119,7 @@ export default function NavBar() {
<Menu.Item>
{({ active }) => (
<Link
to="#"
to="/"
className={classNames(
active ? "bg-gray-100" : "",
"block px-4 py-2 text-sm text-gray-700"
Expand Down Expand Up @@ -156,20 +152,14 @@ export default function NavBar() {
<Disclosure.Panel className="sm:hidden">
<div className="px-2 pt-2 pb-3 space-y-1">
{navigation.map((item) => (
<Disclosure.Button
key={item.name}
as="a"
href={item.href}
className={classNames(
item.current
? "bg-gray-900 text-white"
: "text-gray-300 hover:bg-gray-700 hover:text-white",
"block px-3 py-2 rounded-md text-base font-medium"
)}
aria-current={item.current ? "page" : undefined}
<NavLink
// activeClassName="bg-gray-900 text-white"
className="text-gray-300 hover:bg-gray-700 hover:text-white block px-3 py-2 rounded-md text-base font-medium"
aria-current="page"
to={item.href}
>
{item.name}
</Disclosure.Button>
</NavLink>
))}
</div>
</Disclosure.Panel>
Expand Down
150 changes: 150 additions & 0 deletions src/components/PackageForms.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
import React, { useState } from "react";
import UserFinalForms from "./UserFinalForms";

function PackageForms() {
const [viewForm, setViewForm] = useState(false);
const [namePackage, setNamePackage] = useState("");
const [amount, setAmount] = useState("");
const [weight, setWeight] = useState("");
const [type, setType] = useState("");
const [userFinal, setUserFinal] = useState("");
const handleAdd = () => {
setViewForm(!viewForm);
};
return (
<>
<div className="max-w-2xl mx-auto bg-white p-16">
<form>
<div className="grid gap-6 mb-6 lg:grid-cols-2">
<div>
<label
htmlFor="nombre"
className="block mb-2 text-sm font-semibold px-1 text-gray-900 dark:text-gray-900"
>
Nombre
</label>
<input
type="text"
id="nombre"
value={namePackage}
onChange={(e) => setNamePackage(e.target.value)}
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="Ej:Computadora"
required
/>
</div>
<div>
<label
htmlFor="tipo"
className="block mb-2 text-sm font-semibold px-1 text-gray-900 dark:text-gray-900"
>
Tipo de paquete
</label>
<select
id="tipo"
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:focus:ring-blue-500 dark:focus:border-blue-500"
required
onChange={(e) => setType(e.target.value)}
>
<option disabled>Selecione</option>
<option value="1" selected>
Alimentación
</option>
<option value="2">Hogar y electrodoméstico</option>
<option value="3">Bebidas</option>
<option value="4">Cuidado Personal y Belleza</option>
<option value="5">Limpieza</option>
</select>
</div>
<div>
<label
htmlFor="cantidad"
className="block mb-2 text-sm font-semibold px-1 text-gray-900 dark:text-gray-900"
>
Cantidad (LB)
</label>
<input
type="number"
id="cantidad"
value={amount}
onChange={(e) => setAmount(e.target.value)}
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="Ej:10"
required
/>
</div>
<div>
<label
htmlFor="peso"
className="block mb-2 text-sm font-semibold px-1 text-gray-900 dark:text-gray-900"
>
Peso (LB)
</label>
<input
type="number"
name="peso"
value={weight}
onChange={(e) => setWeight(e.target.value)}
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:focus:ring-blue-500 dark:focus:border-blue-500"
placeholder="Ej:10"
required
/>
</div>
</div>

<div>
<p className="text-sm text-justify mb-2 mt-6">
Registra un usuario final.
</p>

<button
type="button"
onClick={handleAdd}
className="text-white mb-6 bg-green-700 hover:bg-green-800 focus:ring-4 focus:outline-none focus:ring-green-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800"
>
{!viewForm ? "Agregar usuario" : "Cerrar"}
</button>
</div>

{!viewForm && (
<div>
<div>
<p className="text-sm text-justify mb-2">
¿Habías agregado a alguien anteriormente? Seleccionalo{" "}
</p>
<label
htmlFor="user_final"
className="block mb-2 text-sm font-semibold px-1 text-gray-900 dark:text-gray-900"
>
Usuario final
</label>
<select
id="tipo"
className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:focus:ring-blue-500 dark:focus:border-blue-500"
required
onChange={(e) => setUserFinal(e.target.value)}
>
<option disabled>Selecione</option>
<option value="1" selected>
No tienes personas agregadas
</option>
<option value="2">Una persona</option>
</select>
</div>

<button
type="submit"
className="text-white mt-3 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
Agregar paquete
</button>
</div>
)}
</form>
{viewForm && <UserFinalForms />}
</div>
</>
);
}

export default PackageForms;
Loading

0 comments on commit 6431fd4

Please sign in to comment.