56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
import { RequestCtx } from '@/backend/routes.ts';
|
|
|
|
import { html } from '@atelier/responses.ts';
|
|
import { Form, View } from '@/backend/templates/index.ts';
|
|
|
|
export function viewItems(req: Request, ctx: RequestCtx) {
|
|
return new Response('');
|
|
}
|
|
|
|
export function viewItem(req: Request, ctx: RequestCtx) {
|
|
return new Response('');
|
|
}
|
|
|
|
/*
|
|
item_type text not null,
|
|
name text not null,
|
|
image_blob_id integer,
|
|
|
|
started_timestamp text,
|
|
finished_timestamp text,
|
|
|
|
rating real,
|
|
review text,
|
|
|
|
other_metadata_json text,
|
|
|
|
foreign key (image_blob_id) references blob(blob_id)
|
|
|
|
*/
|
|
|
|
export function viewCreateItem(req: Request, ctx: RequestCtx) {
|
|
const body = `
|
|
${
|
|
Form({
|
|
hasFileData: true,
|
|
action: '/items/create',
|
|
fields: [
|
|
{ name: 'name', type: 'text', label: 'Name' },
|
|
{ name: 'image', type: 'file', label: 'Image', required: false },
|
|
{ name: 'rating', type: 'number', label: 'Rating', required: false },
|
|
{ name: 'review', type: 'textarea', label: 'Review', required: false },
|
|
],
|
|
})
|
|
}
|
|
`;
|
|
|
|
return html(View({ title: 'Create item', body }));
|
|
}
|
|
|
|
export async function postItem(req: Request, ctx: RequestCtx) {
|
|
const form = await req.formData();
|
|
console.debug({ form });
|
|
|
|
return new Response('');
|
|
}
|