From 8464d65358376e2d3b9d65fa932486890eb5f9f1 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Wed, 10 Aug 2022 17:48:58 +0300 Subject: [PATCH 1/2] feat: add toasts to the profile updating page --- package-lock.json | 25 +++++++++-- package.json | 1 + src/Components/VoteButton/VoteButton.tsx | 2 +- .../SaveChangesCard/SaveChangesCard.tsx | 9 +++- .../UpdateMyProfileCard.tsx | 18 ++++---- src/services/notifications.service.ts | 44 +++++++++++++++++-- src/utils/Wrapper.tsx | 8 ++++ src/utils/hooks/useVote/useVote.tsx | 8 ++-- 8 files changed, 94 insertions(+), 21 deletions(-) diff --git a/package-lock.json b/package-lock.json index c24518c..c57e2a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -82,6 +82,7 @@ "react-router-dom": "^6.3.0", "react-scripts": "5.0.1", "react-select": "^5.3.2", + "react-toastify": "^9.0.8", "react-tooltip": "^4.2.21", "react-topbar-progress-indicator": "^4.1.1", "remirror": "^1.0.77", @@ -19587,7 +19588,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz", "integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==", - "dev": true, "engines": { "node": ">=6" } @@ -60696,6 +60696,18 @@ "react": "^16.8.0 || ^17.0.0" } }, + "node_modules/react-toastify": { + "version": "9.0.8", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.0.8.tgz", + "integrity": "sha512-EwM+teWt49HSHx+67qI08yLAW1zAsBxCXLCsUfxHYv1W7/R3ZLhrqKalh7j+kjgPna1h5LQMSMwns4tB4ww2yQ==", + "dependencies": { + "clsx": "^1.1.1" + }, + "peerDependencies": { + "react": ">=16", + "react-dom": ">=16" + } + }, "node_modules/react-tooltip": { "version": "4.2.21", "resolved": "https://registry.npmjs.org/react-tooltip/-/react-tooltip-4.2.21.tgz", @@ -83039,8 +83051,7 @@ "clsx": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz", - "integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==", - "dev": true + "integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==" }, "co": { "version": "4.6.0", @@ -114215,6 +114226,14 @@ "use-latest": "^1.0.0" } }, + "react-toastify": { + "version": "9.0.8", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.0.8.tgz", + "integrity": "sha512-EwM+teWt49HSHx+67qI08yLAW1zAsBxCXLCsUfxHYv1W7/R3ZLhrqKalh7j+kjgPna1h5LQMSMwns4tB4ww2yQ==", + "requires": { + "clsx": "^1.1.1" + } + }, "react-tooltip": { "version": "4.2.21", "resolved": "https://registry.npmjs.org/react-tooltip/-/react-tooltip-4.2.21.tgz", diff --git a/package.json b/package.json index 330a812..dd0041d 100644 --- a/package.json +++ b/package.json @@ -77,6 +77,7 @@ "react-router-dom": "^6.3.0", "react-scripts": "5.0.1", "react-select": "^5.3.2", + "react-toastify": "^9.0.8", "react-tooltip": "^4.2.21", "react-topbar-progress-indicator": "^4.1.1", "remirror": "^1.0.77", diff --git a/src/Components/VoteButton/VoteButton.tsx b/src/Components/VoteButton/VoteButton.tsx index 7d49c20..7defb67 100644 --- a/src/Components/VoteButton/VoteButton.tsx +++ b/src/Components/VoteButton/VoteButton.tsx @@ -55,7 +55,7 @@ type BtnState = 'ready' | 'voting' | 'loading' | "success" | "fail"; export default function VoteButton({ votes, onVote = () => { }, - fillType = 'leftRight', + fillType = 'background', direction = 'horizontal', disableCounter = false, disableShake = true, diff --git a/src/features/Profiles/pages/EditProfilePage/SaveChangesCard/SaveChangesCard.tsx b/src/features/Profiles/pages/EditProfilePage/SaveChangesCard/SaveChangesCard.tsx index c1d72f7..3476113 100644 --- a/src/features/Profiles/pages/EditProfilePage/SaveChangesCard/SaveChangesCard.tsx +++ b/src/features/Profiles/pages/EditProfilePage/SaveChangesCard/SaveChangesCard.tsx @@ -26,6 +26,12 @@ export default function SaveChangesCard(props: Props) { if (!profileQuery.data?.profile) return <> + + const clickCancel = () => { + if (window.confirm('You might lose some unsaved changes. Are you sure you want to continue?')) + props.onCancel?.() + } + return (
@@ -45,14 +51,13 @@ export default function SaveChangesCard(props: Props) { ) diff --git a/src/Components/Navbar/NavMobile.tsx b/src/Components/Navbar/NavMobile.tsx index db03d3b..0e32380 100644 --- a/src/Components/Navbar/NavMobile.tsx +++ b/src/Components/Navbar/NavMobile.tsx @@ -151,20 +151,8 @@ export default function NavMobile() { >
toggleDrawerOpen(false)} /> - { - !curUser && - - }
-
    +
    • toggleDrawerOpen(false)} className='font-medium flex gap-16 !rounded-12 ' > -
      - ✍🏼 +
      + ✍🏼

      @@ -214,8 +202,8 @@ export default function NavMobile() { className='font-medium flex gap-16 !rounded-12 opacity-60' > -

      - 💬 +
      + 💬

      @@ -231,8 +219,8 @@ export default function NavMobile() { onClick={() => toggleDrawerOpen(false)} className='font-medium flex gap-16 !rounded-12' > -

      - 🏆 +
      + 🏆

      @@ -264,14 +252,15 @@ export default function NavMobile() { Donate

    • -
    • - toggleDrawerOpen(false)} - className='text-body4 font-bold hover:text-primary-600'> - Logout 👋 - -
    • + {curUser && +
    • + toggleDrawerOpen(false)} + className='text-body4 font-bold hover:text-primary-600'> + Logout 👋 + +
    • }