From 1915d89bc30ae15f183cc95f493f0193f63f5064 Mon Sep 17 00:00:00 2001 From: Yared Yemane Date: Mon, 15 Jun 2026 08:12:43 -0700 Subject: [PATCH] Align subscription plan categories with backend allowed values. Replace EXAM_PREP and SKILLS with IELTS and DUOLINGO, and centralize category labels across payments and user subscriptions. Co-authored-by: Cursor --- src/lib/subscriptionPlans.ts | 4 ++-- src/pages/payments/PaymentsPage.tsx | 8 ++------ .../components/UserSubscriptionsSection.tsx | 6 ++---- src/types/payment.types.ts | 4 +++- src/types/subscription.types.ts | 2 +- 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/lib/subscriptionPlans.ts b/src/lib/subscriptionPlans.ts index ed19f69..2148196 100644 --- a/src/lib/subscriptionPlans.ts +++ b/src/lib/subscriptionPlans.ts @@ -9,8 +9,8 @@ export const SUBSCRIPTION_PLAN_CATEGORIES: { label: string }[] = [ { value: "LEARN_ENGLISH", label: "Learn English" }, - { value: "EXAM_PREP", label: "Exam prep" }, - { value: "SKILLS", label: "Skills" }, + { value: "IELTS", label: "IELTS" }, + { value: "DUOLINGO", label: "Duolingo" }, ] export const SUBSCRIPTION_DURATION_UNITS: { diff --git a/src/pages/payments/PaymentsPage.tsx b/src/pages/payments/PaymentsPage.tsx index aab6a6d..4dbabe4 100644 --- a/src/pages/payments/PaymentsPage.tsx +++ b/src/pages/payments/PaymentsPage.tsx @@ -40,7 +40,7 @@ import { paymentCustomerName, paymentStatusBadgeVariant, } from "../../lib/payments" -import { SUBSCRIPTION_CURRENCIES } from "../../lib/subscriptionPlans" +import { SUBSCRIPTION_CURRENCIES, SUBSCRIPTION_PLAN_CATEGORIES } from "../../lib/subscriptionPlans" import type { Payment, PaymentPlanCategory, @@ -64,11 +64,7 @@ const PROVIDER_FILTERS: { value: PaymentProvider; label: string }[] = [ { value: "ARIFPAY", label: "Arifpay" }, ] -const PLAN_CATEGORY_FILTERS: { value: PaymentPlanCategory; label: string }[] = [ - { value: "LEARN_ENGLISH", label: "Learn English" }, - { value: "IELTS", label: "IELTS" }, - { value: "DUOLINGO", label: "Duolingo" }, -] +const PLAN_CATEGORY_FILTERS = SUBSCRIPTION_PLAN_CATEGORIES type PaymentListFilters = { status: PaymentStatus | "" diff --git a/src/pages/user-management/components/UserSubscriptionsSection.tsx b/src/pages/user-management/components/UserSubscriptionsSection.tsx index 9695e52..8ade4e3 100644 --- a/src/pages/user-management/components/UserSubscriptionsSection.tsx +++ b/src/pages/user-management/components/UserSubscriptionsSection.tsx @@ -12,6 +12,7 @@ import { TableRow, } from "../../../components/ui/table"; import { cn } from "../../../lib/utils"; +import { formatPlanCategory } from "../../../lib/subscriptionPlans"; import type { UserSubscriptionsData } from "../../../types/userAdmin.types"; function formatStatusLabel(status: string): string { @@ -24,10 +25,7 @@ function formatStatusLabel(status: string): string { } function formatCategoryLabel(value: string): string { - return value - .split("_") - .map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase()) - .join(" "); + return formatPlanCategory(value); } function formatDateTime(value?: string | null): string { diff --git a/src/types/payment.types.ts b/src/types/payment.types.ts index ea5aa32..ccf0737 100644 --- a/src/types/payment.types.ts +++ b/src/types/payment.types.ts @@ -1,3 +1,5 @@ +import type { SubscriptionPlanCategory } from "./subscription.types" + export type PaymentStatus = | "PENDING" | "PROCESSING" @@ -11,7 +13,7 @@ export type PaymentProvider = "CHAPA" | "ARIFPAY" | string export type PaymentMethod = PaymentProvider | string -export type PaymentPlanCategory = "LEARN_ENGLISH" | "IELTS" | "DUOLINGO" | string +export type PaymentPlanCategory = SubscriptionPlanCategory export interface Payment { id: number diff --git a/src/types/subscription.types.ts b/src/types/subscription.types.ts index d63d866..7b7f3cb 100644 --- a/src/types/subscription.types.ts +++ b/src/types/subscription.types.ts @@ -1,6 +1,6 @@ export type SubscriptionPlanDurationUnit = "MONTH" | "YEAR" | "WEEK" | "DAY" | string -export type SubscriptionPlanCategory = "LEARN_ENGLISH" | "EXAM_PREP" | "SKILLS" | string +export type SubscriptionPlanCategory = "LEARN_ENGLISH" | "IELTS" | "DUOLINGO" export interface SubscriptionPlan { id: number