From a9db41de89cdfcfabf469c938c903790b17d5934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Wed, 5 Jul 2023 21:39:50 +0200 Subject: [PATCH] Use AvatarPicker/HeaderPicker on Edit Profile page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- .../api/hooks/groups/useUpdateGroup.ts | 6 +- app/soapbox/components/still-image.tsx | 2 +- .../components/avatar-picker.tsx} | 18 ++-- .../components/header-picker.tsx} | 26 ++++-- .../components/profile-preview.tsx | 49 ----------- app/soapbox/features/edit-profile/index.tsx | 85 ++++++------------- app/soapbox/features/group/edit-group.tsx | 9 +- .../manage-group-modal/steps/details-step.tsx | 8 +- app/soapbox/hooks/forms/useImageField.ts | 10 ++- app/soapbox/hooks/forms/usePreview.ts | 2 +- 10 files changed, 79 insertions(+), 136 deletions(-) rename app/soapbox/features/{group/components/group-avatar-picker.tsx => edit-profile/components/avatar-picker.tsx} (61%) rename app/soapbox/features/{group/components/group-header-picker.tsx => edit-profile/components/header-picker.tsx} (64%) delete mode 100644 app/soapbox/features/edit-profile/components/profile-preview.tsx diff --git a/app/soapbox/api/hooks/groups/useUpdateGroup.ts b/app/soapbox/api/hooks/groups/useUpdateGroup.ts index bb3a37dc2..eb69670b1 100644 --- a/app/soapbox/api/hooks/groups/useUpdateGroup.ts +++ b/app/soapbox/api/hooks/groups/useUpdateGroup.ts @@ -6,8 +6,8 @@ import { groupSchema } from 'soapbox/schemas'; interface UpdateGroupParams { display_name?: string note?: string - avatar?: File - header?: File + avatar?: File | '' | null + header?: File | '' | null group_visibility?: string discoverable?: boolean tags?: string[] @@ -30,4 +30,4 @@ function useUpdateGroup(groupId: string) { }; } -export { useUpdateGroup }; \ No newline at end of file +export { useUpdateGroup }; diff --git a/app/soapbox/components/still-image.tsx b/app/soapbox/components/still-image.tsx index cdebaf359..4a3caf01e 100644 --- a/app/soapbox/components/still-image.tsx +++ b/app/soapbox/components/still-image.tsx @@ -67,7 +67,7 @@ const StillImage: React.FC = ({ alt, className, src, style, letterb )} diff --git a/app/soapbox/features/group/components/group-avatar-picker.tsx b/app/soapbox/features/edit-profile/components/avatar-picker.tsx similarity index 61% rename from app/soapbox/features/group/components/group-avatar-picker.tsx rename to app/soapbox/features/edit-profile/components/avatar-picker.tsx index b13dfe80e..09a6b0d29 100644 --- a/app/soapbox/features/group/components/group-avatar-picker.tsx +++ b/app/soapbox/features/edit-profile/components/avatar-picker.tsx @@ -1,19 +1,25 @@ import clsx from 'clsx'; import React from 'react'; +import { FormattedMessage } from 'react-intl'; -import Icon from 'soapbox/components/icon'; -import { Avatar, HStack } from 'soapbox/components/ui'; +import { Avatar, Icon, HStack } from 'soapbox/components/ui'; interface IMediaInput { + className?: string src: string | undefined accept: string onChange: React.ChangeEventHandler disabled?: boolean } -const AvatarPicker = React.forwardRef(({ src, onChange, accept, disabled }, ref) => { +const AvatarPicker = React.forwardRef(({ className, src, onChange, accept, disabled }, ref) => { return ( -