-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from vidyaaKhandekar/metabase-dashboard
Task #234692-Integrate Public Metabase URL in Profile Section
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
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
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,52 @@ | ||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"; | ||
import { useRouter } from "next/router"; | ||
import { useEffect, useState } from "react"; | ||
|
||
const Dashboard = () => { | ||
const router = useRouter(); | ||
const { userId } = router.query; | ||
const [isError, setIsError] = useState(false); | ||
|
||
// Validate userId | ||
useEffect(() => { | ||
if (!userId) { | ||
setIsError(true); | ||
} | ||
}, [userId]); | ||
|
||
const metabaseUrl = `${process.env.NEXT_PUBLIC_METABASE_URL}${userId}`; | ||
|
||
return ( | ||
<div> | ||
{isError ? ( | ||
<p style={{ fontWeight: "bold" }}> | ||
User ID is missing. Please go back and try again. | ||
</p> | ||
) : ( | ||
<iframe | ||
src={metabaseUrl} | ||
width="100%" | ||
height="600px" | ||
style={{ border: "none" }} | ||
onError={() => setIsError(true)} // Handle iframe load failure | ||
title="metabase-dashboard" | ||
/> | ||
)} | ||
|
||
{isError && ( | ||
<p> | ||
Dashboard not available. Please check your access or try again later. | ||
</p> | ||
)} | ||
</div> | ||
); | ||
}; | ||
export async function getStaticProps({ locale }: any) { | ||
return { | ||
props: { | ||
...(await serverSideTranslations(locale, ["common"])), | ||
}, | ||
}; | ||
} | ||
|
||
export default Dashboard; |