Skip to content

Commit

Permalink
fix: fix bugs in delete family member flow
Browse files Browse the repository at this point in the history
  • Loading branch information
chennara committed Nov 21, 2023
1 parent ba93c7a commit 53c71df
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/_components/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as Styled from './style';
export type TButtonProps = {
accessibilityHint?: string;
accessibilityLabel?: string;
backgroundColor?: ThemeColor;
centered?: boolean;
children?: ReactNode;
color?: ThemeColor;
Expand Down Expand Up @@ -37,6 +38,7 @@ const Button: FC<TButtonProps> = ({
loading,
variant = 'contained',
color,
backgroundColor,
underline = true,
fontStyle = 'bold',
inline,
Expand All @@ -57,6 +59,7 @@ const Button: FC<TButtonProps> = ({
return (
<Styled.ButtonElement
$active={isActive}
$backgroundColor={backgroundColor}
$color={color}
$inline={inline}
$radius={radius}
Expand Down
6 changes: 5 additions & 1 deletion src/_components/button/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const ButtonContainer = styled.View<Pick<TButtonProps, 'inline' | 'center

export const ButtonElement = styled(TouchableRipple)<{
$active: boolean;
$backgroundColor: TButtonProps['backgroundColor'];
$color: TButtonProps['color'];
$inline: TButtonProps['inline'];
$radius: TButtonProps['radius'];
Expand All @@ -23,7 +24,10 @@ export const ButtonElement = styled(TouchableRipple)<{
align-items: center;
border-radius: ${({ $inline, $radius }) => (!$radius ? '0px' : $inline ? '24px' : '16px')};
opacity: ${({ disabled }) => (disabled ? 0.4 : 1)};
background-color: ${({ $active, $variant, theme }) => {
background-color: ${({ $active, $variant, $backgroundColor, theme }) => {
if ($backgroundColor) {
return getColor($backgroundColor);
}
if ($variant === 'contained') {
return $active ? theme.palette.primary['900'] : theme.palette.primary['700'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const DeleteFamilyMember = ({ name, familyMemberId }: TProps) => {
</Styled.Title>
<Trans i18nKey="ONBOARDING.FAMILY.DELETE_MEMBER.CONFIRMATION_MODAL.DESCRIPTION" values={{ name }} />
<Styled.DeleteButton
backgroundColor="error.700"
fontStyle="semibold"
label={t('ONBOARDING.FAMILY.DELETE_MEMBER.CONFIRMATION_MODAL.CONFIRM')}
loading={isLoading}
Expand Down
2 changes: 1 addition & 1 deletion src/onboarding/family/deleteFamilyMember/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const DeleteButtonContainer = styled.View`
`;

export const DeleteButton = styled(Button)`
margin-left: 8px;
margin-top: 32px;
`;

export const CloseButton = styled(Button)`
Expand Down
8 changes: 4 additions & 4 deletions src/onboarding/family/editFamilyMember/EditFamilyMember.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export const EditFamilyMember = ({ navigation, route }: TProps) => {
});
return avatars;
}, []);
const { mutate: editFamilyMember } = useEditFamilyMember(member.passholderId);
const { mutateAsync: editFamilyMember, isLoading } = useEditFamilyMember(member.passholderId);

const { bottom } = useSafeAreaInsets();
const { t } = useTranslation();

const handleSubmit = () => {
editFamilyMember({ body: { icon: selectedAvatar } });
const handleSubmit = async () => {
await editFamilyMember({ body: { icon: selectedAvatar } });
queryClient.invalidateQueries(['family-members']);
navigation.goBack();
};
Expand Down Expand Up @@ -77,7 +77,7 @@ export const EditFamilyMember = ({ navigation, route }: TProps) => {
)}
/>
<Styled.StickyFooter style={{ marginBottom: bottom + 16 }}>
<Button label={t('ONBOARDING.FAMILY.EDIT_MEMBER.SAVE')} onPress={handleSubmit} />
<Button label={t('ONBOARDING.FAMILY.EDIT_MEMBER.SAVE')} loading={isLoading} onPress={handleSubmit} />
</Styled.StickyFooter>
</Styled.ScreenContainer>
);
Expand Down

0 comments on commit 53c71df

Please sign in to comment.