fix-default-picture-url (#11779)

Fixing the default avatar picture in /settings/profile
This commit is contained in:
Guillim
2025-04-29 10:30:05 +02:00
committed by GitHub
parent 23d71915f6
commit 4833ee2914
2 changed files with 10 additions and 6 deletions

View File

@ -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 }] =

View File

@ -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} />