From c4468bd6e12c92e8eca50b82589b5f5085c084b1 Mon Sep 17 00:00:00 2001 From: kunalmkv <138765481+cd-nikhil@users.noreply.github.com> Date: Sun, 10 Dec 2023 04:09:58 +0530 Subject: [PATCH 1/2] frontend-nikhil-fixing-profilechanges --- frontend/src/components/Navbar.jsx | 4 +--- frontend/src/components/PortfolioDetails.jsx | 7 +++---- frontend/src/pages/ProfilePage.jsx | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/Navbar.jsx b/frontend/src/components/Navbar.jsx index 109bfca..b766e26 100644 --- a/frontend/src/components/Navbar.jsx +++ b/frontend/src/components/Navbar.jsx @@ -41,16 +41,14 @@ const Navbar = () => { onSubmit={(e) => { e.preventDefault(); navigate(`/profile/${search}`); - console.log('search'); }} onKeyDown={handleKeyDown} - /> {/* Button on the Right */} - + {/* */} ); diff --git a/frontend/src/components/PortfolioDetails.jsx b/frontend/src/components/PortfolioDetails.jsx index 628660f..e736cab 100644 --- a/frontend/src/components/PortfolioDetails.jsx +++ b/frontend/src/components/PortfolioDetails.jsx @@ -12,12 +12,11 @@ import { useUserStore } from "../store/userStore"; import { getPortfolioDetails, getTokenDetails } from "../api/profile.api"; -const PortfolioDetails = () => { +const PortfolioDetails = ({searchId}) => { const [suppliedDetails, setSuppliedDetails] = useState([]); const [borrowedDetails, setBorrowedDetails] = useState([]); let userAddress = useUserStore((state) => state.userAddress); userAddress = "0xb63e8a8d04999500a97470769d10c4395789836d"; - const convertSuppliedToDesiredFormat = async (array) => { try { const result = await Promise.all( @@ -73,7 +72,7 @@ const PortfolioDetails = () => { }; const callApis = async () => { - const details = await getPortfolioDetails(userAddress); + const details = await getPortfolioDetails(searchId); const { metadata } = details[0]; const { supplied, borrowed } = metadata; const derivedSupplied = await convertSuppliedToDesiredFormat(supplied); @@ -83,7 +82,7 @@ const PortfolioDetails = () => { }; useEffect(() => { callApis(); - }, []); + }, [searchId]); // console.log(suppliedDetails); return ( diff --git a/frontend/src/pages/ProfilePage.jsx b/frontend/src/pages/ProfilePage.jsx index 32add6b..8138bf3 100644 --- a/frontend/src/pages/ProfilePage.jsx +++ b/frontend/src/pages/ProfilePage.jsx @@ -18,6 +18,7 @@ const ProfilePage = () => { const handleTabChange = (event, newValue) => { setCurrentTab(newValue); }; + const searchId=window.location.pathname.split('/')[2]; return ( <> @@ -78,7 +79,7 @@ const ProfilePage = () => { {currentTab === 0 && (
- +
)} From 78a1e11e40d901d79ad91c1e7587ddb6485695c4 Mon Sep 17 00:00:00 2001 From: kunalmkv Date: Sun, 10 Dec 2023 04:34:15 +0530 Subject: [PATCH 2/2] discord alert added --- .../src/components/ConnectWalltet/Walltet.jsx | 3 +- .../src/components/Onboarding/Onboarding.jsx | 36 +++++++++++++++++-- frontend/yarn.lock | 5 --- 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/ConnectWalltet/Walltet.jsx b/frontend/src/components/ConnectWalltet/Walltet.jsx index ab57ccf..1a49e77 100644 --- a/frontend/src/components/ConnectWalltet/Walltet.jsx +++ b/frontend/src/components/ConnectWalltet/Walltet.jsx @@ -19,8 +19,7 @@ const ConnectWalletButton = ({ }} disabled > -
Loading...
+ Loading... ) : (
{ const [selectedProtocols, setSelectedProtocols] = useState([]); const [slackWebhook, setSlackWebhook] = useState(''); const [emailAddress, setEmailAddress] = useState(''); + const [discordWebhook, setDiscordWebhook] = useState(''); const handleClose = () => { setOpen(false); }; @@ -35,6 +36,11 @@ const Onboarding = ({ open, setOpen, signer }) => { event.stopPropagation(); setEmailAddress(event.target.value); }; + const handleDiscordWebhookChange = (event) => { + event.preventDefault(); + event.stopPropagation(); + setDiscordWebhook(event.target.value); + } const handleNext = async () => { if (selectedProtocols.includes('Slack') && !slackWebhook) { @@ -43,7 +49,7 @@ const Onboarding = ({ open, setOpen, signer }) => { } selectedProtocols.includes('Slack') && axios.post('https://finsafe-backend.insidefi.io/alert/slack/subscribe', { webhook: slackWebhook }, { headers: { 'Content-Type': 'application/json', authorization: `Bearer ${localStorage.getItem('token')}` } }); - + selectedProtocols.includes('Discord') && axios.post('https://finsafe-backend.insidefi.io/alert/discord/subscribe', { webhook: discordWebhook }, { headers: { 'Content-Type': 'application/json', authorization: `Bearer ${localStorage.getItem('token')}` } }); if (selectedProtocols.includes('Email') && !emailAddress) { alert('Please enter email address'); return; @@ -82,7 +88,7 @@ const Onboarding = ({ open, setOpen, signer }) => { width: '100%', }} > -

Select Push Protocols

+

Select Alert Prefrences

{ value="Alerts" /> } - label="Alerts" + label="Push Protocol Alerts" + /> + + } + label="Discord" /> { />
)} + {selectedProtocols.includes('Discord') && ( +
+ handleDiscordWebhookChange(e)} + /> +
+ )} + {selectedProtocols.includes('Email') && (
diff --git a/frontend/yarn.lock b/frontend/yarn.lock index 0d4f80d..0573051 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -6184,11 +6184,6 @@ fs.realpath@^1.0.0: resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@^2.3.2, fsevents@~2.3.2: - version "2.3.3" - resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" - integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== - function-bind@^1.1.1, function-bind@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"