Edit profile

This commit is contained in:
Josh Perez 2021-07-19 15:26:06 -04:00 committed by GitHub
parent f14c426170
commit cd35a29638
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 2124 additions and 356 deletions

View file

@ -18,12 +18,13 @@ import { LocalizerType } from '../types/Util';
import { Spinner } from './Spinner';
import { canvasToArrayBuffer } from '../util/canvasToArrayBuffer';
type PropsType = {
export type PropsType = {
// This ID needs to be globally unique across the app.
contextMenuId: string;
disabled?: boolean;
i18n: LocalizerType;
onChange: (value: undefined | ArrayBuffer) => unknown;
type?: AvatarInputType;
value: undefined | ArrayBuffer;
variant?: AvatarInputVariant;
};
@ -34,6 +35,11 @@ enum ImageStatus {
HasImage = 'has-image',
}
export enum AvatarInputType {
Profile = 'Profile',
Group = 'Group',
}
export enum AvatarInputVariant {
Light = 'light',
Dark = 'dark',
@ -44,6 +50,7 @@ export const AvatarInput: FunctionComponent<PropsType> = ({
disabled,
i18n,
onChange,
type,
value,
variant = AvatarInputVariant.Light,
}) => {
@ -96,9 +103,14 @@ export const AvatarInput: FunctionComponent<PropsType> = ({
};
}, [processingFile, onChange]);
const buttonLabel = value
? i18n('AvatarInput--change-photo-label')
: i18n('AvatarInput--no-photo-label--group');
let buttonLabel = i18n('AvatarInput--change-photo-label');
if (!value) {
if (type === AvatarInputType.Profile) {
buttonLabel = i18n('AvatarInput--no-photo-label--profile');
} else {
buttonLabel = i18n('AvatarInput--no-photo-label--group');
}
}
const startUpload = () => {
const fileInput = fileInputRef.current;