merged two files
This commit is contained in:
@ -22,25 +22,25 @@ export default async function ArtworkSinglePage({ params }: { params: Promise<{
|
|||||||
<div>
|
<div>
|
||||||
<h1 className="text-2xl font-bold mb-4">Edit artwork</h1>
|
<h1 className="text-2xl font-bold mb-4">Edit artwork</h1>
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
||||||
<div>
|
<div className="space-y-6">
|
||||||
{item ? <EditArtworkForm artwork={item} tags={tags} categories={categories} /> : 'Artwork not found...'}
|
{item ? <EditArtworkForm artwork={item} tags={tags} categories={categories} /> : 'Artwork not found...'}
|
||||||
<div className="mt-6">
|
<div>
|
||||||
{item && <DeleteArtworkButton artworkId={item.id} />}
|
{item && <DeleteArtworkButton artworkId={item.id} />}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{item && <ArtworkVariants artworkId={item.id} variants={item.variants} />}
|
{item && <ArtworkTimelapse artworkId={item.id} timelapse={item.timelapse} />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div>
|
|
||||||
{item && <ArtworkTimelapse artworkId={item.id} timelapse={item.timelapse} />}
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
{item && <ArtworkColors colors={item.colors} artworkId={item.id} />}
|
{item && <ArtworkColors colors={item.colors} artworkId={item.id} />}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{item && <ArtworkDetails artwork={item} />}
|
{item && <ArtworkDetails artwork={item} />}
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
{item && <ArtworkVariants artworkId={item.id} variants={item.variants} />}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -2,23 +2,19 @@
|
|||||||
|
|
||||||
import { updateArtwork } from "@/actions/artworks/updateArtwork";
|
import { updateArtwork } from "@/actions/artworks/updateArtwork";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Calendar } from "@/components/ui/calendar";
|
|
||||||
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form";
|
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import MultipleSelector from "@/components/ui/multiselect";
|
import MultipleSelector from "@/components/ui/multiselect";
|
||||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
import { Textarea } from "@/components/ui/textarea";
|
||||||
import { ArtTag } from "@/generated/prisma/client";
|
import type { ArtTag } from "@/generated/prisma/client";
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
import { artworkSchema } from "@/schemas/artworks/imageSchema";
|
import { artworkSchema } from "@/schemas/artworks/imageSchema";
|
||||||
import { ArtworkWithRelations, CategoryWithTags } from "@/types/Artwork";
|
import type { ArtworkWithRelations, CategoryWithTags } from "@/types/Artwork";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { format } from "date-fns";
|
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { z } from "zod/v4";
|
import type { z } from "zod/v4";
|
||||||
|
|
||||||
export default function EditArtworkForm({ artwork, categories, tags }:
|
export default function EditArtworkForm({ artwork, categories, tags }:
|
||||||
{
|
{
|
||||||
@ -82,7 +78,7 @@ export default function EditArtworkForm({ artwork, categories, tags }:
|
|||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Alt Text</FormLabel>
|
<FormLabel>Alt Text</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Input {...field} placeholder="Alt for this image" />
|
<Textarea {...field} placeholder="Alt for this image" />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@ -155,7 +151,7 @@ export default function EditArtworkForm({ artwork, categories, tags }:
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{/* Date */}
|
{/* Date
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="creationDate"
|
name="creationDate"
|
||||||
@ -195,7 +191,7 @@ export default function EditArtworkForm({ artwork, categories, tags }:
|
|||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/> */}
|
||||||
{/* Select */}
|
{/* Select */}
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
@ -337,21 +333,6 @@ export default function EditArtworkForm({ artwork, categories, tags }:
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Boolean */}
|
{/* Boolean */}
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="needsWork"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="flex items-center justify-between rounded-lg border p-4">
|
|
||||||
<div className="space-y-0.5">
|
|
||||||
<FormLabel>Needs some work</FormLabel>
|
|
||||||
<FormDescription></FormDescription>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Switch checked={field.value} onCheckedChange={field.onChange} />
|
|
||||||
</FormControl>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="nsfw"
|
name="nsfw"
|
||||||
@ -367,21 +348,6 @@ export default function EditArtworkForm({ artwork, categories, tags }:
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="published"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="flex items-center justify-between rounded-lg border p-4">
|
|
||||||
<div className="space-y-0.5">
|
|
||||||
<FormLabel>Publish</FormLabel>
|
|
||||||
<FormDescription>Will this image be published.</FormDescription>
|
|
||||||
</div>
|
|
||||||
<FormControl>
|
|
||||||
<Switch checked={field.value} onCheckedChange={field.onChange} />
|
|
||||||
</FormControl>
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="setAsHeader"
|
name="setAsHeader"
|
||||||
@ -397,51 +363,37 @@ export default function EditArtworkForm({ artwork, categories, tags }:
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
{/* Read only */}
|
<FormField
|
||||||
{/* <FormField
|
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="fileKey"
|
name="needsWork"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem className="flex items-center justify-between rounded-lg border p-4">
|
||||||
<FormLabel>Image Key</FormLabel>
|
<div className="space-y-0.5">
|
||||||
<FormControl><Input {...field} disabled /></FormControl>
|
<FormLabel>Needs some work</FormLabel>
|
||||||
<FormMessage />
|
<FormDescription></FormDescription>
|
||||||
|
</div>
|
||||||
|
<FormControl>
|
||||||
|
<Switch checked={field.value} onCheckedChange={field.onChange} />
|
||||||
|
</FormControl>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="originalFile"
|
name="published"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem className="flex items-center justify-between rounded-lg border p-4">
|
||||||
<FormLabel>Original file</FormLabel>
|
<div className="space-y-0.5">
|
||||||
<FormControl><Input {...field} disabled /></FormControl>
|
<FormLabel>Publish</FormLabel>
|
||||||
<FormMessage />
|
<FormDescription>Will this image be published.</FormDescription>
|
||||||
|
</div>
|
||||||
|
<FormControl>
|
||||||
|
<Switch checked={field.value} onCheckedChange={field.onChange} />
|
||||||
|
</FormControl>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="fileType"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>Filetype</FormLabel>
|
|
||||||
<FormControl><Input {...field} disabled /></FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="fileSize"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>FileSize</FormLabel>
|
|
||||||
<FormControl><Input type="number" {...field} disabled /></FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/> */}
|
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
<Button type="submit">Submit</Button>
|
<Button type="submit">Submit</Button>
|
||||||
<Button type="reset" variant="secondary" onClick={() => router.back()}>Cancel</Button>
|
<Button type="reset" variant="secondary" onClick={() => router.back()}>Cancel</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user