From f3f7f6272f84fb6de808bdd3895e6d5d43543226 Mon Sep 17 00:00:00 2001 From: Sonny Date: Sun, 26 May 2024 00:48:13 +0200 Subject: [PATCH] fix: missing nextId field for collection forms --- app/validators/collection.ts | 4 ++-- database/default_table_fields.ts | 2 +- inertia/app/app.tsx | 1 + inertia/components/form/form_collection.tsx | 2 +- inertia/components/theme_switcher.tsx | 1 - 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/validators/collection.ts b/app/validators/collection.ts index 54516b9..1277c26 100644 --- a/app/validators/collection.ts +++ b/app/validators/collection.ts @@ -10,7 +10,7 @@ export const createCollectionValidator = vine.compile( name: vine.string().trim().minLength(1).maxLength(254), description: vine.string().trim().maxLength(254).nullable(), visibility: vine.enum(Visibility), - nextId: vine.number(), + nextId: vine.number().optional(), }) ); @@ -19,7 +19,7 @@ export const updateCollectionValidator = vine.compile( name: vine.string().trim().minLength(1).maxLength(254), description: vine.string().trim().maxLength(254).nullable(), visibility: vine.enum(Visibility), - nextId: vine.number(), + nextId: vine.number().optional(), params, }) diff --git a/database/default_table_fields.ts b/database/default_table_fields.ts index 1c901c1..b896379 100644 --- a/database/default_table_fields.ts +++ b/database/default_table_fields.ts @@ -1,7 +1,7 @@ import { Knex } from 'knex'; export function defaultTableFields(table: Knex.CreateTableBuilder) { - table.increments('id', { primaryKey: true }).first().unique().notNullable(); + table.increments('id').primary().first().unique().notNullable(); table.timestamp('created_at').notNullable(); table.timestamp('updated_at').nullable(); diff --git a/inertia/app/app.tsx b/inertia/app/app.tsx index 637b75d..33eda7c 100644 --- a/inertia/app/app.tsx +++ b/inertia/app/app.tsx @@ -2,6 +2,7 @@ import { resolvePageComponent } from '@adonisjs/inertia/helpers'; import { createInertiaApp } from '@inertiajs/react'; import { hydrateRoot } from 'react-dom/client'; import { primaryColor } from '~/styles/theme'; +import 'react-toggle/style.css'; import '../i18n/index'; diff --git a/inertia/components/form/form_collection.tsx b/inertia/components/form/form_collection.tsx index 5b240e9..fe6e616 100644 --- a/inertia/components/form/form_collection.tsx +++ b/inertia/components/form/form_collection.tsx @@ -11,7 +11,7 @@ export type FormCollectionData = { name: string; description: string | null; visibility: Visibility; - nextId: Collection['id']; + nextId?: Collection['id']; }; interface FormCollectionProps { diff --git a/inertia/components/theme_switcher.tsx b/inertia/components/theme_switcher.tsx index 9d4f049..af858b6 100644 --- a/inertia/components/theme_switcher.tsx +++ b/inertia/components/theme_switcher.tsx @@ -1,6 +1,5 @@ import { Fragment } from 'react'; import Toggle from 'react-toggle'; -import 'react-toggle/style.css'; import useDarkTheme from '~/hooks/use_dark_theme'; export default function ThemeSwitcher() {