Skip to content

Instantly share code, notes, and snippets.

@Klerith
Created November 27, 2023 17:59
Show Gist options
  • Save Klerith/0206389e37eaa6de6dc9c067270465cd to your computer and use it in GitHub Desktop.
Save Klerith/0206389e37eaa6de6dc9c067270465cd to your computer and use it in GitHub Desktop.
Formulario para actualizar un producto
"use client";
import { Product } from "@/interfaces";
interface Props {
product: Product;
}
const sizes = ["XS", "S", "M", "L", "XL", "XXL"];
export const ProductForm = ({ product }: Props) => {
return (
<form className="grid px-5 mb-16 grid-cols-1 sm:px-0 sm:grid-cols-2 gap-3">
{/* Textos */}
<div className="w-full">
<div className="flex flex-col mb-2">
<span>Título</span>
<input type="text" className="p-2 border rounded-md bg-gray-200" />
</div>
<div className="flex flex-col mb-2">
<span>Slug</span>
<input type="text" className="p-2 border rounded-md bg-gray-200" />
</div>
<div className="flex flex-col mb-2">
<span>Descripción</span>
<textarea
rows={5}
className="p-2 border rounded-md bg-gray-200"
></textarea>
</div>
<div className="flex flex-col mb-2">
<span>Price</span>
<input type="number" className="p-2 border rounded-md bg-gray-200" />
</div>
<div className="flex flex-col mb-2">
<span>Tags</span>
<input type="text" className="p-2 border rounded-md bg-gray-200" />
</div>
<div className="flex flex-col mb-2">
<span>Gender</span>
<select className="p-2 border rounded-md bg-gray-200">
<option value="">[Seleccione]</option>
<option value="men">Men</option>
<option value="women">Women</option>
<option value="kid">Kid</option>
<option value="unisex">Unisex</option>
</select>
</div>
<div className="flex flex-col mb-2">
<span>Categoria</span>
<select className="p-2 border rounded-md bg-gray-200">
<option value="">[Seleccione]</option>
</select>
</div>
<button className="btn-primary w-full">
Guardar
</button>
</div>
{/* Selector de tallas y fotos */}
<div className="w-full">
{/* As checkboxes */}
<div className="flex flex-col">
<span>Tallas</span>
<div className="flex flex-wrap">
{
sizes.map( size => (
// bg-blue-500 text-white <--- si está seleccionado
<div key={ size } className="flex items-center justify-center w-10 h-10 mr-2 border rounded-md">
<span>{ size }</span>
</div>
))
}
</div>
<div className="flex flex-col mb-2">
<span>Fotos</span>
<input
type="file"
multiple
className="p-2 border rounded-md bg-gray-200"
accept="image/png, image/jpeg"
/>
</div>
</div>
</div>
</form>
);
};
@sergiocolque
Copy link

gracias

@jjrh92
Copy link

jjrh92 commented Aug 2, 2024

Bonito curso y proyecto gracias Fernando.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment