Skip to content

Commit

Permalink
admin aÑadir producto front, me falta arreglar las imagenes y hacer e…
Browse files Browse the repository at this point in the history
…l back
  • Loading branch information
Adolfopgv committed May 21, 2024
1 parent 38091ac commit 5b12c54
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 19 deletions.
8 changes: 4 additions & 4 deletions backend/models/productModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ const productSchema = new Schema(
type: Number,
default: 0,
},
reviews: {
reviews: [{
userId: {
type: Schema.Types.ObjectId,
ref: "User",
},
review: [{
review: {
type: String,
trim: true,
}]
}
}
}]
},
{ toJSON: { getters: true }, timestamps: true }
);
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/NavbarLoggedIn.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function NavbarLoggedIn() {
<ul className="p-2 bg-accent rounded-t-none">
<li>
<Link to="/store" className="btn btn-ghost">
Todo
catálogo
</Link>
</li>
<li>
Expand Down Expand Up @@ -172,7 +172,7 @@ export default function NavbarLoggedIn() {
{/** Icono de busqueda (Queda mal en mobiles) */}

{/** Carrito de compra */}
<div className="mr-1 dropdown dropdown-end lg:hidden">
{user.role !== 1 && <div className="mr-1 dropdown dropdown-end lg:hidden">
<div
tabIndex={0}
role="button"
Expand Down Expand Up @@ -210,7 +210,7 @@ export default function NavbarLoggedIn() {
</div>
</div>
</div>
</div>
</div>}

{/**Avatar desplegable */}
<div className="mr-4 dropdown dropdown-end">
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/NavbarLoggedOut.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function NavbarLoggedOut() {
<ul className="p-2 bg-accent rounded-t-none">
<li>
<Link to="/store" className="btn btn-ghost">
Todo
Catálogo
</Link>
</li>
<li>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/TextBoxWithTextOnTop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ export default function TextBoxWithTextOnTop(props) {
return (
<div className="form-control w-full mt-4">
<label className="label">
<span className="label-text text-base-content">{props.text}</span>
<span className="label-text">{props.text}</span>
</label>
<label className="input input-bordered flex items-center gap-2 bg-primary">
<input className="w-[100%] text-black" {...props} />
<input className={`w-[100%] text-black ${props.classStyle}`} {...props} />
<div>{props.eye}</div>
</label>
</div>
Expand Down
164 changes: 157 additions & 7 deletions frontend/src/pages/admin/AdminProducts.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,171 @@
import { useContext } from "react";
import { UserContext } from "../../context/userContext";
import TextBoxWithTextOnTop from "../../components/TextBoxWithTextOnTop";
import Error from "../error/Error";

const products = [
{
id: 1,
name: "Earthen Bottle",
href: "#",
price: "$48",
imageSrc:
"https://tailwindui.com/img/ecommerce-images/category-page-04-image-card-01.jpg",
imageAlt:
"Tall slender porcelain bottle with natural clay textured body and cork stopper.",
},
{
id: 2,
name: "Nomad Tumbler",
href: "#",
price: "$35",
imageSrc:
"https://tailwindui.com/img/ecommerce-images/category-page-04-image-card-02.jpg",
imageAlt:
"Olive drab green insulated bottle with flared screw lid and flat top.",
},
{
id: 3,
name: "Focus Paper Refill",
href: "#",
price: "$89",
imageSrc:
"https://tailwindui.com/img/ecommerce-images/category-page-04-image-card-03.jpg",
imageAlt:
"Person using a pen to cross a task off a productivity paper card.",
},
{
id: 4,
name: "Machined Mechanical Pencil",
href: "#",
price: "$35",
imageSrc:
"https://tailwindui.com/img/ecommerce-images/category-page-04-image-card-04.jpg",
imageAlt:
"Hand holding black machined steel mechanical pencil with brass tip and top.",
},
{
id: 5,
name: "Machined Mechanical Pencil",
href: "#",
price: "$35",
imageSrc:
"https://tailwindui.com/img/ecommerce-images/category-page-04-image-card-04.jpg",
imageAlt:
"Hand holding black machined steel mechanical pencil with brass tip and top.",
},
// More products...
];

export default function AdminProducts() {
const { user } = useContext(UserContext);

return (
<>
{user && user.role === 1 && (
{user && user.role === 1 ? (
<>
<h1>Añadir un nuevo producto</h1>
<TextBoxWithTextOnTop
type="text"
text="Nombre del producto"
placeholder="Nombre de producto..."
/>
<div className="flex lg:flex-row max-lg:flex-col">
<div className="m-10 lg:w-2/4">
<h1 className="card-title">Añadir un nuevo producto</h1>
<form onSubmit="">
<TextBoxWithTextOnTop
type="text"
text="Nombre del producto"
placeholder="Nombre de producto..."
/>
<label className="form-control w-full mt-4">
<div className="label">
<span className="label-text">Descripción</span>
</div>
<textarea
className="textarea textarea-bordered h-24 gap-2 bg-primary text-black"
placeholder="Descripción del producto..."
></textarea>
</label>
<TextBoxWithTextOnTop
type="number"
text="Precio"
placeholder="Precio del producto..."
/>
<TextBoxWithTextOnTop
type="text"
text="Género"
placeholder="Género del producto..."
/>
<label className="form-control w-full mt-4">
<div className="label">
<span className="label-text">Selecciona una imagen</span>
</div>
<input
type="file"
className="file-input file-input-bordered file-input-secondary w-full max-w-xs"
/>
<img src="input" alt="img" />
</label>
<button
type="submit"
className="btn mt-4 mb-4 w-full btn-accent"
>
Añadir producto
</button>
</form>
</div>

<div className="divider lg:divider-horizontal" />

<div className="table-fixed m-10 overflow-auto">
<table className="text-left text-sm font-light text-surface">
<caption className="caption-top mb-2">
<span className="card-title"> Productos actuales</span>
</caption>
<thead className="border-b border-accent font-medium">
<tr>
<th scope="col" className="px-6 py-4">
#
</th>
<th scope="col" className="px-6 py-4">
Imagen
</th>
<th scope="col" className="px-6 py-4">
Nombre
</th>
<th scope="col" className="px-6 py-4">
Genero
</th>
<th scope="col" className="px-6 py-4">
Precio
</th>
</tr>
</thead>
<tbody>
{products.map((product) => (
<>
<tr className="border-b border-base-300 transition duration-300 ease-in-out hover:badge-ghost">
<td className=" px-6 py-4 font-medium">{product.id}</td>
<td className="px-6 py-4">
<div className="relative">
<img src={product.imageSrc} className=""/>
</div>
</td>
<td className="whitespace-nowrap px-6 py-4">
{product.name}
</td>
<td className="whitespace-nowrap px-6 py-4">
{product.imageAlt}
</td>
<td className="whitespace-nowrap px-6 py-4">
{product.price}
</td>
</tr>
</>
))}
</tbody>
</table>
</div>
</div>
</>
) : (
<Error />
)}
</>
);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/pages/auth/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function Login() {
if (data.error) {
toast.error(data.error);
} else if (data.role !== 1 && data.verified) {
toast.success(`Bienvenido ${email}!`);
toast.success(`Bienvenido ${data.username}!`);
setUser(data.user);
setData({});
navigate("/");
Expand All @@ -83,7 +83,7 @@ export default function Login() {
{!user ? (
<div className="min-h-screen bg-primary flex items-center">
<div className="card mx-auto w-full max-w-5xl shadow-xl">
<div className="grid md:grid-cols-2 grid-cols-1 bg-base-100 rounded-xl">
<div className="grid md:grid-cols-2 grid-cols-1 bg-base-100 rounded-xl">
<div className="py-24 px-10">
<h2 className="text-2xl font-semibold mb-2 text-center">
Iniciar Sesión
Expand Down
132 changes: 132 additions & 0 deletions
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
commit 38091ac9d183f6b37a988634f20517ff7525b34c (HEAD -> dev, origin/dev)
Author: Adolfopgv <[email protected]>
Date: Mon May 20 19:41:56 2024 +0200

Bug de inicio de sesión arreglado, bug de textbox con texto blanco arreglado, añadido la variable verificado en el login para que no entre en la sesión sin el mail verificado

commit 45409f7addcad05183620e601a31929a8a02195c
Author: Adolfopgv <[email protected]>
Date: Mon May 20 01:22:11 2024 +0200

products schema, admin auth, admin pages

commit e3a33e87260c2420717afa5aada466329cfc5e1f
Merge: c05df27 d272f8d
Author: Adolfopgv <[email protected]>
Date: Sat May 18 22:06:07 2024 +0200

Merge branch 'dev' of https://github.com/Adolfopgv/Laxart into dev

commit c05df27797d9c11c45bb3eed9c97e450a85e7f10
Author: Adolfopgv <[email protected]>
Date: Sat May 18 22:04:19 2024 +0200

Admin auth y dashboard, verificacion email 100% hecho

commit d272f8dfe6b62a9335884b0c4bffca795ec524a1
Author: Adolfo <[email protected]>
Date: Fri May 17 08:38:03 2024 +0200

Delete CNAME

commit 8a4e408ac33544e5eb6c65b648253b777ebb2b13
Author: Adolfo <[email protected]>
Date: Fri May 17 08:37:52 2024 +0200

Update CNAME

commit c436469d0bfdfa3b16b545f67db0292a0791cbf9
Author: Adolfo <[email protected]>
Date: Fri May 17 08:37:17 2024 +0200

Create CNAME

commit 71ee5549f20e87bad28477f41b7b51d5e111f9cf
Author: Adolfo <[email protected]>
Date: Fri May 17 08:37:04 2024 +0200

Delete CNAME

commit 05caf81a70108adbff376b671879cd9264d0506d
Author: Adolfo <[email protected]>
Date: Fri May 17 08:36:41 2024 +0200

Create CNAME

commit dfd453149375e28719603ff27b31e6ed7fcb1792
Author: Adolfo <[email protected]>
Date: Fri May 17 08:36:30 2024 +0200

Delete CNAME

commit 6381a35a306add36daba38d5fe4949dd7f3e5062
Author: Adolfo <[email protected]>
Date: Fri May 17 08:36:04 2024 +0200

Create CNAME

commit df4dd599407658da5465fb1ebb20a43135f7d43e
Author: Adolfopgv <[email protected]>
Date: Fri May 17 01:36:07 2024 +0200

Mejorado todo el register, añadido verificacion por email y mas estilos

commit 4e3f3aad1707cc9a70289080245858a4b0c57323
Author: Adolfopgv <[email protected]>
Date: Thu May 16 12:32:28 2024 +0200

banner arreglado y textbox width arreglado

commit 56c51d9b3373b05eef4d2bc4ca528a6df7b3342d
Author: Adolfopgv <[email protected]>
Date: Thu May 16 00:51:28 2024 +0200

diseño estructurado con diferentes colores para la app que utilizare a lo largo del desarrollo

commit 41b72aa96cb547de55a8fded5b6c3442593ef17c
Author: Adolfopgv <[email protected]>
Date: Tue May 14 18:37:32 2024 +0200

Navbar optimizado

commit 2bb77b2276843a468d1d9028c0d3bd6f5b612329
Author: Adolfopgv <[email protected]>
Date: Mon May 13 09:01:25 2024 +0200

arreglado algo en register (login no funciona en portatil)

commit d971effb57e58a92da4c6af8ba548d4694c172a7
Author: Adolfopgv <[email protected]>
Date: Mon May 13 00:09:16 2024 +0200

olvidado back

commit e6eeb7ae79cf324936d352dc6251579e7f772bc3
Author: Adolfopgv <[email protected]>
Date: Mon May 13 00:08:44 2024 +0200

UI login y register terminado, navbar responsive y theme añadido

commit e64bde50724cdeb25f1d8462f5507447a44329a9
Author: Adolfopgv <[email protected]>
Date: Sun May 12 03:58:03 2024 +0200

Cookies gestionadas y empezado google oauth

commit bb678fc23062af82f193a02707221be08aeee350
Author: Adolfopgv <[email protected]>
Date: Sat May 11 03:01:40 2024 +0200

back autenticacion terminada (mirar tema de contraseña en front)

commit 2bd6f49d77859e021a3db947cd4738a44ac60f5a
Author: Adolfopgv <[email protected]>
Date: Fri May 10 15:01:48 2024 +0200

cambios 15:00 10/05

commit 6e91b70e26b482dcaf202d9176b7462d3c34de67 (origin/main, origin/HEAD, main)
Author: Adolfopgv <[email protected]>
Date: Fri May 10 09:57:46 2024 +0200

primer commit arreglando el repo

0 comments on commit 5b12c54

Please sign in to comment.