Skip to content

Commit

Permalink
Merge pull request #12991 from albertkol/fix-technical-user-error
Browse files Browse the repository at this point in the history
Fix techinical user error
  • Loading branch information
albertkol committed Jul 3, 2023
2 parents 221e388 + f88315f commit 1caab18
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ describe("SubscriptionDetails", () => {
const contract = userSubscriptionFactory.build({
type: UserSubscriptionType.Monthly,
statuses: userSubscriptionStatusesFactory.build({
is_subscription_active: true,
is_renewed: true,
is_cancelled: false,
}),
});

Expand All @@ -467,6 +469,7 @@ describe("SubscriptionDetails", () => {
const contract = userSubscriptionFactory.build({
type: UserSubscriptionType.Monthly,
statuses: userSubscriptionStatusesFactory.build({
is_subscription_active: true,
is_renewed: false,
}),
});
Expand Down Expand Up @@ -535,7 +538,9 @@ describe("SubscriptionDetails", () => {
const contract = userSubscriptionFactory.build({
type: UserSubscriptionType.Trial,
statuses: userSubscriptionStatusesFactory.build({
is_subscription_active: true,
is_renewed: true,
is_cancelled: false,
}),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,39 +155,51 @@ export const SubscriptionDetails = forwardRef<HTMLDivElement, Props>(
{subscription.type == "monthly" ||
subscription.type == "yearly" ? (
<>
{subscription.statuses.is_renewed ? (
<button className="p-chip--positive">
<span className="p-chip__value">Auto-renewal on</span>
</button>
) : (
{subscription.statuses.is_subscription_active &&
!subscription.statuses.is_cancelled ? (
<>
{!subscription.statuses.is_cancelled ? (
{subscription.statuses.is_renewed ? (
<button className="p-chip--positive">
<span className="p-chip__value">
Auto-renewal on
</span>
</button>
) : null}
{!subscription.statuses.is_renewed ? (
<button className="p-chip--caution">
<span className="p-chip__value">
Auto-renewal off
</span>
</button>
) : (
<button className="p-chip--negative">
<span className="p-chip__value">Cancelled</span>
</button>
)}
) : null}
</>
)}
) : null}
{subscription.statuses.is_cancelled ? (
<button className="p-chip--negative">
<span className="p-chip__value">Cancelled</span>
</button>
) : null}
</>
) : null}
{subscription.type == "trial" ? (
<>
{subscription.statuses.is_subscription_active ? (
<>
{subscription.statuses.is_renewed &&
!subscription.statuses.is_cancelled ? (
<button className="p-chip--positive">
<span className="p-chip__value">
Auto-renewal on
</span>
</button>
) : null}
</>
) : null}
{subscription.statuses.is_cancelled ? (
<button className="p-chip--negative">
<span className="p-chip__value">Cancelled</span>
</button>
) : null}
{subscription.statuses.is_renewed ? (
<button className="p-chip--positive">
<span className="p-chip__value">Auto-renewal on</span>
</button>
) : null}
</>
) : null}
</>
Expand Down
4 changes: 2 additions & 2 deletions webapp/shop/api/ua_contracts/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def get_user_subscription_statuses(
statuses["has_pending_purchases"] = True
return statuses

if type == "trial":
if type == "trial" and account.role != "technical":
active_trial = [
subscription
for subscription in subscriptions
Expand Down Expand Up @@ -273,7 +273,7 @@ def get_user_subscription_statuses(
and not statuses["is_cancelled"]
)

if type in ["yearly", "monthly"]:
if type in ["yearly", "monthly"] and account.role != "technical":
statuses["is_subscription_active"] = is_billing_subscription_active(
subscriptions, subscription_id
)
Expand Down

0 comments on commit 1caab18

Please sign in to comment.