trim
This commit is contained in:
parent
3f22b2ce82
commit
158d73a6df
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 {
|
try {
|
||||||
subSchema.parse(data)
|
subSchema.parse(data)
|
||||||
const res = await prisma.sub.update({ where: { id: data.id }, data })
|
const res = await prisma.sub.update({ where: { id: data.id }, data })
|
||||||
revalidatePath("/submission")
|
revalidatePath("submission")
|
||||||
return res
|
return res
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
return undefined
|
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 pubs = await getPubs()
|
||||||
const responses = await getResponses()
|
const responses = await getResponses()
|
||||||
const genres = await getGenres()
|
const genres = await getGenres()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<DataTable data={subs} columns={columns} tableName="sub"
|
<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 selectedRows = table.getState().rowSelection
|
||||||
const rowIds = Object.keys(selectedRows)
|
const rowIds = Object.keys(selectedRows)
|
||||||
const recordIds = rowIds.map(id => Number(table.getRow(id).original.id))
|
const recordIds = rowIds.map(id => Number(table.getRow(id).original.id))
|
||||||
console.table(recordIds)
|
|
||||||
deleteRecords(recordIds, pathname)
|
deleteRecords(recordIds, pathname)
|
||||||
}}>
|
}}>
|
||||||
Yes, delete them!</Button>
|
Yes, delete them!</Button>
|
||||||
|
|
|
@ -100,7 +100,6 @@ export default function GenrePickerInputCell(props: CellContext<any, any>) {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
checked={field.value?.includes(item.id)}
|
checked={field.value?.includes(item.id)}
|
||||||
onCheckedChange={(checked) => {
|
onCheckedChange={(checked) => {
|
||||||
console.log(field.value)
|
|
||||||
return checked
|
return checked
|
||||||
? field.onChange(
|
? field.onChange(
|
||||||
[...field.value, item.id]
|
[...field.value, item.id]
|
||||||
|
|
|
@ -2,9 +2,7 @@ import { ComponentProps } from "react";
|
||||||
|
|
||||||
export default function itleContainer({ children }: ComponentProps<"div">) {
|
export default function itleContainer({ children }: ComponentProps<"div">) {
|
||||||
let classes = "w-full text-left m-auto"
|
let classes = "w-full text-left m-auto"
|
||||||
console.table(children)
|
|
||||||
if (children == "RECORD DELETED") {
|
if (children == "RECORD DELETED") {
|
||||||
console.log("BINGO")
|
|
||||||
classes = classes + " text-destructive font-bold"
|
classes = classes + " text-destructive font-bold"
|
||||||
}
|
}
|
||||||
return <span className="h-10 flex align-center"><p className={classes}>{children}</p></span>
|
return <span className="h-10 flex align-center"><p className={classes}>{children}</p></span>
|
||||||
|
|
Loading…
Reference in New Issue