Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: subscription size action #43122

Merged
merged 10 commits into from
Jun 11, 2024
2 changes: 1 addition & 1 deletion src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3266,7 +3266,7 @@ export default {
eachMonth:
'Each month, your subscription covers up to the number of active members set above. Any time you increase your subscription size, you’ll start a new 12-month subscription at that new size.',
note: 'Note: An active member is anyone who has created, edited, submitted, approved, reimbursed, or exported expense data tied to your company workspace.',
confirmDetails: 'Confirm your new annual subscription details',
confirmDetails: 'Confirm your new annual subscription details:',
subscriptionSize: 'Subscription size',
activeMembers: ({size}) => `${size} active members/month`,
subscriptionRenews: 'Subscription renews',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3773,7 +3773,7 @@ export default {
eachMonth:
'Cada mes, tu suscripción cubre hasta el número de miembros activos establecido anteriormente. Cada vez que aumentes el tamaño de tu suscripción, iniciarás una nueva suscripción de 12 meses con ese nuevo tamaño.',
note: 'Nota: Un miembro activo es cualquiera que haya creado, editado, enviado, aprobado, reembolsado, o exportado datos de gastos vinculados al espacio de trabajo de tu empresa.',
confirmDetails: 'Confirma los datos de tu nueva suscripción anual',
confirmDetails: 'Confirma los datos de tu nueva suscripción anual:',
subscriptionSize: 'Tamaño de suscripción',
activeMembers: ({size}) => `${size} miembros activos/mes`,
subscriptionRenews: 'Renovación de la suscripción',
Expand Down
35 changes: 17 additions & 18 deletions src/pages/settings/Subscription/SubscriptionDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import Section from '@components/Section';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import Navigation from '@libs/Navigation/Navigation';
import variables from '@styles/variables';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';

type SubscriptionVariant = ValueOf<typeof CONST.SUBSCRIPTION.TYPE>;

Expand Down Expand Up @@ -44,33 +46,30 @@ function SubscriptionDetails() {
setSelectedOption(option);
};

// This section is only shown when the subscription is annual
// An onPress action is going to be assigned to these buttons in phase 2
let subscriptionSizeSection: React.JSX.Element | null = null;
const onSubscriptionSizePress = () => {
Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION_SIZE);
};

if (privateSubscription?.type === CONST.SUBSCRIPTION.TYPE.ANNUAL) {
subscriptionSizeSection = privateSubscription?.userCount ? (
<MenuItemWithTopDescription
description={translate('subscription.details.subscriptionSize')}
title={`${privateSubscription?.userCount}`}
wrapperStyle={styles.sectionMenuItemTopDescription}
style={styles.mt5}
/>
) : (
// This section is only shown when the subscription is annual
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is visible even if the subscription type is not annual:

Screen.Recording.2024-06-05.at.7.50.19.PM.mov

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I guess it does not show up if the set subscription is not annual.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Condition was checking it against data coming straight from the API. Because change is only happening on FE now (API call will be implemented in the next phase) it was not working as expected. I've updated the condition to check it against the selectedOption that we store inside state of the component. It should work as expected now.

const subscriptionSizeSection: React.JSX.Element | null =
selectedOption === CONST.SUBSCRIPTION.TYPE.ANNUAL ? (
<>
<MenuItemWithTopDescription
description={translate('subscription.details.subscriptionSize')}
shouldShowRightIcon
onPress={onSubscriptionSizePress}
wrapperStyle={styles.sectionMenuItemTopDescription}
style={styles.mt5}
title={`${privateSubscription?.userCount ?? ''}`}
/>
<Text style={styles.mt2}>
<Text style={styles.h4}>{translate('subscription.details.headsUpTitle')}</Text>
<Text style={styles.textLabelSupporting}>{translate('subscription.details.headsUpBody')}</Text>
</Text>
{!privateSubscription?.userCount && (
<Text style={styles.mt2}>
<Text style={styles.h4}>{translate('subscription.details.headsUpTitle')}</Text>
<Text style={styles.textLabelSupporting}>{translate('subscription.details.headsUpBody')}</Text>
</Text>
)}
</>
);
}
) : null;

return (
<Section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Size({onNext}: SizeProps) {

const defaultValues = {
// TODO this is temporary and default value will be replaced in next phase once data in ONYX is ready
[INPUT_IDS.SUBSCRIPTION_SIZE]: '0',
[INPUT_IDS.SUBSCRIPTION_SIZE]: '',
};

return (
Expand Down
2 changes: 1 addition & 1 deletion src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2819,7 +2819,7 @@ const styles = (theme: ThemeColors) =>
},

sectionSelectCircle: {
backgroundColor: colors.productDark200,
backgroundColor: theme.highlightBG,
},

qrShareSection: {
Expand Down
Loading