Skip to content

Commit

Permalink
Revert "feat: Integrated Dicebear Library To Enhance Security (Palisa…
Browse files Browse the repository at this point in the history
  • Loading branch information
palisadoes authored Feb 28, 2024
1 parent da8df05 commit ebcc977
Show file tree
Hide file tree
Showing 14 changed files with 580 additions and 1,291 deletions.
1 change: 0 additions & 1 deletion __mocks__/@dicebear/collection.ts

This file was deleted.

5 changes: 0 additions & 5 deletions __mocks__/@dicebear/core.ts

This file was deleted.

2 changes: 0 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ export default {
moduleNameMapper: {
'^react-native$': 'react-native-web',
'^@mui/(.*)$': '<rootDir>/node_modules/@mui/$1',
'^@dicebear/core$': '<rootDir>/__mocks__/@dicebear/core.ts',
'^@dicebear/collection$': '<rootDir>/__mocks__/@dicebear/collection.ts',
},
moduleFileExtensions: [
'web.js',
Expand Down
1,634 changes: 514 additions & 1,120 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"@apollo/client": "^3.4.0-beta.19",
"@apollo/link-error": "^2.0.0-beta.3",
"@apollo/react-testing": "^4.0.0",
"@dicebear/collection": "^7.0.4",
"@dicebear/core": "^7.0.4",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.8.3",
Expand Down
50 changes: 0 additions & 50 deletions src/components/Avatar/Avatar.test.tsx

This file was deleted.

39 changes: 0 additions & 39 deletions src/components/Avatar/Avatar.tsx

This file was deleted.

5 changes: 2 additions & 3 deletions src/components/LeftDrawer/LeftDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import styles from './LeftDrawer.module.css';
import { useMutation } from '@apollo/client';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import useLocalStorage from 'utils/useLocalstorage';
import Avatar from 'components/Avatar/Avatar';

export interface InterfaceLeftDrawerProps {
hideDrawer: boolean | null;
Expand Down Expand Up @@ -116,8 +115,8 @@ const leftDrawer = ({
{userImage && userImage !== 'null' ? (
<img src={userImage} alt={`profile picture`} />
) : (
<Avatar
name={`${firstName} ${lastName}`}
<img
src={`https://api.dicebear.com/5.x/initials/svg?seed=${firstName}%20${lastName}`}
alt={`dummy picture`}
/>
)}
Expand Down
11 changes: 6 additions & 5 deletions src/components/LeftDrawerEvent/LeftDrawerEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { EventStatsWrapper } from 'components/EventStats/EventStatsWrapper';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import { useMutation } from '@apollo/client';
import useLocalStorage from 'utils/useLocalstorage';
import Avatar from 'components/Avatar/Avatar';

export interface InterfaceLeftDrawerProps {
event: {
Expand Down Expand Up @@ -69,8 +68,10 @@ const leftDrawerEvent = ({
<div className={styles.organizationContainer}>
<button className={styles.profileContainer} data-testid="OrgBtn">
<div className={styles.imageContainer}>
<Avatar
name={event.title.split(' ').join('%20')}
<img
src={`https://api.dicebear.com/5.x/initials/svg?seed=${event.title
.split(' ')
.join('%20')}`}
alt="Dummy Event Picture"
/>
</div>
Expand Down Expand Up @@ -134,8 +135,8 @@ const leftDrawerEvent = ({
{userImage && userImage !== 'null' ? (
<img src={userImage} alt={`Profile Picture`} />
) : (
<Avatar
name={`${firstName} ${lastName}`}
<img
src={`https://api.dicebear.com/5.x/initials/svg?seed=${firstName}%20${lastName}`}
alt={`Dummy User Picture`}
/>
)}
Expand Down
11 changes: 5 additions & 6 deletions src/components/LeftDrawerOrg/LeftDrawerOrg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { ReactComponent as TalawaLogo } from 'assets/svgs/talawa.svg';
import styles from './LeftDrawerOrg.module.css';
import { REVOKE_REFRESH_TOKEN } from 'GraphQl/Mutations/mutations';
import useLocalStorage from 'utils/useLocalstorage';
import Avatar from 'components/Avatar/Avatar';

export interface InterfaceLeftDrawerProps {
orgId: string;
Expand Down Expand Up @@ -119,9 +118,9 @@ const leftDrawerOrg = ({
{organization.image ? (
<img src={organization.image} alt={`profile picture`} />
) : (
<Avatar
name={organization.name}
alt={'Dummy Organization Picture'}
<img
src={`https://api.dicebear.com/5.x/initials/svg?seed=${organization.name}`}
alt={`Dummy Organization Picture`}
/>
)}
</div>
Expand Down Expand Up @@ -188,8 +187,8 @@ const leftDrawerOrg = ({
{userImage && userImage !== 'null' ? (
<img src={userImage} alt={`profile picture`} />
) : (
<Avatar
name={`${firstName} ${lastName}`}
<img
src={`https://api.dicebear.com/5.x/initials/svg?seed=${firstName}%20${lastName}`}
alt={`dummy picture`}
/>
)}
Expand Down
23 changes: 13 additions & 10 deletions src/components/OrgListCard/OrgListCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import LocationOnIcon from '@mui/icons-material/LocationOn';
import { IS_SAMPLE_ORGANIZATION_QUERY } from 'GraphQl/Queries/Queries';
import { useQuery } from '@apollo/client';
import { Tooltip } from '@mui/material';
import Avatar from 'components/Avatar/Avatar';

export interface InterfaceOrgListCardProps {
data: InterfaceOrgConnectionInfoType;
Expand Down Expand Up @@ -43,15 +42,19 @@ function orgListCard(props: InterfaceOrgListCardProps): JSX.Element {
<div className={styles.orgCard}>
<div className={styles.innerContainer}>
<div className={styles.orgImgContainer}>
{image ? (
<img src={image} alt={`${name} image`} />
) : (
<Avatar
name={name}
alt={`${name} image`}
dataTestId="emptyContainerForImage"
/>
)}
<img
src={
image
? image
: `https://api.dicebear.com/5.x/initials/svg?seed=${name
.split(/\s+/)
.map((word) => word.charAt(0))
.slice(0, 2)
.join('')}`
}
alt={`${name} image`}
data-testid={image ? '' : 'emptyContainerForImage'}
/>
</div>
<div className={styles.content}>
<Tooltip title={name} placement="top-end">
Expand Down
18 changes: 4 additions & 14 deletions src/components/UserPortal/ContactCard/ContactCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import styles from './ContactCard.module.css';
import Avatar from 'components/Avatar/Avatar';

interface InterfaceContactCardProps {
id: string;
Expand All @@ -15,6 +14,9 @@ interface InterfaceContactCardProps {

function contactCard(props: InterfaceContactCardProps): JSX.Element {
const contactName = `${props.firstName} ${props.lastName}`;
const imageUrl = props.image
? props.image
: `https://api.dicebear.com/5.x/initials/svg?seed=${contactName}`;

const handleSelectedContactChange = (): void => {
props.setSelectedContact(props.id);
Expand All @@ -38,19 +40,7 @@ function contactCard(props: InterfaceContactCardProps): JSX.Element {
onClick={handleSelectedContactChange}
data-testid="contactContainer"
>
{props.image ? (
<img
src={props.image}
alt={contactName}
className={styles.contactImage}
/>
) : (
<Avatar
name={contactName}
alt={contactName}
avatarStyle={styles.contactImage}
/>
)}
<img src={imageUrl} alt={contactName} className={styles.contactImage} />
<div className={styles.contactNameContainer}>
<b>{contactName}</b>
<small className={styles.grey}>{props.email}</small>
Expand Down
59 changes: 32 additions & 27 deletions src/components/UsersTableItem/UsersTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { toast } from 'react-toastify';
import { errorHandler } from 'utils/errorHandler';
import type { InterfaceQueryUserListItem } from 'utils/interfaces';
import styles from './UsersTableItem.module.css';
import Avatar from 'components/Avatar/Avatar';

type Props = {
user: InterfaceQueryUserListItem;
Expand Down Expand Up @@ -307,11 +306,14 @@ const UsersTableItem = (props: Props): JSX.Element => {
className="p-0"
onClick={() => goToOrg(org._id)}
>
{org.image ? (
<img src={org.image} alt="orgImage" />
) : (
<Avatar name={org.name} alt="orgImage" />
)}
<img
src={
org.image
? org.image
: `https://api.dicebear.com/5.x/initials/svg?seed=${org.name}`
}
alt="orgImage"
/>
{org.name}
</Button>
</td>
Expand All @@ -324,14 +326,14 @@ const UsersTableItem = (props: Props): JSX.Element => {
onClick={() => handleCreator()}
data-testid={`creator${org._id}`}
>
{org.creator.image ? (
<img src={org.creator.image} alt="creator" />
) : (
<Avatar
name={`${org.creator.firstName} ${org.creator.lastName}`}
alt="creator"
/>
)}
<img
src={
org.creator.image
? org.creator.image
: `https://api.dicebear.com/5.x/initials/svg?seed=${org.creator.firstName} ${org.creator.lastName}`
}
alt="creator"
/>
{org.creator.firstName} {org.creator.lastName}
</Button>
</td>
Expand Down Expand Up @@ -481,11 +483,14 @@ const UsersTableItem = (props: Props): JSX.Element => {
className="p-0"
onClick={() => goToOrg(org._id)}
>
{org.image ? (
<img src={org.image} alt="orgImage" />
) : (
<Avatar name={org.name} alt="orgImage" />
)}
<img
src={
org.image
? org.image
: `https://api.dicebear.com/5.x/initials/svg?seed=${org.name}`
}
alt="orgImage"
/>
{org.name}
</Button>
</td>
Expand All @@ -498,14 +503,14 @@ const UsersTableItem = (props: Props): JSX.Element => {
onClick={() => handleCreator()}
data-testid={`creator${org._id}`}
>
{org.creator.image ? (
<img src={org.creator.image} alt="creator" />
) : (
<Avatar
name={`${org.creator.firstName} ${org.creator.lastName}`}
alt="creator"
/>
)}
<img
src={
org.creator.image
? org.creator.image
: `https://api.dicebear.com/5.x/initials/svg?seed=${org.creator.firstName} ${org.creator.lastName}`
}
alt="creator"
/>
{org.creator.firstName} {org.creator.lastName}
</Button>
</td>
Expand Down
11 changes: 4 additions & 7 deletions src/screens/MemberDetail/MemberDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { toast } from 'react-toastify';
import { errorHandler } from 'utils/errorHandler';
import Loader from 'components/Loader/Loader';
import useLocalStorage from 'utils/useLocalstorage';
import Avatar from 'components/Avatar/Avatar';

const { getItem } = useLocalStorage();

Expand Down Expand Up @@ -155,12 +154,10 @@ const MemberDetail: React.FC<MemberDetailProps> = ({ id }): JSX.Element => {
data-testid="userImagePresent"
/>
) : (
<Avatar
name={`${userData?.user?.firstName} ${userData?.user?.lastName}`}
alt="User Image"
size={180}
avatarStyle={styles.userImage}
dataTestId="userImageAbsent"
<img
className={styles.userImage}
src={`https://api.dicebear.com/5.x/initials/svg?seed=${userData?.user?.firstName} ${userData?.user?.lastName}`}
data-testid="userImageAbsent"
/>
)}
</div>
Expand Down

0 comments on commit ebcc977

Please sign in to comment.