Openstatus www.openstatus.dev

fix: pagerduty config (#1526)

authored by

Maximilian Kaske and committed by
GitHub
675b4919 2bb6d089

+13 -7
+13 -7
apps/dashboard/src/components/forms/notifications/form-pagerduty.tsx
··· 71 71 72 72 useEffect(() => { 73 73 if (searchConfig) { 74 - const data = PagerDutySchema.safeParse(searchConfig); 74 + const data = PagerDutySchema.safeParse(JSON.parse(searchConfig)); 75 75 if (data.success) { 76 76 form.setValue("data", JSON.stringify(data.data)); 77 77 } else { ··· 110 110 try { 111 111 const provider = form.getValues("provider"); 112 112 const data = form.getValues("data"); 113 - const promise = config[provider].sendTest( 114 - data as unknown as { 115 - url: string; 116 - integrationKey: string; 117 - }, 118 - ); 113 + if (!data) { 114 + toast.error("No PagerDuty configuration found"); 115 + return; 116 + } 117 + const validation = PagerDutySchema.safeParse(JSON.parse(data)); 118 + if (!validation.success) { 119 + toast.error("Invalid PagerDuty configuration"); 120 + return; 121 + } 122 + const promise = config[provider].sendTest({ 123 + integrationKey: validation.data.integration_keys[0].integration_key, 124 + }); 119 125 toast.promise(promise, { 120 126 loading: "Sending test...", 121 127 success: "Test sent",