contacts refactoring
parent
3d05804625
commit
23acd4dcf2
|
@ -1,6 +1,5 @@
|
||||||
import React, { useMemo } from "react";
|
import React, { useMemo } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { Grid } from "@material-ui/core";
|
|
||||||
import UserProfilePicture from "./UserProfilePicture";
|
import UserProfilePicture from "./UserProfilePicture";
|
||||||
import ContactOptions from "../contact/ContactOptions";
|
import ContactOptions from "../contact/ContactOptions";
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
|
@ -34,14 +33,7 @@ const UserProfileCardContent = ({ userData }) => {
|
||||||
return (
|
return (
|
||||||
<div className={classes.panel}>
|
<div className={classes.panel}>
|
||||||
<UserProfilePicture pictureUrl={userData.profilePictureUrl} />
|
<UserProfilePicture pictureUrl={userData.profilePictureUrl} />
|
||||||
<Grid container spacing={2}>
|
<ContactOptions contactOptions={_contactOptions} userName={userName} />
|
||||||
<Grid item xs={12} sm={6}>
|
|
||||||
<ContactOptions
|
|
||||||
contactOptions={_contactOptions}
|
|
||||||
userName={userName}
|
|
||||||
/>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
import React from "react";
|
||||||
|
import PropTypes from "prop-types";
|
||||||
|
import { List } from "@material-ui/core";
|
||||||
|
import ContactOption from "./ContactOption";
|
||||||
|
|
||||||
|
const ContactOptionList = ({ options }) => {
|
||||||
|
return (
|
||||||
|
<List>
|
||||||
|
{options.map((z, index) => (
|
||||||
|
<ContactOption
|
||||||
|
key={`contact_${index}_${z.id}`}
|
||||||
|
icon={z.icon}
|
||||||
|
tooltip={z.tooltip}
|
||||||
|
label={z.label}
|
||||||
|
link={z.link}
|
||||||
|
onClick={z.onClick}
|
||||||
|
onIconClick={z.onIconClick}
|
||||||
|
iconTooltip={z.iconTooltip}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ContactOptionList.propTypes = {
|
||||||
|
options: PropTypes.array.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ContactOptionList;
|
|
@ -1,8 +1,8 @@
|
||||||
import React, { useCallback, useMemo } from "react";
|
import React, { useCallback, useMemo } from "react";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { List } from "@material-ui/core";
|
import { Grid } from "@material-ui/core";
|
||||||
import ContactOption from "./ContactOption";
|
import ContactOptionList from "./ContactOptionList";
|
||||||
import BusinessCenterIcon from "@material-ui/icons/BusinessCenter";
|
import BusinessCenterIcon from "@material-ui/icons/BusinessCenter";
|
||||||
import EmailIcon from "@material-ui/icons/Email";
|
import EmailIcon from "@material-ui/icons/Email";
|
||||||
import PhoneAndroidIcon from "@material-ui/icons/PhoneAndroid";
|
import PhoneAndroidIcon from "@material-ui/icons/PhoneAndroid";
|
||||||
|
@ -42,11 +42,12 @@ const orderNumbers = {
|
||||||
PHONE: 3,
|
PHONE: 3,
|
||||||
CURRICULUM_VITAE: 4,
|
CURRICULUM_VITAE: 4,
|
||||||
LINKEDIN: 5,
|
LINKEDIN: 5,
|
||||||
GITEA: 6,
|
PROFILE_PICTURE: 6,
|
||||||
GITHUB: 7,
|
GITEA: 7,
|
||||||
BLOG: 8,
|
GITHUB: 8,
|
||||||
WEBSITE: 9,
|
BLOG: 9,
|
||||||
REDDIT: 10,
|
WEBSITE: 10,
|
||||||
|
REDDIT: 12,
|
||||||
DEFAULT: 100
|
DEFAULT: 100
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -84,6 +85,15 @@ const handleEmailSending = email => event => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const chunkSize = 6;
|
||||||
|
const sliceContactOptions = options => {
|
||||||
|
const chunks = [];
|
||||||
|
for (let i = 0; i < options.length; i += chunkSize) {
|
||||||
|
chunks.push(options.slice(i, i + chunkSize));
|
||||||
|
}
|
||||||
|
return chunks;
|
||||||
|
};
|
||||||
|
|
||||||
const ContactOptions = ({ contactOptions, userName }) => {
|
const ContactOptions = ({ contactOptions, userName }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { copy } = useClipboard();
|
const { copy } = useClipboard();
|
||||||
|
@ -127,6 +137,7 @@ const ContactOptions = ({ contactOptions, userName }) => {
|
||||||
const { onIconClick, iconTooltip } = getIconClickEvent(co);
|
const { onIconClick, iconTooltip } = getIconClickEvent(co);
|
||||||
const orderNo = getOrderNumber(co);
|
const orderNo = getOrderNumber(co);
|
||||||
const option = {
|
const option = {
|
||||||
|
id: co.id,
|
||||||
icon,
|
icon,
|
||||||
tooltip: t(tooltip),
|
tooltip: t(tooltip),
|
||||||
label,
|
label,
|
||||||
|
@ -146,21 +157,16 @@ const ContactOptions = ({ contactOptions, userName }) => {
|
||||||
[enrichedContactOptions]
|
[enrichedContactOptions]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const chunks = useMemo(() => sliceContactOptions(sorted), [sorted]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List>
|
<Grid container>
|
||||||
{sorted.map((z, index) => (
|
{chunks.map((chunk, index) => (
|
||||||
<ContactOption
|
<Grid item xs={12} md={6} key={index}>
|
||||||
key={`contact_${index}`}
|
<ContactOptionList options={chunk} />
|
||||||
icon={z.icon}
|
</Grid>
|
||||||
tooltip={z.tooltip}
|
|
||||||
label={z.label}
|
|
||||||
link={z.link}
|
|
||||||
onClick={z.onClick}
|
|
||||||
onIconClick={z.onIconClick}
|
|
||||||
iconTooltip={z.iconTooltip}
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</List>
|
</Grid>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue