style: clean up code with prettier and eslint
This commit is contained in:
1 parent
60278b9e71
commit
fb8e77bb68
378 files changed
+22407
-20689
No files matched your search
@@ -1,69 +1,57 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
import { Loader2, Plus } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { createCatalogPage } from '@/actions/catalog'
|
||||
import { createBcPage } from '@/actions/catalog-bc'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
} from '@/components/ui/dialog'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select'
|
||||
import { useServerAction } from '@/hooks/use-server-action'
|
||||
import { CATALOG_LAYOUTS } from '@/lib/catalog-layouts'
|
||||
import { Loader2, Plus } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { createCatalogPage } from "@/actions/catalog";
|
||||
import { createBcPage } from "@/actions/catalog-bc";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { useServerAction } from "@/hooks/use-server-action";
|
||||
import { CATALOG_LAYOUTS } from "@/lib/catalog-layouts";
|
||||
|
||||
interface CatalogActionsProps {
|
||||
catalogType?: 'normal' | 'bc'
|
||||
catalogType?: "normal" | "bc";
|
||||
}
|
||||
|
||||
export function CatalogActions({ catalogType = 'normal' }: CatalogActionsProps) {
|
||||
const { run, isPending } = useServerAction()
|
||||
const [open, setOpen] = useState(false)
|
||||
const [caption, setCaption] = useState('')
|
||||
const [parentId, setParentId] = useState('-1')
|
||||
const [pageLayout, setPageLayout] = useState('default_3x3')
|
||||
const isBc = catalogType === 'bc'
|
||||
export function CatalogActions({ catalogType = "normal" }: CatalogActionsProps) {
|
||||
const { run, isPending } = useServerAction();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [caption, setCaption] = useState("");
|
||||
const [parentId, setParentId] = useState("-1");
|
||||
const [pageLayout, setPageLayout] = useState("default_3x3");
|
||||
const isBc = catalogType === "bc";
|
||||
|
||||
function handleCreate() {
|
||||
if (!caption.trim()) {
|
||||
toast.error('Caption is required')
|
||||
return
|
||||
toast.error("Caption is required");
|
||||
return;
|
||||
}
|
||||
|
||||
const input = {
|
||||
caption: caption.trim(),
|
||||
parentId: parseInt(parentId, 10),
|
||||
pageLayout,
|
||||
}
|
||||
};
|
||||
|
||||
const fn = isBc ? () => createBcPage(input) : () => createCatalogPage(input)
|
||||
const fn = isBc ? () => createBcPage(input) : () => createCatalogPage(input);
|
||||
|
||||
run(fn, {
|
||||
successMessage: `Catalog page "${caption.trim()}" created.`,
|
||||
onSuccess: (data) => {
|
||||
setOpen(false)
|
||||
setCaption('')
|
||||
setParentId('-1')
|
||||
setOpen(false);
|
||||
setCaption("");
|
||||
setParentId("-1");
|
||||
if (data.id) {
|
||||
window.location.href = isBc
|
||||
? `/admin/catalog/builder-club/${data.id}`
|
||||
: `/admin/catalog/${data.id}`
|
||||
: `/admin/catalog/${data.id}`;
|
||||
}
|
||||
},
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -76,7 +64,7 @@ export function CatalogActions({ catalogType = 'normal' }: CatalogActionsProps)
|
||||
</DialogTrigger>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{isBc ? 'Create Builder Club Page' : 'Create Catalog Page'}</DialogTitle>
|
||||
<DialogTitle>{isBc ? "Create Builder Club Page" : "Create Catalog Page"}</DialogTitle>
|
||||
</DialogHeader>
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
@@ -124,5 +112,5 @@ export function CatalogActions({ catalogType = 'normal' }: CatalogActionsProps)
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user