-
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
1 parent
7967a4b
commit d71e8c2
Showing
11 changed files
with
162 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createContext } from "react"; | ||
|
||
/** | ||
* システムメッセージコンテキスト。 | ||
*/ | ||
const SystemMessageContext = createContext({ | ||
showSystemMessage: (status: "success" | "error", message: string) => {} | ||
}); | ||
export default SystemMessageContext; |
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,49 @@ | ||
import SystemMessageContext from "./system-message-context"; | ||
import { ReactNode } from "react"; | ||
import toast, { Toaster, useToaster } from "react-hot-toast"; | ||
|
||
/** | ||
* システムメッセージプロバイダー。 | ||
* @param children 子要素。 | ||
* @returns システムメッセージプロバイダー。 | ||
*/ | ||
const SystemMessageProvider = ({ | ||
children, | ||
}: { | ||
children: ReactNode, | ||
}) => { | ||
const showSystemMessage = (status: "success" | "error", message: string) => { | ||
if (!message) return; | ||
switch (status) { | ||
case "success": | ||
toast.success(message); | ||
break; | ||
case "error": | ||
toast.error(message); | ||
break; | ||
} | ||
}; | ||
|
||
return ( | ||
<SystemMessageContext.Provider value={{ showSystemMessage }}> | ||
{children} | ||
<Toaster | ||
position="bottom-right" | ||
toastOptions={{ | ||
className: "", | ||
style: { | ||
background: "#363636", | ||
color: "#fff", | ||
}, | ||
success: { | ||
duration: 3000, | ||
}, | ||
error: { | ||
duration: 4000, | ||
}, | ||
}} | ||
/> | ||
</SystemMessageContext.Provider> | ||
); | ||
}; | ||
export default SystemMessageProvider; |
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
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
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
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
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