status page

This commit is contained in:
Alex Holliday committed 2025-12-28 19:49:36 +00:00
1 parent 8fb13273bf
commit 6dcfb67246
7 files changed
+22 -28

No files matched your search

@@ -1,14 +1,12 @@
import { statusPageSchema } from "@/validation/zod";
import { useMemo } from "react";
import { z } from "zod";
import type { FormValues } from "@/pages/status-page/StatusPageForm";
export const useInitForm = ({
initialData,
}: {
initialData: Partial<z.infer<typeof statusPageSchema>> | undefined;
initialData: Partial<FormValues> | undefined;
}) => {
return useMemo(() => {
const defaults: z.infer<typeof statusPageSchema> = {
const defaults: FormValues = {
name: initialData?.name || "",
description: initialData?.description || "",
url: initialData?.url || Math.floor(Math.random() * 1000000).toFixed(0),
@@ -2,14 +2,11 @@ import { StatusPageForm } from "@/pages/status-page/StatusPageForm";
import { useParams } from "react-router";
import { useNavigate } from "react-router";
import { z } from "zod";
import { usePatch, useGet } from "@/hooks/UseApi";
import type { ApiResponse } from "@/types/api";
import { statusPageSchema } from "@/validation/zod";
import type { IMonitor } from "@/types/monitor";
import type { IStatusPageWithMonitors } from "@/types/status-page";
type FormValues = z.infer<typeof statusPageSchema>;
import type { FormValues } from "@/pages/status-page/StatusPageForm";
const StatusPageConfigPage = () => {
const navigate = useNavigate();
@@ -1,13 +1,10 @@
import { StatusPageForm } from "@/pages/status-page/StatusPageForm";
import { useNavigate } from "react-router";
import { z } from "zod";
import { usePost, useGet } from "@/hooks/UseApi";
import type { ApiResponse } from "@/types/api";
import { statusPageSchema } from "@/validation/zod";
import type { IMonitor } from "@/types/monitor";
type FormValues = z.infer<typeof statusPageSchema>;
import type { FormValues } from "@/pages/status-page/StatusPageForm";
const StatusPageCreatePage = () => {
const navigate = useNavigate();
@@ -9,7 +9,7 @@ import { useTheme } from "@mui/material/styles";
import { zodResolver } from "@hookform/resolvers/zod";
import { useTranslation } from "react-i18next";
import { z } from "zod";
import { statusPageSchema } from "@/validation/zod";
import { statusPageSchema } from "@/validation";
import {
useForm,
Controller,
@@ -20,7 +20,7 @@ import { useEffect } from "react";
import { useInitForm } from "@/hooks/forms/UseInitStatusPageForm";
import type { IMonitor } from "@/types/monitor";
type FormValues = z.infer<typeof statusPageSchema>;
export type FormValues = z.infer<typeof statusPageSchema>;
export const StatusPageForm = ({
initialData,
+1
View File
@@ -9,3 +9,4 @@ export * from "./notification-channel";
export * from "./maintenance";
export * from "./team";
export * from "./system-settings";
export * from "./status-page";
+14
View File
@@ -0,0 +1,14 @@
import { z } from "zod";
const statusPageUrlRegex = /^[A-Za-z0-9]+$/;
export const statusPageSchema = z.object({
name: z.string().min(1, "Status page name is required"),
description: z.string().optional(),
url: z
.string()
.min(1, "URL is required")
.regex(statusPageUrlRegex, "Invalid URL"),
isPublished: z.boolean().optional(),
monitors: z.array(z.string()),
});
-13
View File
@@ -7,19 +7,6 @@ export const inviteSchema = z.object({
orgRoleId: z.string().optional(),
});
const statusPageUrlRegex = /^[A-Za-z0-9]+$/;
export const statusPageSchema = z.object({
name: z.string().min(1, "Status page name is required"),
description: z.string().optional(),
url: z
.string()
.min(1, "URL is required")
.regex(statusPageUrlRegex, "Invalid URL"),
isPublished: z.boolean().optional(),
monitors: z.array(z.string()),
});
export const recoverySchema = z.object({
email: z.email({ message: "Invalid email address" }).trim().toLowerCase(),
});