* fix(deps): update dependency drizzle-zod to ^0.8.2 * chore: update zod to v4 import * fix: path is no longer available in transform context * fix: AnyZodObject does no longer exist * fix: auth env.ts using wrong createEnv and remove unused file env-validation.ts * fix: required_error no longer exists on z.string * fix: zod error map is deprecated and replaced with config * fix: default requires callback now * fix: migrate zod resolver for mantine * fix: remove unused form translation file * fix: wrong enum type * fix: record now requires two arguments * fix: add-confirm-password-refinement type issues * fix: add missing first record argument for entityStateSchema * fix: migrate superrefine to check * fix(deps): upgrade zod-form-data to v3 * fix: migrate superRefine to check for mediaUploadSchema * fix: authProvidersSchema default is array * fix: use stringbool instead of custom implementation * fix: record requires first argument * fix: migrate superRefine to check for certificate router * fix: confirm pasword refinement is overwriting types * fix: email optional not working * fix: migrate intersection to object converter * fix: safe parse return value rename * fix: easier access for min and max number value * fix: migrate superRefine to check for oldmarr import file * fix: inference of enum shape for old-import board-size wrong * fix: errors renamed to issues * chore: address pull request feedback * fix: zod form requires object * fix: inference for use-zod-form not working * fix: remove unnecessary convertion * fix(deps): upgrade trpc-to-openapi to v3 * fix: build error * fix: migrate missing zod imports to v4 * fix: migrate zod records to v4 * fix: missing core package dependency in api module * fix: unable to convert custom zod schema to openapi schema * fix(deps): upgrade zod to v4 * chore(renovate): enable zod dependency updates * test: add simple unit test for convertIntersectionToZodObject --------- Co-authored-by: homarr-renovate[bot] <158783068+homarr-renovate[bot]@users.noreply.github.com>
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
import { useCallback } from "react";
|
|
import { useRouter } from "next/navigation";
|
|
import type { z } from "zod/v4";
|
|
|
|
import { clientApi } from "@homarr/api/client";
|
|
import { revalidatePathActionAsync } from "@homarr/common/client";
|
|
import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";
|
|
import { useI18n, useScopedI18n } from "@homarr/translation/client";
|
|
import type { appManageSchema } from "@homarr/validation/app";
|
|
|
|
import { AppForm } from "./_form";
|
|
|
|
export const AppNewForm = ({
|
|
showCreateAnother,
|
|
showBackToOverview,
|
|
}: {
|
|
showCreateAnother: boolean;
|
|
showBackToOverview: boolean;
|
|
}) => {
|
|
const tScoped = useScopedI18n("app.page.create.notification");
|
|
const t = useI18n();
|
|
const router = useRouter();
|
|
|
|
const { mutate, isPending } = clientApi.app.create.useMutation({
|
|
onError: () => {
|
|
showErrorNotification({
|
|
title: tScoped("error.title"),
|
|
message: tScoped("error.message"),
|
|
});
|
|
},
|
|
});
|
|
|
|
const handleSubmit = useCallback(
|
|
(values: z.infer<typeof appManageSchema>, redirect: boolean, afterSuccess?: () => void) => {
|
|
mutate(values, {
|
|
onSuccess() {
|
|
showSuccessNotification({
|
|
title: tScoped("success.title"),
|
|
message: tScoped("success.message"),
|
|
});
|
|
afterSuccess?.();
|
|
|
|
if (!redirect) {
|
|
return;
|
|
}
|
|
void revalidatePathActionAsync("/manage/apps").then(() => {
|
|
router.push("/manage/apps");
|
|
});
|
|
},
|
|
});
|
|
},
|
|
[mutate, router, tScoped],
|
|
);
|
|
|
|
return (
|
|
<AppForm
|
|
buttonLabels={{
|
|
submit: t("common.action.create"),
|
|
submitAndCreateAnother: showCreateAnother ? t("common.action.createAnother") : undefined,
|
|
}}
|
|
showBackToOverview={showBackToOverview}
|
|
handleSubmit={handleSubmit}
|
|
isPending={isPending}
|
|
/>
|
|
);
|
|
};
|