fix-default-picture-url (#11779)
Fixing the default avatar picture in /settings/profile
This commit is contained in:
@ -5,9 +5,9 @@ import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMembe
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord';
|
||||
import { ImageInput } from '@/ui/input/components/ImageInput';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useUploadProfilePictureMutation } from '~/generated/graphql';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const ProfilePictureUploader = () => {
|
||||
const [uploadPicture, { loading: isUploading }] =
|
||||
|
||||
@ -3,11 +3,11 @@ import styled from '@emotion/styled';
|
||||
import { Trans, useLingui } from '@lingui/react/macro';
|
||||
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import React from 'react';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
import React, { useState } from 'react';
|
||||
import { getImageAbsoluteURI, isDefined } from 'twenty-shared/utils';
|
||||
import { Button } from 'twenty-ui/input';
|
||||
import { IconPhotoUp, IconTrash, IconUpload, IconX } from 'twenty-ui/display';
|
||||
import { Button } from 'twenty-ui/input';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
display: flex;
|
||||
@ -113,6 +113,7 @@ export const ImageInput = ({
|
||||
const onUploadButtonClick = () => {
|
||||
hiddenFileInput.current?.click();
|
||||
};
|
||||
const [isPictureURLError, setIsPictureURLError] = useState(false);
|
||||
|
||||
const pictureURI = isNonEmptyString(picture)
|
||||
? getImageAbsoluteURI({
|
||||
@ -128,10 +129,13 @@ export const ImageInput = ({
|
||||
disabled={disabled}
|
||||
onClick={onUploadButtonClick}
|
||||
>
|
||||
{pictureURI ? (
|
||||
{pictureURI && !isPictureURLError ? (
|
||||
<img
|
||||
src={pictureURI || '/images/default-profile-picture.png'}
|
||||
src={pictureURI}
|
||||
alt="profile"
|
||||
onError={() => {
|
||||
setIsPictureURLError(true);
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<IconPhotoUp size={theme.icon.size.lg} />
|
||||
|
||||
Reference in New Issue
Block a user