trim
This commit is contained in:
parent
10c64d3883
commit
1f358c5b84
BIN
prisma/dev.db
BIN
prisma/dev.db
Binary file not shown.
|
@ -47,13 +47,12 @@ export async function updateSub(data: Sub): Promise<Sub | undefined> {
|
|||
try {
|
||||
subSchema.parse(data)
|
||||
const res = await prisma.sub.update({ where: { id: data.id }, data })
|
||||
revalidatePath("/submission")
|
||||
revalidatePath("submission")
|
||||
return res
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return undefined
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
"use client"
|
||||
import { LineChart, Line, CartesianGrid, XAxis, YAxis, PieChart, Pie } from "recharts"
|
||||
import { SubComplete } from "./page"
|
||||
export function SubsChart({ data }: { data: Array<SubComplete> }) {
|
||||
const pieData: Array<{ story: string, occurrences: number }> = []
|
||||
data.forEach(dataRow => {
|
||||
const story = dataRow.story.title
|
||||
const exists = pieData.findIndex(pieRow => story === pieRow.story)
|
||||
if (exists === -1) {
|
||||
//add the story to pieData if it doesn't already exist
|
||||
pieData.push({ story: story, occurrences: 0 })
|
||||
return
|
||||
}
|
||||
pieData[exists].occurrences++
|
||||
})
|
||||
console.log(pieData)
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<PieChart width={400} height={400}>
|
||||
<Pie data={pieData} dataKey="story" outerRadius={50} fill="teal" />
|
||||
</PieChart>
|
||||
|
||||
|
||||
|
||||
|
||||
<LineChart width={400} height={400} data={data}>
|
||||
<Line type="monotone" dataKey="id" stroke="#8884d8" />
|
||||
<CartesianGrid />
|
||||
<XAxis dataKey="submitted" />
|
||||
<YAxis />
|
||||
|
||||
</LineChart>
|
||||
</>
|
||||
|
||||
)
|
||||
}
|
|
@ -16,6 +16,7 @@ export default async function Page() {
|
|||
const pubs = await getPubs()
|
||||
const responses = await getResponses()
|
||||
const genres = await getGenres()
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
<DataTable data={subs} columns={columns} tableName="sub"
|
||||
|
|
|
@ -1,115 +0,0 @@
|
|||
"use client"
|
||||
|
||||
import { z } from "zod"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { Genre } from "@prisma/client"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormDescription,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form"
|
||||
import { Input } from "@/components/ui/input"
|
||||
import { Checkbox } from "@/components/ui/checkbox"
|
||||
import { storySchema } from "./schemas"
|
||||
|
||||
export default function FancyForm({ genres }) {
|
||||
// 1. Define your form.
|
||||
const form = useForm<z.infer<typeof storySchema>>({
|
||||
resolver: zodResolver(storySchema),
|
||||
defaultValues: {
|
||||
title: "",
|
||||
word_count: 0,
|
||||
genres: genres
|
||||
},
|
||||
})
|
||||
// 2. Define a submit handler.
|
||||
function onSubmit(values: z.infer<typeof storySchema>) {
|
||||
// Do something with the form values.
|
||||
// ✅ This will be type-safe and validated.
|
||||
console.log(values)
|
||||
}
|
||||
return (
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="title"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Title</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="title goes here..." {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="word_count"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Word count</FormLabel>
|
||||
<FormControl>
|
||||
<Input type="number" step={500} min={0} {...field}></Input>
|
||||
</FormControl>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="genres"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<div className="mb-4">
|
||||
<FormLabel>Genres</FormLabel>
|
||||
<FormDescription>genres baby</FormDescription>
|
||||
</div>
|
||||
{genres.map((item) => (
|
||||
<FormField
|
||||
key={item.id}
|
||||
control={form.control}
|
||||
name="genres"
|
||||
render={({ field }) => {
|
||||
return (
|
||||
<FormItem
|
||||
key={item.id}
|
||||
className="flex flex-row items-start space-x-3 space-y-0"
|
||||
>
|
||||
<FormControl>
|
||||
<Checkbox
|
||||
checked={field.value?.includes(item.id)}
|
||||
onCheckedChange={(checked) => {
|
||||
return checked
|
||||
? field.onChange([...field.value, item.id])
|
||||
: field.onChange(
|
||||
field.value?.filter(
|
||||
(value) => value !== item.id
|
||||
)
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormLabel className="text-sm font-normal">
|
||||
{item.name}
|
||||
</FormLabel>
|
||||
</FormItem>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</FormItem>
|
||||
)}
|
||||
|
||||
/>
|
||||
<Button type="submit">Submit</Button>
|
||||
</form>
|
||||
</Form>
|
||||
)
|
||||
}
|
|
@ -210,7 +210,6 @@ export function DataTable<TData, TValue>({
|
|||
const selectedRows = table.getState().rowSelection
|
||||
const rowIds = Object.keys(selectedRows)
|
||||
const recordIds = rowIds.map(id => Number(table.getRow(id).original.id))
|
||||
console.table(recordIds)
|
||||
deleteRecords(recordIds, pathname)
|
||||
}}>
|
||||
Yes, delete them!</Button>
|
||||
|
|
|
@ -100,7 +100,6 @@ export default function GenrePickerInputCell(props: CellContext<any, any>) {
|
|||
<Checkbox
|
||||
checked={field.value?.includes(item.id)}
|
||||
onCheckedChange={(checked) => {
|
||||
console.log(field.value)
|
||||
return checked
|
||||
? field.onChange(
|
||||
[...field.value, item.id]
|
||||
|
|
|
@ -2,9 +2,7 @@ import { ComponentProps } from "react";
|
|||
|
||||
export default function itleContainer({ children }: ComponentProps<"div">) {
|
||||
let classes = "w-full text-left m-auto"
|
||||
console.table(children)
|
||||
if (children == "RECORD DELETED") {
|
||||
console.log("BINGO")
|
||||
classes = classes + " text-destructive font-bold"
|
||||
}
|
||||
return <span className="h-10 flex align-center"><p className={classes}>{children}</p></span>
|
||||
|
|
Loading…
Reference in New Issue