Skip to content

Commit

Permalink
Merge pull request #936 from singnet/package-updating
Browse files Browse the repository at this point in the history
Package updating
  • Loading branch information
MarinaFedy authored Aug 15, 2024
2 parents 84933a3 + 057a9ca commit d8aa8c6
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 80 deletions.
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const App = () => {

useEffect(() => {
dispatch(userActions.fetchUserDetails());
}, []);
}, [dispatch]);

if (!isInitialized) {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/ServiceDetails/ProjectDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const ProjectDetails = ({ classes, projectURL, contributors, orgId, serviceId })
<Grid item sm={5} xs={12}>
<h5>{dataRow.label}</h5>
</Grid>
<Grid item sm={7} xs={12}>
{dataRow.value}
<Grid item sm={7} xs={12} className={classes.projectDetailsValue}>
<span>{dataRow.value}</span>
</Grid>
</Grid>
))}
Expand Down
25 changes: 25 additions & 0 deletions src/components/ServiceDetails/ProjectDetails/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@ export const useStyles = (theme) => ({
lineHeight: "22px",
},
},
projectDetailsValue: {
width: "100%",
textAlign: "left",
position: "relative",
height: "1rem",
"& span": {
width: "100%",
overflow: "hidden",
textOverflow: "ellipsis",
display: "-webkit-box",
height: "min-content",
"-webkit-line-clamp": 1,
"-webkit-box-orient": "vertical",
transition: "all 0.1s",
overflowWrap: "break-word",
},
"& span:hover": {
height: "min-content",
background: "white",
paddingBottom: 5,
"-webkit-line-clamp": 10,
borderRadius: 5,
transition: "all 0.1s",
},
},
projectURLContainer: {
"& > div": {
display: "flex",
Expand Down
3 changes: 0 additions & 3 deletions src/components/ServiceDetails/TitleCard/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ export const useStyles = (theme) => ({
margin: "0 auto",
},
},
serviceLightBox: {
position: "relative",
},
serviceImgContainer: {
boxSizing: "border-box",
width: 1045,
Expand Down
37 changes: 20 additions & 17 deletions src/components/UserProfile/UserProfileAccount/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useCallback, useEffect, useState } from "react";
import { useDispatch } from "react-redux";
import Grid from "@mui/material/Grid";
import { withStyles } from "@mui/styles";
Expand Down Expand Up @@ -36,18 +36,21 @@ const UserProfileAccount = ({ classes }) => {
return { value: address, label: `${type} (${address})`, address, type };
};

const getWallets = async (currentAddress) => {
const availableWallets = await dispatch(fetchAvailableUserWallets());
let currentWallet = availableWallets.find(({ address }) => address === currentAddress);
const enhancedWallets = availableWallets.map(({ address, type }) => parseWallet(address, type));
if (!currentWallet) {
currentWallet = parseWallet(currentAddress, walletTypes.METAMASK);
enhancedWallets.push(currentWallet);
}
setSelectedWallet(parseWallet(currentWallet.address, currentWallet.type));
dispatch(userActions.updateWallet(currentWallet));
return enhancedWallets;
};
const getWallets = useCallback(
async (currentAddress) => {
const availableWallets = await dispatch(fetchAvailableUserWallets());
let currentWallet = availableWallets.find(({ address }) => address === currentAddress);
const enhancedWallets = availableWallets.map(({ address, type }) => parseWallet(address, type));
if (!currentWallet) {
currentWallet = parseWallet(currentAddress, walletTypes.METAMASK);
enhancedWallets.push(currentWallet);
}
setSelectedWallet(parseWallet(currentWallet.address, currentWallet.type));
dispatch(userActions.updateWallet(currentWallet));
return enhancedWallets;
},
[dispatch]
);

useEffect(() => {
const fetchWallets = async () => {
Expand All @@ -66,7 +69,8 @@ const UserProfileAccount = ({ classes }) => {
}
};
fetchWallets();
}, [dispatch]);
// eslint
}, [dispatch, getWallets]);

useEffect(() => {
const getProviders = async () => {
Expand All @@ -81,7 +85,7 @@ const UserProfileAccount = ({ classes }) => {
};

getProviders();
}, [selectedWallet]);
}, [selectedWallet, dispatch]);

const isSameMetaMaskAddress = (address) => {
if (currentAddress && address) {
Expand All @@ -90,9 +94,8 @@ const UserProfileAccount = ({ classes }) => {
return false;
};

const handleWalletTypeChange = async (event) => {
const handleWalletTypeChange = (event) => {
setAlert({});

const { value: selectedValue } = event.target;
const selectedWallet = wallets.find(({ value }) => selectedValue === value);
setSelectedWallet(selectedWallet);
Expand Down
73 changes: 41 additions & 32 deletions src/components/UserProfile/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useCallback, useEffect, useMemo, useState } from "react";
import { withStyles } from "@mui/styles";
import AppBar from "@mui/material/AppBar";
import Tabs from "@mui/material/Tabs";
Expand All @@ -21,46 +21,55 @@ export const userProfileRoutes = {
// MODELS: { path: `/${Routes.USER_PROFILE}/models`, component: () => <UserProfileModels /> },
};

const tabs = {
account: {
name: "Account",
index: 0,
path: userProfileRoutes.ACCOUNT,
component: <UserProfileAccount />,
},
settings: {
name: "Settings",
index: 1,
path: userProfileRoutes.SETTINGS,
component: <UserProfileSettings />,
},
transactions: {
name: "Transactions",
index: 2,
path: userProfileRoutes.TRANSACTIONS,
component: <UserProfileTransactionHistory />,
},
};
const UserProfile = ({ classes, nickname, email }) => {
const tabs = useMemo(
() => ({
account: {
name: "Account",
index: 0,
path: userProfileRoutes.ACCOUNT,
component: <UserProfileAccount />,
},
settings: {
name: "Settings",
index: 1,
path: userProfileRoutes.SETTINGS,
component: <UserProfileSettings />,
},
transactions: {
name: "Transactions",
index: 2,
path: userProfileRoutes.TRANSACTIONS,
component: <UserProfileTransactionHistory />,
},
}),
[]
);

const tabByPath = {
[`${tabs.account.path}`]: "account",
[`${tabs.settings.path}`]: "settings",
[`${tabs.transactions.path}`]: "transactions",
};
const tabByPath = useMemo(
() => ({
[`${tabs.account.path}`]: "account",
[`${tabs.settings.path}`]: "settings",
[`${tabs.transactions.path}`]: "transactions",
}),
[tabs]
);

const UserProfile = ({ classes, nickname, email }) => {
const navigate = useNavigate();
const location = useLocation();
const [activeTab, setActiveTab] = useState(tabs.account);

const selectTab = (tab) => {
setActiveTab(tab);
navigate(tab.path);
};
const selectTab = useCallback(
(tab) => {
setActiveTab(tab);
navigate(tab.path);
},
[navigate]
);

useEffect(() => {
selectTab(tabs[tabByPath[`${location.pathname.toLowerCase()}`]]);
}, [location]);
}, [location.pathname, tabs, tabByPath, selectTab]);

return (
<div className={classes.UserProfileContainer}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/common/AppLoader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const AppLoader = ({ loading, loaderHeader, loaderText }) => {
const classes = useStyles();

return (
<Modal disableBackdropClick open={loading}>
<Modal open={loading}>
<Card className={classes.card}>
<CardHeader title={<h2>{loaderHeader}</h2>} />
<Divider />
Expand Down
22 changes: 1 addition & 21 deletions src/components/common/Header/NavItem.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,13 @@
import React from "react";
import { NavLink } from "react-router-dom";

import { useStyles } from "./styles";
import Routes from "../../../utility/constants/Routes";

const NavItem = ({ title, link }) => {
const classes = useStyles();
const isActive = (unused, { pathname }) => {
switch (link) {
case `/${Routes.AI_MARKETPLACE}`: {
if (pathname === "/" || pathname.includes(Routes.AI_MARKETPLACE)) {
return true;
}
return false;
}

default: {
return pathname === link;
}
}
};

return (
<li className={classes.navLinks}>
<NavLink
to={link || "#"}
// className={(isActive) => classes.navLinksAnchor + (isActive ? " activated" : classes.activeTab)} TODO
isActive={isActive}
>
<NavLink to={link || "#"} className={classes.navLinksAnchor}>
{title}
</NavLink>
</li>
Expand Down
1 change: 0 additions & 1 deletion src/components/common/SeoMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const SeoMetadata = (props) => {
.slice(0, totalKeywordsAllowed)
.join(",")
: undefined;
console.log("keywordsCommaDelimitedString", keywordsCommaDelimitedString);
return (
<Fragment>
<Helmet>
Expand Down
1 change: 1 addition & 0 deletions src/components/common/StyledDropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const StyledDropdown = ({ labelTxt, name, list, value, onChange, formControlProp
value={value || ""}
onChange={onChange}
name={name}
MenuProps={{ disableScrollLock: true }}
variant="outlined"
disabled={disabled}
className={classes.selectEmpty}
Expand Down
8 changes: 7 additions & 1 deletion src/components/common/StyledMenu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ const StyledMenu = ({ classes, label, list }) => {
<Button className={classes.button}>{label}</Button>
<CaretIcon />
</div>
<Menu anchorEl={anchorEl} id="simple-menu" open={Boolean(anchorEl)} onClose={handleClose}>
<Menu
anchorEl={anchorEl}
id="simple-menu"
open={Boolean(anchorEl)}
onClose={handleClose}
disableScrollLock={true}
>
{list.map((item) => (
<MenuItem key={item.label} className={classes.menuItem}>
<AnchorLink label={item.label} href={item.link} newTab={item.newTab} />
Expand Down
2 changes: 1 addition & 1 deletion src/utility/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const DEFAULT_GAS_LIMIT = 210000;
const ON_ACCOUNT_CHANGE = "accountsChanged";
const ON_NETWORK_CHANGE = "chainChanged";

const EXPECTED_ID_ETHEREUM_NETWORK = process.env.REACT_APP_ETH_NETWORK;
const EXPECTED_ID_ETHEREUM_NETWORK = Number(process.env.REACT_APP_ETH_NETWORK);

let sdk;
let channel;
Expand Down

0 comments on commit d8aa8c6

Please sign in to comment.