Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replaced react-toastify with sonner lib #242

Merged
merged 6 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
],
"dependencies": {
"@reduxjs/toolkit": "~1.9.5",
"@types/node": "20.4.10",
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"@tiptap/pm": "~2.1.16",
"@tiptap/react": "~2.1.16",
"@tiptap/starter-kit": "~2.1.16",
"@types/node": "20.4.10",
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"appwrite": "11.0.1",
"autoprefixer": "10.4.14",
"eslint": "8.47.0",
Expand All @@ -61,6 +61,7 @@
"react-toastify": "~9.1.3",
"resend": "2.1.0",
"sharp": "0.33.1",
"sonner": "^1.4.0",
"tailwindcss": "3.3.3",
"typescript": "5.1.6"
},
Expand Down
21 changes: 10 additions & 11 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import "@/styles/globals.css";
import { Poppins } from "next/font/google";
import { Metadata } from "next";
import ReduxProvider from "@/redux/ReduxProvider";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
// import { ToastContainer } from "react-toastify";
// import "react-toastify/dist/ReactToastify.css";
import { Toaster } from "sonner";

import { Providers } from "./providers";

const poppinsFont = Poppins({
Expand Down Expand Up @@ -50,16 +52,13 @@ export default async function RootLayout({ children }: { children: React.ReactNo
<body
className={`${poppinsFont.className} scrollbar-thin scrollbar-thumb-primary scrollbar-track-secondary-light scrollbar-track-rounded-full bg-white dark:bg-secondary`}
>
<ToastContainer
<Toaster
position="top-right"
autoClose={3000}
hideProgressBar={false}
newestOnTop={false}
closeOnClick
pauseOnFocusLoss={false}
draggable
pauseOnHover={false}
theme="colored"
duration={3000}
closeButton={true}
richColors
expand
theme="light"
/>
<Providers>
<ReduxProvider>{children}</ReduxProvider>
Expand Down
34 changes: 26 additions & 8 deletions src/helper/toastify.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
import "react-toastify/dist/ReactToastify.css";

import { toast } from "react-toastify";
import type { TypeOptions } from "react-toastify";
import { toast } from "sonner";

// import { toast } from "react-toastify";
// import type { TypeOptions } from "react-toastify";

type ToastTypes = 'success' | 'info' | 'warning' | 'error';


/**
* @work create a toastify by parsing the following values
* @param {String} text
* @param {TypeOptions} statusType
* @param {boolean} loadingStatus
* @returns
*/
export function toastify(text: string, statusType: TypeOptions, loadingStatus: boolean = false) {
return toast(text, {
type: statusType,
isLoading: loadingStatus,
});

export function toastify(text: string, statusType: ToastTypes) {
Sanchitbajaj02 marked this conversation as resolved.
Show resolved Hide resolved
switch (statusType) {
case 'success':
return toast.success(text)
break;
case 'info':
return toast.info(text)
break;
case 'error':
return toast.success(text)
break;
case 'warning':
return toast.success(text)
break;
default:
return toast.message(text)
break;
}
}
17 changes: 11 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1720,9 +1720,9 @@ dot-prop@^5.1.0:
is-obj "^2.0.0"

dotenv@^16.3.1:
version "16.4.1"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.1.tgz#1d9931f1d3e5d2959350d1250efab299561f7f11"
integrity sha512-CjA3y+Dr3FyFDOAMnxZEGtnW9KBR2M0JvvUtXNW+dYJL5ROWxP9DUHCwgFqpMk0OXCc0ljhaNTr2w/kutYIcHQ==
version "16.4.2"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.2.tgz#7ca798f89ae2011846bbdbf6470785307754120d"
integrity sha512-rZSSFxke7d9nYQ5NeMIwp5PP+f8wXgKNljpOb7KtH6SKW1cEqcXAz9VSJYVLKe7Jhup/gUYOkaeSVyK8GJ+nBg==

eastasianwidth@^0.2.0:
version "0.2.0"
Expand Down Expand Up @@ -2513,9 +2513,9 @@ has-tostringtag@^1.0.0, has-tostringtag@^1.0.1:
has-symbols "^1.0.3"

hasown@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.0.tgz#f4c513d454a57b7c7e1650778de226b11700546c"
integrity sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==
version "2.0.1"
resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.1.tgz#26f48f039de2c0f8d3356c223fb8d50253519faa"
integrity sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==
dependencies:
function-bind "^1.1.2"

Expand Down Expand Up @@ -4491,6 +4491,11 @@ slice-ansi@^7.0.0:
ansi-styles "^6.2.1"
is-fullwidth-code-point "^5.0.0"

sonner@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/sonner/-/sonner-1.4.0.tgz#f71b0576909043f6b32f05ff796c86ef6b97350a"
integrity sha512-nvkTsIuOmi9e5Wz5If8ldasJjZNVfwiXYijBi2dbijvTQnQppvMcXTFNxL/NUFWlI2yJ1JX7TREDsg+gYm9WyA==

source-map-js@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.0.2.tgz#adbc361d9c62df380125e7f161f71c826f1e490c"
Expand Down
Loading