From 599ff6c72ae17549b43208ccc28ced8765b8702e Mon Sep 17 00:00:00 2001 From: uubulb Date: Fri, 15 Nov 2024 18:11:58 +0800 Subject: [PATCH] init service card --- package-lock.json | 37 ++++++++++ package.json | 1 + src/components/ui/dialog.tsx | 120 +++++++++++++++++++++++++++++++++ src/components/xui/service.tsx | 108 +++++++++++++++++++++++++++++ src/routes/service.tsx | 8 +-- 5 files changed, 269 insertions(+), 5 deletions(-) create mode 100644 src/components/ui/dialog.tsx create mode 100644 src/components/xui/service.tsx diff --git a/package-lock.json b/package-lock.json index 82203c0..3e9659b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "@hookform/resolvers": "^3.9.1", "@radix-ui/react-avatar": "^1.1.1", "@radix-ui/react-checkbox": "^1.1.2", + "@radix-ui/react-dialog": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.1.2", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-navigation-menu": "^1.2.1", @@ -1259,6 +1260,42 @@ } } }, + "node_modules/@radix-ui/react-dialog": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@radix-ui/react-dialog/-/react-dialog-1.1.2.tgz", + "integrity": "sha512-Yj4dZtqa2o+kG61fzB0H2qUvmwBA2oyQroGLyNtBj1beo1khoQ3q1a2AO8rrQYjd8256CO9+N8L9tvsS+bnIyA==", + "license": "MIT", + "dependencies": { + "@radix-ui/primitive": "1.1.0", + "@radix-ui/react-compose-refs": "1.1.0", + "@radix-ui/react-context": "1.1.1", + "@radix-ui/react-dismissable-layer": "1.1.1", + "@radix-ui/react-focus-guards": "1.1.1", + "@radix-ui/react-focus-scope": "1.1.0", + "@radix-ui/react-id": "1.1.0", + "@radix-ui/react-portal": "1.1.2", + "@radix-ui/react-presence": "1.1.1", + "@radix-ui/react-primitive": "2.0.0", + "@radix-ui/react-slot": "1.1.0", + "@radix-ui/react-use-controllable-state": "1.1.0", + "aria-hidden": "^1.1.1", + "react-remove-scroll": "2.6.0" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-direction": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@radix-ui/react-direction/-/react-direction-1.1.0.tgz", diff --git a/package.json b/package.json index 03f2228..1b5dfd5 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@hookform/resolvers": "^3.9.1", "@radix-ui/react-avatar": "^1.1.1", "@radix-ui/react-checkbox": "^1.1.2", + "@radix-ui/react-dialog": "^1.1.2", "@radix-ui/react-dropdown-menu": "^2.1.2", "@radix-ui/react-label": "^2.1.0", "@radix-ui/react-navigation-menu": "^1.2.1", diff --git a/src/components/ui/dialog.tsx b/src/components/ui/dialog.tsx new file mode 100644 index 0000000..c23630e --- /dev/null +++ b/src/components/ui/dialog.tsx @@ -0,0 +1,120 @@ +import * as React from "react" +import * as DialogPrimitive from "@radix-ui/react-dialog" +import { X } from "lucide-react" + +import { cn } from "@/lib/utils" + +const Dialog = DialogPrimitive.Root + +const DialogTrigger = DialogPrimitive.Trigger + +const DialogPortal = DialogPrimitive.Portal + +const DialogClose = DialogPrimitive.Close + +const DialogOverlay = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName + +const DialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + + + {children} + + + Close + + + +)) +DialogContent.displayName = DialogPrimitive.Content.displayName + +const DialogHeader = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +DialogHeader.displayName = "DialogHeader" + +const DialogFooter = ({ + className, + ...props +}: React.HTMLAttributes) => ( +
+) +DialogFooter.displayName = "DialogFooter" + +const DialogTitle = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogTitle.displayName = DialogPrimitive.Title.displayName + +const DialogDescription = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)) +DialogDescription.displayName = DialogPrimitive.Description.displayName + +export { + Dialog, + DialogPortal, + DialogOverlay, + DialogClose, + DialogTrigger, + DialogContent, + DialogHeader, + DialogFooter, + DialogTitle, + DialogDescription, +} diff --git a/src/components/xui/service.tsx b/src/components/xui/service.tsx new file mode 100644 index 0000000..8d682bc --- /dev/null +++ b/src/components/xui/service.tsx @@ -0,0 +1,108 @@ +import { Plus } from "lucide-react" +import { Button } from "@/components/ui/button" +import { + Dialog, + DialogClose, + DialogContent, + DialogFooter, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog" +import { Input } from "@/components/ui/input" +import { + Form, + FormControl, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form" +import { useForm } from "react-hook-form" +import { z } from "zod" +import { zodResolver } from "@hookform/resolvers/zod" + +interface ServiceCardProps { + className?: string; +} + +const formSchema = z.object({ + name: z.string(), + target: z.string(), + type: z.number().default(1), + enableShowInService: z.boolean().default(false), + duration: z.number().min(30), +}) + +export const ServiceCard: React.FC = ({ className }) => { + const form = useForm>({ + resolver: zodResolver(formSchema), + defaultValues: { + type: 1, + enableShowInService: false, + }, + }) + + function onSubmit(values: z.infer) { + + } + + return ( + + + + + + + New Service + {/* + + Anyone who has this link will be able to view this. + + */} + +
+
+ + ( + + Service Name + + + + + + )} + /> + ( + + Password + + + + + + )} + /> + + +
+ + + + + +
+
+ ) +} diff --git a/src/routes/service.tsx b/src/routes/service.tsx index c78c8fc..72d1f6f 100644 --- a/src/routes/service.tsx +++ b/src/routes/service.tsx @@ -1,6 +1,6 @@ import { swrFetcher } from "@/api/api" import { Checkbox } from "@/components/ui/checkbox" -import { Button } from "@/components/ui/button" +import { ServiceCard } from "@/components/xui/service" import { Plus } from "lucide-react" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { ModelService as Service } from "@/types" @@ -71,9 +71,7 @@ export default function ServicePage() {

Service

- +
@@ -117,5 +115,5 @@ export default function ServicePage() { )}
-
+ } \ No newline at end of file