feat: add api generation
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import { getRelativeTime } from "../lib/getRelativeTime";
|
||||
import { LoadingIcon } from "./LoadingIcon";
|
||||
import { callServerPromise } from "./callServerPromise";
|
||||
import {
|
||||
FormControl,
|
||||
FormField,
|
||||
@@ -56,7 +57,6 @@ import {
|
||||
import { ArrowUpDown, MoreHorizontal } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { toast } from "sonner";
|
||||
import { z } from "zod";
|
||||
|
||||
export type Machine = {
|
||||
@@ -176,20 +176,6 @@ export const columns: ColumnDef<Machine>[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export async function callServerPromise<T>(result: Promise<T>) {
|
||||
return result
|
||||
.then((x) => {
|
||||
if ((x as { message: string })?.message !== undefined) {
|
||||
toast.success((x as { message: string }).message);
|
||||
}
|
||||
return x;
|
||||
})
|
||||
.catch((error) => {
|
||||
toast.error(error.message);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
export function MachineList({ data }: { data: Machine[] }) {
|
||||
const [sorting, setSorting] = React.useState<SortingState>([]);
|
||||
const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(
|
||||
|
||||
Reference in New Issue
Block a user