"use client";

import {
  PaymentPlansResponseSchema,
  type PaymentPlansResponseData,
} from "@/data/schemas/payment";
import { type Result as ResultT, SpAsyncUtil } from "@/utils";

import { StorageKeys } from "../storage_keys";

export class PaymentPlansStorage {
  private constructor() {}

  static getPlans(): Promise<ResultT<PaymentPlansResponseData | null>> {
    return SpAsyncUtil.getJson(
      StorageKeys.paymentPlans,
      PaymentPlansResponseSchema,
    );
  }

  static setPlans(plans: PaymentPlansResponseData): Promise<ResultT<void>> {
    return SpAsyncUtil.setJson(
      StorageKeys.paymentPlans,
      plans,
      PaymentPlansResponseSchema,
    );
  }

  static clearPlans(): Promise<ResultT<void>> {
    return SpAsyncUtil.remove(StorageKeys.paymentPlans);
  }
}
