feat(payment): implement coffee tip plans and update payment flow

This commit is contained in:
2026-07-14 11:48:46 +08:00
parent f9c15bd91f
commit 3a4f24cb06
30 changed files with 632 additions and 56 deletions
+16 -4
View File
@@ -12,18 +12,30 @@ import {
import { getPaymentRepository } from "@/data/repositories/payment_repository";
import { Result } from "@/utils";
import type { PaymentPlanCatalog } from "./payment-state";
export const loadCachedPaymentPlansActor =
fromPromise<PaymentPlansResponse | null>(async () => {
fromPromise<
PaymentPlansResponse | null,
{ catalog: PaymentPlanCatalog }
>(async ({ input }) => {
if (input.catalog === "tip") return null;
const paymentRepo = getPaymentRepository();
const result = await paymentRepo.getCachedPlans();
if (Result.isErr(result)) throw result.error;
return result.data;
});
export const refreshPaymentPlansActor = fromPromise<PaymentPlansResponse>(
async () => {
export const refreshPaymentPlansActor = fromPromise<
PaymentPlansResponse,
{ catalog: PaymentPlanCatalog }
>(
async ({ input }) => {
const paymentRepo = getPaymentRepository();
const result = await paymentRepo.getPlans();
const result =
input.catalog === "tip"
? await paymentRepo.getTipPlans()
: await paymentRepo.getPlans();
if (Result.isErr(result)) throw result.error;
return result.data;
},