Download src/components/admin/ServicoForm.jsx from guisousa/BaseAdmin: direct link, hf CLI and curl.
- Browser
- Download file 3.75 kB
-
https://huggingface.co/spaces/guisousa/BaseAdmin/resolve/main/src/components/admin/ServicoForm.jsx
- Command line
-
hf download hf://spaces/guisousa/BaseAdmin/src/components/admin/ServicoForm.jsx
-
curl -L -o ServicoForm.jsx https://huggingface.co/spaces/guisousa/BaseAdmin/resolve/main/src/components/admin/ServicoForm.jsx
3.75 kB
| import React, { useState } from "react"; | |
| import { motion } from "framer-motion"; | |
| import { Card, CardContent, CardHeader, CardTitle, CardFooter } from "@/components/ui/card"; | |
| import { Button } from "@/components/ui/button"; | |
| import { Input } from "@/components/ui/input"; | |
| import { Label } from "@/components/ui/label"; | |
| import { Textarea } from "@/components/ui/textarea"; | |
| import { Checkbox } from "@/components/ui/checkbox"; | |
| export default function ServicoForm({ servico, onSubmit, onCancel, isLoading }) { | |
| const [formData, setFormData] = useState(servico || { | |
| nome: "", | |
| descricao: "", | |
| preco: "", | |
| duracao: "", | |
| ativo: true, | |
| }); | |
| const handleSubmit = (e) => { | |
| e.preventDefault(); | |
| onSubmit({ | |
| ...formData, | |
| preco: parseFloat(formData.preco), | |
| duracao: parseInt(formData.duracao), | |
| }); | |
| }; | |
| return ( | |
| <motion.div | |
| initial={{ opacity: 0, y: -20 }} | |
| animate={{ opacity: 1, y: 0 }} | |
| exit={{ opacity: 0, y: -20 }} | |
| > | |
| <Card className="mb-8 border-2 border-black"> | |
| <CardHeader className="bg-black text-white"> | |
| <CardTitle>{servico ? "Editar Serviço" : "Novo Serviço"}</CardTitle> | |
| </CardHeader> | |
| <form onSubmit={handleSubmit}> | |
| <CardContent className="p-6 space-y-4"> | |
| <div className="grid md:grid-cols-2 gap-4"> | |
| <div className="space-y-2"> | |
| <Label>Nome do Serviço *</Label> | |
| <Input | |
| value={formData.nome} | |
| onChange={(e) => setFormData({ ...formData, nome: e.target.value })} | |
| placeholder="Ex: Corte masculino" | |
| required | |
| /> | |
| </div> | |
| <div className="space-y-2"> | |
| <Label>Preço (R$) *</Label> | |
| <Input | |
| type="number" | |
| step="0.01" | |
| value={formData.preco} | |
| onChange={(e) => setFormData({ ...formData, preco: e.target.value })} | |
| placeholder="0.00" | |
| required | |
| /> | |
| </div> | |
| </div> | |
| <div className="space-y-2"> | |
| <Label>Duração (minutos) *</Label> | |
| <Input | |
| type="number" | |
| value={formData.duracao} | |
| onChange={(e) => setFormData({ ...formData, duracao: e.target.value })} | |
| placeholder="Ex: 30" | |
| required | |
| /> | |
| </div> | |
| <div className="space-y-2"> | |
| <Label>Descrição</Label> | |
| <Textarea | |
| value={formData.descricao} | |
| onChange={(e) => setFormData({ ...formData, descricao: e.target.value })} | |
| rows={3} | |
| placeholder="Descreva o serviço..." | |
| /> | |
| </div> | |
| <div className="flex items-center space-x-2"> | |
| <Checkbox | |
| id="ativo" | |
| checked={formData.ativo} | |
| onCheckedChange={(checked) => setFormData({ ...formData, ativo: checked })} | |
| /> | |
| <label htmlFor="ativo" className="text-sm cursor-pointer"> | |
| Serviço ativo (visível para clientes) | |
| </label> | |
| </div> | |
| </CardContent> | |
| <CardFooter className="flex justify-end gap-3 border-t p-6"> | |
| <Button type="button" variant="outline" onClick={onCancel}> | |
| Cancelar | |
| </Button> | |
| <Button type="submit" className="bg-black hover:bg-gray-800 text-white" disabled={isLoading}> | |
| {isLoading ? "Salvando..." : "Salvar"} | |
| </Button> | |
| </CardFooter> | |
| </form> | |
| </Card> | |
| </motion.div> | |
| ); | |
| } |