@@ -49,13 +49,13 @@ export const billingAlertsSchema = z.object({
4949
5050 return [ "" ] ;
5151 } , z . string ( ) . email ( ) . array ( ) . nonempty ( "At least one email is required" ) ) ,
52- alertLevels : z . preprocess ( ( i ) => {
53- const values = typeof i === "string" ? [ i ] : Array . isArray ( i ) ? i : [ ] ;
54- return values
55- . filter ( ( v ) => v !== "" )
56- . map ( ( v ) => Number ( v ) )
57- . filter ( ( n ) => Number . isFinite ( n ) ) ;
58- } , z . number ( ) . array ( ) . refine ( thresholdValuesAreUnique , "Each alert must be unique" ) ) ,
52+ alertLevels : z . preprocess (
53+ ( i ) => {
54+ const values = typeof i === "string" ? [ i ] : Array . isArray ( i ) ? i : [ ] ;
55+ return values . filter ( ( v ) => v !== "" ) . map ( ( v ) => Number ( v ) ) ;
56+ } ,
57+ z . number ( ) . array ( ) . refine ( thresholdValuesAreUnique , "Each alert must be unique" ) ,
58+ ) ,
5959} ) ;
6060
6161export type { BillingAlertsFormData } from "~/components/billing/billingAlertsFormat" ;
@@ -101,7 +101,7 @@ function isDuplicateThresholdRow(rows: ThresholdRow[], index: number): boolean {
101101 const parsed = Number ( value ) ;
102102 return rows . some (
103103 ( row , rowIndex ) =>
104- rowIndex !== index && ! isEmptyThresholdRow ( row . value ) && Number ( row . value ) === parsed
104+ rowIndex !== index && ! isEmptyThresholdRow ( row . value ) && Number ( row . value ) === parsed ,
105105 ) ;
106106}
107107
@@ -136,27 +136,26 @@ export function BillingAlertsSection({
136136 const alertPreviewLimitCents = getAlertPreviewLimitCents (
137137 alerts ,
138138 effectiveLimitCents ,
139- planLimitCents
139+ planLimitCents ,
140140 ) ;
141141 const maxAlerts = isPercentageMode ? MAX_PERCENTAGE_ALERTS : MAX_ABSOLUTE_ALERTS ;
142142
143143 const savedThresholds = useMemo (
144144 ( ) => storedAlertsToThresholds ( alerts , billingLimitMode , effectiveLimitCents , planLimitCents ) ,
145- [ alerts , billingLimitMode , effectiveLimitCents , planLimitCents ]
145+ [ alerts , billingLimitMode , effectiveLimitCents , planLimitCents ] ,
146146 ) ;
147147 const savedEmails = useMemo ( ( ) => alerts . emails , [ alerts . emails ] ) ;
148148 const hasLegacySpikes = useMemo (
149- ( ) =>
150- hasLegacySpikeAlertLevels ( alerts , billingLimitMode , effectiveLimitCents , planLimitCents ) ,
151- [ alerts , billingLimitMode , effectiveLimitCents , planLimitCents ]
149+ ( ) => hasLegacySpikeAlertLevels ( alerts , billingLimitMode , effectiveLimitCents , planLimitCents ) ,
150+ [ alerts , billingLimitMode , effectiveLimitCents , planLimitCents ] ,
152151 ) ;
153152
154153 const nextThresholdIdRef = useRef ( savedThresholds . length ) ;
155154 const [ thresholdRows , setThresholdRows ] = useState < ThresholdRow [ ] > ( ( ) =>
156- toThresholdRows ( savedThresholds )
155+ toThresholdRows ( savedThresholds ) ,
157156 ) ;
158157 const [ emailValues , setEmailValues ] = useState < string [ ] > (
159- savedEmails . length > 0 ? [ ...savedEmails , "" ] : [ "" ]
158+ savedEmails . length > 0 ? [ ...savedEmails , "" ] : [ "" ] ,
160159 ) ;
161160 const actionData = useActionData < BillingAlertsActionData > ( ) ;
162161 const alertsSubmission =
@@ -192,7 +191,7 @@ export function BillingAlertsSection({
192191
193192 function updateThresholdRow ( index : number , rawValue : string ) {
194193 setThresholdRows ( ( current ) =>
195- current . map ( ( row , rowIndex ) => ( rowIndex === index ? { ...row , value : rawValue } : row ) )
194+ current . map ( ( row , rowIndex ) => ( rowIndex === index ? { ...row , value : rawValue } : row ) ) ,
196195 ) ;
197196 }
198197
@@ -262,7 +261,7 @@ export function BillingAlertsSection({
262261 if ( e . target . value === "" ) return ;
263262 const clamped = Math . min (
264263 MAX_PERCENTAGE_THRESHOLD ,
265- Math . max ( 1 , Number ( e . target . value ) )
264+ Math . max ( 1 , Number ( e . target . value ) ) ,
266265 ) ;
267266 if ( String ( clamped ) !== e . target . value ) {
268267 updateThresholdRow ( index , String ( clamped ) ) ;
@@ -281,9 +280,9 @@ export function BillingAlertsSection({
281280 { formatCurrency (
282281 previewDollarAmountForPercent (
283282 Number . isFinite ( parsed ) ? parsed : 0 ,
284- alertPreviewLimitCents
283+ alertPreviewLimitCents ,
285284 ) ,
286- false
285+ false ,
287286 ) }
288287 )
289288 </ span >
@@ -343,7 +342,7 @@ export function BillingAlertsSection({
343342 { emailFields . map ( ( email , index ) => {
344343 const { defaultValue : _emailDefaultValue , ...emailInputProps } = conform . input (
345344 email ,
346- { type : "email" }
345+ { type : "email" } ,
347346 ) ;
348347
349348 return (
0 commit comments