-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
7 changed files
with
181 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,17 +1,22 @@ | ||
"use client"; // Add this line to indicate the file is a client component | ||
|
||
import { Inter } from "next/font/google"; | ||
import "./globals.css"; | ||
import { useEffect } from "react"; | ||
|
||
import { Toaster } from "@/components/ui/sonner"; | ||
|
||
export default function RootLayout({ children }) { | ||
useEffect(() => { | ||
document.documentElement.classList.add("dark"); | ||
}, []); | ||
|
||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
<head /> | ||
<body> | ||
<main>{children}</main> | ||
<Toaster /> | ||
</body> | ||
</html> | ||
); | ||
} |
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,39 @@ | ||
"use client"; | ||
import { toast } from "sonner"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
import formatCurrentDate from "@/utils/helper"; | ||
|
||
/** | ||
* @typedef {Object} ActionButtonProps | ||
* @property {string} toast_message - the message to be displayed on on the toast popup | ||
* @property {string} cta_button - the call to action to be displayed on the button | ||
*/ | ||
|
||
/** | ||
* ActionButton component | ||
* @param {ActionButtonProps} actionButtonProps | ||
* @returns {JSX.Element} | ||
*/ | ||
export function ActionButton({ toast_message, cta_button }) { | ||
return ( | ||
<Button | ||
variant="outline" | ||
onClick={() => | ||
toast( | ||
toast_message, | ||
{ | ||
description: formatCurrentDate(), | ||
action: { | ||
label: "Ok", | ||
// onClick: () => console.log("Undo"), | ||
}, | ||
}, | ||
console.log("Event has been recorded"), | ||
) | ||
} | ||
> | ||
{cta_button} | ||
</Button> | ||
); | ||
} |
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,29 @@ | ||
"use client"; | ||
import { useTheme } from "next-themes" | ||
import { Toaster as Sonner } from "sonner" | ||
|
||
const Toaster = ({ | ||
...props | ||
}) => { | ||
const { theme = "system" } = useTheme() | ||
|
||
return ( | ||
(<Sonner | ||
theme={theme} | ||
className="toaster group" | ||
toastOptions={{ | ||
classNames: { | ||
toast: | ||
"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg", | ||
description: "group-[.toast]:text-muted-foreground", | ||
actionButton: | ||
"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground", | ||
cancelButton: | ||
"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground", | ||
}, | ||
}} | ||
{...props} />) | ||
); | ||
} | ||
|
||
export { Toaster } |
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,20 @@ | ||
/* | ||
* This function formats the current date and time in a human-readable format. | ||
* @returns {string} formattedNow - The formatted date and time in the following format | ||
* Thursday, June 20 at 2024 at 2:41 PM | ||
*/ | ||
const formatCurrentDate = () => { | ||
const options = { | ||
weekday: "long", | ||
year: "numeric", | ||
month: "long", | ||
day: "2-digit", | ||
hour: "numeric", | ||
minute: "2-digit", | ||
hour12: true, | ||
}; | ||
const now = new Date(); | ||
return now.toLocaleString("en-US", options).replace(/,([^,]*)$/, " at$1"); | ||
}; | ||
|
||
export default formatCurrentDate; |