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

Fix / remove profiles from the web app #563

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/common/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const DEFAULT_FEATURES = {
hasSocialURLs: false,
hasNotifications: false,
watchListSizeLimit: MAX_WATCHLIST_ITEMS_COUNT,
canSwitchSubscription: false,
};

export const EPG_TYPE = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type AccountServiceFeatures = {
readonly hasSocialURLs: boolean;
readonly hasNotifications: boolean;
readonly watchListSizeLimit: number;
readonly canSwitchSubscription: boolean;
};

export default abstract class AccountService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default class CleengAccountService extends AccountService {
canShowReceipts: false,
hasSocialURLs: false,
hasNotifications: false,
canSwitchSubscription: true,
// The 'externalData' attribute of Cleeng can contain max 4000 characters
watchListSizeLimit: 48,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ export default class JWPAccountService extends AccountService {
canSupportEmptyFullName: false,
canChangePasswordWithOldPassword: true,
canRenewSubscription: false,
canExportAccountData: true,
canExportAccountData: false,
canUpdatePaymentMethod: false,
canShowReceipts: true,
canDeleteAccount: true,
canDeleteAccount: false,
hasNotifications: true,
canSwitchSubscription: false,
hasSocialURLs: true,
// Limit of media_ids length passed to the /apps/watchlists endpoint
watchListSizeLimit: 48,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('<Payment>', () => {
canUpdatePaymentMethod={false}
showAllTransactions={false}
isLoading={false}
canSwitchSubscription={false}
offerSwitchesAvailable={false}
onShowReceiptClick={vi.fn()}
onUpgradeSubscriptionClick={vi.fn()}
Expand Down
47 changes: 30 additions & 17 deletions packages/ui-react/src/components/Payment/Payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type Props = {
isExternalPaymentProvider: boolean;
paymentProvider?: string;
paymentProviderLink?: string;
canSwitchSubscription: boolean;
};

const Payment = ({
Expand Down Expand Up @@ -92,6 +93,7 @@ const Payment = ({
isExternalPaymentProvider,
paymentProvider,
paymentProviderLink,
canSwitchSubscription,
}: Props): JSX.Element => {
const subscriptionDetailsId = useOpaqueId('subscription-details');
const paymentMethodId = useOpaqueId('payment-method');
Expand Down Expand Up @@ -219,23 +221,34 @@ const Payment = ({
</Link>
</p>
) : (
showChangeSubscriptionButton && (
<Button
className={styles.upgradeSubscription}
label={t('user:payment.change_subscription')}
disabled={!canRenewSubscription && activeSubscription.status === 'cancelled'}
onClick={() => {
if (offers.length > 1 && !canRenewSubscription) {
setIsChangingOffer(true);
} else {
onUpgradeSubscriptionClick?.();
borkopetrovicc marked this conversation as resolved.
Show resolved Hide resolved
}
}}
fullWidth={isMobile}
color="primary"
data-testid="change-subscription-button"
/>
)
<>
{canSwitchSubscription && showChangeSubscriptionButton && (
Copy link
Collaborator

@AntonLantukh AntonLantukh Jul 8, 2024

Choose a reason for hiding this comment

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

I am hesitant to add additional complexity here introducing a new condition + new "cancel" button (third one?). I like the solution Christiaan purposed. Do you think we could focus on that one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes i will close this pr.

<Button
className={styles.upgradeSubscription}
label={t('user:payment.change_subscription')}
disabled={!canRenewSubscription && activeSubscription.status === 'cancelled'}
onClick={() => {
if (offers.length > 1 && !canRenewSubscription) {
setIsChangingOffer(true);
} else {
onUpgradeSubscriptionClick?.();
}
}}
fullWidth={isMobile}
color="primary"
data-testid="change-subscription-button"
/>
)}
{!canSwitchSubscription && activeSubscription?.status !== 'cancelled' && (
<Button
className={styles.changePlanCancelButton}
label={t('user:payment.cancel_subscription')}
onClick={onCancelSubscriptionClick}
variant="danger"
data-testid="cancel-subscription-button"
/>
)}
</>
)}
{(activeSubscription.status === 'active' || activeSubscription.status === 'active_trial') &&
!isGrantedSubscription &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const PaymentContainer = () => {

const { accessModel } = useConfigStore(({ accessModel }) => ({ accessModel }), shallow);
const { user: customer, subscription: activeSubscription, transactions, activePayment, pendingOffer, loading } = useAccountStore();
const { canUpdatePaymentMethod, canShowReceipts, canRenewSubscription } = accountController.getFeatures();
const { canUpdatePaymentMethod, canShowReceipts, canRenewSubscription, canSwitchSubscription } = accountController.getFeatures();
const { subscriptionOffers, switchSubscriptionOffers } = useOffers();

const [showAllTransactions, setShowAllTransactions] = useState(false);
Expand Down Expand Up @@ -135,6 +135,7 @@ const PaymentContainer = () => {
isExternalPaymentProvider={isExternalPaymentProvider}
paymentProvider={paymentProvider}
paymentProviderLink={paymentProviderLink}
canSwitchSubscription={canSwitchSubscription}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,12 @@ exports[`User Component tests > Payments Page 1`] = `
</p>
</div>
<button
aria-disabled="false"
class="_button_f8f296 _upgradeSubscription_c57ff5 _primary_f8f296 _outlined_f8f296"
data-testid="change-subscription-button"
class="_button_f8f296 _changePlanCancelButton_c57ff5 _default_f8f296 _danger_f8f296"
data-testid="cancel-subscription-button"
type="button"
>
<span>
user:payment.change_subscription
user:payment.cancel_subscription
</span>
</button>
</section>
Expand Down
Loading