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 <cursoragent@cursor.com>
This commit is contained in:
Yared Yemane 2026-06-15 08:12:43 -07:00
parent 8e0ebe077a
commit 1915d89bc3
5 changed files with 10 additions and 14 deletions

View File

@ -9,8 +9,8 @@ export const SUBSCRIPTION_PLAN_CATEGORIES: {
label: string label: string
}[] = [ }[] = [
{ value: "LEARN_ENGLISH", label: "Learn English" }, { value: "LEARN_ENGLISH", label: "Learn English" },
{ value: "EXAM_PREP", label: "Exam prep" }, { value: "IELTS", label: "IELTS" },
{ value: "SKILLS", label: "Skills" }, { value: "DUOLINGO", label: "Duolingo" },
] ]
export const SUBSCRIPTION_DURATION_UNITS: { export const SUBSCRIPTION_DURATION_UNITS: {

View File

@ -40,7 +40,7 @@ import {
paymentCustomerName, paymentCustomerName,
paymentStatusBadgeVariant, paymentStatusBadgeVariant,
} from "../../lib/payments" } from "../../lib/payments"
import { SUBSCRIPTION_CURRENCIES } from "../../lib/subscriptionPlans" import { SUBSCRIPTION_CURRENCIES, SUBSCRIPTION_PLAN_CATEGORIES } from "../../lib/subscriptionPlans"
import type { import type {
Payment, Payment,
PaymentPlanCategory, PaymentPlanCategory,
@ -64,11 +64,7 @@ const PROVIDER_FILTERS: { value: PaymentProvider; label: string }[] = [
{ value: "ARIFPAY", label: "Arifpay" }, { value: "ARIFPAY", label: "Arifpay" },
] ]
const PLAN_CATEGORY_FILTERS: { value: PaymentPlanCategory; label: string }[] = [ const PLAN_CATEGORY_FILTERS = SUBSCRIPTION_PLAN_CATEGORIES
{ value: "LEARN_ENGLISH", label: "Learn English" },
{ value: "IELTS", label: "IELTS" },
{ value: "DUOLINGO", label: "Duolingo" },
]
type PaymentListFilters = { type PaymentListFilters = {
status: PaymentStatus | "" status: PaymentStatus | ""

View File

@ -12,6 +12,7 @@ import {
TableRow, TableRow,
} from "../../../components/ui/table"; } from "../../../components/ui/table";
import { cn } from "../../../lib/utils"; import { cn } from "../../../lib/utils";
import { formatPlanCategory } from "../../../lib/subscriptionPlans";
import type { UserSubscriptionsData } from "../../../types/userAdmin.types"; import type { UserSubscriptionsData } from "../../../types/userAdmin.types";
function formatStatusLabel(status: string): string { function formatStatusLabel(status: string): string {
@ -24,10 +25,7 @@ function formatStatusLabel(status: string): string {
} }
function formatCategoryLabel(value: string): string { function formatCategoryLabel(value: string): string {
return value return formatPlanCategory(value);
.split("_")
.map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
.join(" ");
} }
function formatDateTime(value?: string | null): string { function formatDateTime(value?: string | null): string {

View File

@ -1,3 +1,5 @@
import type { SubscriptionPlanCategory } from "./subscription.types"
export type PaymentStatus = export type PaymentStatus =
| "PENDING" | "PENDING"
| "PROCESSING" | "PROCESSING"
@ -11,7 +13,7 @@ export type PaymentProvider = "CHAPA" | "ARIFPAY" | string
export type PaymentMethod = PaymentProvider | string export type PaymentMethod = PaymentProvider | string
export type PaymentPlanCategory = "LEARN_ENGLISH" | "IELTS" | "DUOLINGO" | string export type PaymentPlanCategory = SubscriptionPlanCategory
export interface Payment { export interface Payment {
id: number id: number

View File

@ -1,6 +1,6 @@
export type SubscriptionPlanDurationUnit = "MONTH" | "YEAR" | "WEEK" | "DAY" | string 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 { export interface SubscriptionPlan {
id: number id: number