-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8dbe7c9
commit f665fdf
Showing
4 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import prisma from '@/app/utils/prisma'; | ||
|
||
export const dynamic = 'force-dynamic'; | ||
|
||
export async function POST(request: Request) { | ||
const { flowName } = await request.json(); | ||
const errs = await prisma.flow_errors.findMany({ | ||
where: { | ||
flow_name: flowName, | ||
}, | ||
}); | ||
|
||
return new Response( | ||
JSON.stringify(errs, (_, v) => (typeof v === 'bigint' ? v.toString() : v)) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
'use client'; | ||
|
||
import { Icon } from "@/lib/Icon"; | ||
import { Prisma } from "@prisma/client"; | ||
import React, { useState, useEffect } from "react"; | ||
import * as Popover from '@radix-ui/react-popover'; | ||
import { ProgressCircle } from "@/lib/ProgressCircle"; | ||
import styled, { css } from 'styled-components'; | ||
|
||
|
||
// const NoErrorMirror = styled.div` | ||
// color: ${({ theme }) => theme.colors.positive.fill.normal}; | ||
// `; | ||
|
||
// const ErroredMirror = styled.div` | ||
// color: ${({ theme }) => theme.colors.destructive.fill.normal}; | ||
// `; | ||
|
||
|
||
export const ErrorModal = ({ flowErrors }: { flowErrors: Prisma.flow_errorsSelect[] }) => { | ||
return ( | ||
<Icon name='error' /> | ||
); | ||
}; | ||
|
||
|
||
export const MirrorError = ({ flowName }: { flowName: string }) => { | ||
const [flowErrors, setFlowErrors] = useState<Prisma.flow_errorsSelect[]>(); | ||
const [isLoading, setIsLoading] = useState<boolean>(true); | ||
const [error, setError] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
const fetchData = async () => { | ||
setIsLoading(true); | ||
try { | ||
const response = await fetch(`/api/mirrors/alerts`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify({ flowName }), | ||
}); | ||
|
||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
|
||
const data = await response.json(); | ||
setFlowErrors(data.errors); | ||
} catch (err: any) { | ||
setError(err.message); | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
fetchData(); | ||
}, [flowName]); | ||
|
||
if (isLoading) { | ||
return <div><ProgressCircle variant="intermediate_progress_circle" /></div>; | ||
} | ||
|
||
if (error) { | ||
console.log(error); | ||
return <div><Icon name='error' /></div>; | ||
} | ||
|
||
if (!flowErrors || flowErrors.length === 0) { | ||
return <Icon name='check_circle' fill={true} />; | ||
} | ||
|
||
return <ErrorModal flowErrors={flowErrors} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters