diff --git a/src/client/components/monitor/StatusPage/EditForm.tsx b/src/client/components/monitor/StatusPage/EditForm.tsx new file mode 100644 index 0000000..c6ef945 --- /dev/null +++ b/src/client/components/monitor/StatusPage/EditForm.tsx @@ -0,0 +1,74 @@ +import { Button, Form, Input, Typography } from 'antd'; +import React from 'react'; +import { slugRegex } from '../../../../shared'; +import { z } from 'zod'; + +const { Text } = Typography; + +interface Values { + title: string; + slug: string; +} + +interface MonitorStatusPageEditFormProps { + isLoading?: boolean; + onFinish: (values: Values) => void; +} + +export const MonitorStatusPageEditForm: React.FC = + React.memo((props) => { + return ( +
+ layout="vertical" onFinish={props.onFinish}> + + + + + +
+ Accept characters: a-z 0-9{' '} + - +
+
+ No consecutive dashes -- +
+
+ } + rules={[ + { + required: true, + }, + { + validator(rule, value, callback) { + try { + z.string().regex(slugRegex).parse(value); + callback(); + } catch (err) { + callback('Not valid slug'); + } + }, + }, + ]} + > + + + + + + ); + }); +MonitorStatusPageEditForm.displayName = 'MonitorStatusPageEditForm'; diff --git a/src/client/pages/Monitor/PageAdd.tsx b/src/client/pages/Monitor/PageAdd.tsx index cdc0ab9..16b582c 100644 --- a/src/client/pages/Monitor/PageAdd.tsx +++ b/src/client/pages/Monitor/PageAdd.tsx @@ -2,12 +2,8 @@ import React from 'react'; import { useNavigate } from 'react-router'; import { useCurrentWorkspaceId } from '../../store/user'; import { trpc } from '../../api/trpc'; -import { Button, Form, Input, Typography } from 'antd'; import { useEvent } from '../../hooks/useEvent'; -import { z } from 'zod'; -import { slugRegex } from '../../../shared'; - -const { Text, Paragraph } = Typography; +import { MonitorStatusPageEditForm } from '../../components/monitor/StatusPage/EditForm'; interface Values { title: string; @@ -35,59 +31,10 @@ export const MonitorPageAdd: React.FC = React.memo(() => { return (
- layout="vertical" onFinish={handleFinish}> - - - - - -
- Accept characters: a-z 0-9{' '} - - -
-
- No consecutive dashes -- -
-
- } - rules={[ - { - required: true, - }, - { - validator(rule, value, callback) { - try { - z.string().regex(slugRegex).parse(value); - callback(); - } catch (err) { - callback('Not valid slug'); - } - }, - }, - ]} - > - - - - + ); });