Skip to content

Commit

Permalink
Merge pull request #902 from DalgoT4D/elementary-report
Browse files Browse the repository at this point in the history
endpoint for elementary report
  • Loading branch information
fatchat authored May 21, 2024
2 parents 5dda6f4 + d292693 commit 7f2edfe
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/components/DBT/Elementary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React, { useEffect, useState } from 'react';
import styles from '@/styles/Home.module.css';
import { useSession } from 'next-auth/react';
import { backendUrl } from '@/config/constant';
import { Card, Typography } from '@mui/material';
import { httpPost } from '@/helpers/http';

export const Elementary = () => {
const [elementaryToken, setElementaryToken] = useState<string>('');
const { data: session }: any = useSession();

const fetchElementaryToken = async () => {
if (!session) return;
try {
const response = await httpPost(
session,
'dbt/make-elementary-report/',
{}
);
if (response.token) {
setElementaryToken(response.token);
}
} catch (err: any) {
console.error(err);
// don't show errorToast
}
};

useEffect(() => {
fetchElementaryToken();
}, []);

return (
<>
{elementaryToken && (
<main className={styles.analysis}>
<iframe
src={backendUrl + `/elementary/${elementaryToken}`}
width={'100%'}
height={'800px'}
style={{ border: 0 }}
></iframe>
</main>
)}
{!elementaryToken && (
<Card
sx={{
background: 'white',
display: 'flex',
borderRadius: '8px',
padding: '16px',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<Typography variant="h6">No Elementary report available</Typography>
</Card>
)}
</>
);
};
5 changes: 5 additions & 0 deletions src/pages/elementary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Elementary } from '@/components/DBT/Elementary';

export default function ElementaryHolder() {
return <Elementary />;
}

0 comments on commit 7f2edfe

Please sign in to comment.