Archived
WIP 1.51.9: frontend on v2 for series, passes, bundles, coupons, campuses
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ls1vMdg2GYqbnKZmPaX1ot
This commit is contained in:
@@ -8,6 +8,7 @@ import { useDismissingState } from "@/hooks/useDismissingState";
|
||||
import { TicketPercent, Plus, X, Search, Pencil, Power, Users, CalendarClock, ListChecks } from "lucide-react";
|
||||
import { errorMessage } from "@/lib/utils";
|
||||
import { BackLink } from "@/components/shared/BackLink";
|
||||
import { apiV2Data } from "@/lib/apiV2";
|
||||
|
||||
type CouponType = "percent" | "fixed" | "comp";
|
||||
type Role = "user" | "staff" | "supervisor" | "admin";
|
||||
@@ -163,7 +164,7 @@ export default function CouponsPage() {
|
||||
setFetching(true);
|
||||
try {
|
||||
const [c, ev] = await Promise.all([
|
||||
apiFetch<Coupon[]>("/api/coupons", { authToken: token }),
|
||||
(apiV2Data("get", "/coupons", { authToken: token }) as Promise<Coupon[]>),
|
||||
fetchManagedEvents<EventLite>(token, { past: true }),
|
||||
]);
|
||||
setCoupons(c || []);
|
||||
@@ -191,7 +192,7 @@ export default function CouponsPage() {
|
||||
|
||||
const toggleActive = async (c: Coupon) => {
|
||||
try {
|
||||
await apiFetch(`/api/coupons/${c.id}`, { method: "PUT", authToken: token!, body: { active: !c.active } });
|
||||
await apiV2Data("patch", "/coupons/{id}", { params: { id: c.id }, authToken: token, body: { active: !c.active } });
|
||||
setInfo(`${c.code} turned ${c.active ? "off" : "on"}.`);
|
||||
load();
|
||||
} catch (e) {
|
||||
@@ -201,7 +202,7 @@ export default function CouponsPage() {
|
||||
|
||||
const openUses = async (c: Coupon) => {
|
||||
try {
|
||||
const full = await apiFetch<Coupon & { redemptions: Redemption[] }>(`/api/coupons/${c.id}`, { authToken: token! });
|
||||
const full = await (apiV2Data("get", "/coupons/{id}", { params: { id: c.id }, authToken: token }) as Promise<Coupon & { redemptions: Redemption[] }>);
|
||||
setViewing({ coupon: c, redemptions: full.redemptions || [] });
|
||||
} catch (e) {
|
||||
setError(errorMessage(e) || "Failed to load uses");
|
||||
@@ -473,10 +474,10 @@ function CouponModal({ token, events, couponId, initial, onClose, onSaved }: {
|
||||
try {
|
||||
const body = bodyFromDraft(d);
|
||||
if (couponId) {
|
||||
await apiFetch(`/api/coupons/${couponId}`, { method: "PUT", authToken: token, body });
|
||||
await apiV2Data("patch", "/coupons/{id}", { params: { id: couponId }, authToken: token, body: body as never });
|
||||
onSaved(`${body.code.toUpperCase()} saved.`);
|
||||
} else {
|
||||
await apiFetch(`/api/coupons`, { method: "POST", authToken: token, body });
|
||||
await apiV2Data("post", "/coupons", { authToken: token, body: body as never });
|
||||
onSaved(`${body.code.toUpperCase()} created.`);
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user