From 471eea731233f24ae9c7028e7477b1023e1966dc Mon Sep 17 00:00:00 2001 From: Kunal Gupta <39487888+iamKunalGupta@users.noreply.github.com> Date: Sat, 9 Mar 2024 03:02:46 +0530 Subject: [PATCH] chore(prettier): lint fixes --- ui/app/alert-config/new.tsx | 20 ++++++++----- ui/app/alert-config/page.tsx | 49 +++++++++++++++++++++++++------ ui/app/alert-config/validation.ts | 18 +++++++----- 3 files changed, 64 insertions(+), 23 deletions(-) diff --git a/ui/app/alert-config/new.tsx b/ui/app/alert-config/new.tsx index 0868277ffb..12dfbc9cf5 100644 --- a/ui/app/alert-config/new.tsx +++ b/ui/app/alert-config/new.tsx @@ -10,9 +10,10 @@ import SelectTheme from '../styles/select'; import { alertConfigReqSchema, alertConfigType, - emailConfigType, serviceConfigType, + emailConfigType, + serviceConfigType, serviceTypeSchemaMap, - slackConfigType + slackConfigType, } from './validation'; export type ServiceType = 'slack' | 'email'; @@ -151,14 +152,19 @@ export function NewConfig(alertProps: AlertConfigProps) { return; } - const serviceSchema = serviceTypeSchemaMap[serviceType] - const serviceValidity = serviceSchema.safeParse(config) - if(!serviceValidity?.success){ - notifyErr("Invalid alert service configuration for "+ serviceType + ". " + serviceValidity.error.issues[0].message) + const serviceSchema = serviceTypeSchemaMap[serviceType]; + const serviceValidity = serviceSchema.safeParse(config); + if (!serviceValidity?.success) { + notifyErr( + 'Invalid alert service configuration for ' + + serviceType + + '. ' + + serviceValidity.error.issues[0].message + ); return; } - const serviceConfig = serviceValidity.data + const serviceConfig = serviceValidity.data; const alertConfigReq: alertConfigType = { id: Number(alertProps.id || -1), serviceType: serviceType, diff --git a/ui/app/alert-config/page.tsx b/ui/app/alert-config/page.tsx index 73fde08a51..25a92338b9 100644 --- a/ui/app/alert-config/page.tsx +++ b/ui/app/alert-config/page.tsx @@ -14,8 +14,21 @@ import { tableStyle } from '../peers/[peerName]/style'; import { fetcher } from '../utils/swr'; import { AlertConfigProps, NewConfig, ServiceType } from './new'; -const ServiceIcon = ({serviceType, size}: {serviceType:string, size:number}) => { - return {serviceType}; +const ServiceIcon = ({ + serviceType, + size, +}: { + serviceType: string; + size: number; +}) => { + return ( + {serviceType} + ); }; const AlertConfigPage: React.FC = () => { @@ -79,13 +92,31 @@ const AlertConfigPage: React.FC = () => { {alerts?.length ? ( alerts.map((alertConfig: UAlertConfigResponse, index) => ( - -
-
- - -
- + +
+
+ + +
diff --git a/ui/app/alert-config/validation.ts b/ui/app/alert-config/validation.ts index fbad342a1a..9b1a14b2b3 100644 --- a/ui/app/alert-config/validation.ts +++ b/ui/app/alert-config/validation.ts @@ -22,9 +22,12 @@ export const slackServiceConfigSchema = z.intersection( .min(1, { message: 'Auth Token cannot be empty' }) .max(256, { message: 'Auth Token is too long' }), channel_ids: z - .array(z.string().trim().min(1, { message: 'Channel IDs cannot be empty' }), { - required_error: 'We need a channel ID', - }) + .array( + z.string().trim().min(1, { message: 'Channel IDs cannot be empty' }), + { + required_error: 'We need a channel ID', + } + ) .min(1, { message: 'Atleast one channel ID is needed' }), }) ); @@ -35,7 +38,8 @@ export const emailServiceConfigSchema = z.intersection( email_addresses: z .array( z - .string().trim() + .string() + .trim() .min(1, { message: 'Email Addresses cannot be empty' }) .includes('@'), { @@ -68,6 +72,6 @@ export type serviceConfigType = z.infer; export type alertConfigType = z.infer; export const serviceTypeSchemaMap = { - 'slack':slackServiceConfigSchema, - 'email':emailServiceConfigSchema -} \ No newline at end of file + slack: slackServiceConfigSchema, + email: emailServiceConfigSchema, +};