Files
Shifted/.storybook/mocks/handlers.js
2026-02-10 01:14:19 +00:00

129 lines
4.0 KiB
JavaScript

import { http, HttpResponse } from "msw";
export const handlers = [
http.get("/layout", () =>
HttpResponse.json({
layout: {
hero: { title: "Shifted Offroad", subtitle: "Dialed for the trail." },
sections: ["shopByVehicle", "categories", "trailReels"],
},
})
),
http.post("/layout", () => HttpResponse.json({ ok: true })),
http.get("/api/printful/products", () =>
HttpResponse.json({
products: [
{
id: "pf_1",
name: "Shifted Hoodie",
unitAmount: 4999,
currency: "usd",
thumbnailUrl: "/assets/sample-1.jpg",
variantId: "v_1",
},
{
id: "pf_2",
name: "Trail Cap",
unitAmount: 2999,
currency: "usd",
thumbnailUrl: "/assets/sample-2.jpg",
variantId: "v_2",
},
],
})
),
http.get("/api/admin/products/list", () =>
HttpResponse.json({
products: [
{
stripeProductId: "prod_1",
stripePriceId: "price_1",
name: "Lift Kit",
description: "2.5 inch lift kit",
unitAmount: 69900,
currency: "usd",
active: true,
},
],
})
),
http.post("/api/admin/products/refresh", () => HttpResponse.json({ ok: true })),
http.post("/api/admin/products/update", () => HttpResponse.json({ ok: true })),
http.get("/api/connect/account/lookup", () => HttpResponse.json({ accountId: "acct_123" })),
http.get("/api/storefront/products", () =>
HttpResponse.json({
products: [
{
stripeProductId: "prod_1",
stripePriceId: "price_1",
name: "Recovery Kit",
description: "Tow strap and shackles",
unitAmount: 12900,
currency: "usd",
},
{
stripeProductId: "prod_2",
stripePriceId: "price_2",
name: "LED Pods",
description: "High output pods",
unitAmount: 9900,
currency: "usd",
},
],
})
),
http.get("/api/connect/products/get", () =>
HttpResponse.json({
product: {
id: "prod_123",
name: "Trail Bundle",
description: "Lighting + recovery essentials",
default_price: { id: "price_123", unit_amount: 19900, currency: "usd" },
},
})
),
http.post("/api/connect/payment-intent", () => HttpResponse.json({ clientSecret: "pi_mock_secret" })),
http.post("/api/connect/checkout", () => HttpResponse.json({ url: "/success" })),
http.get("/api/cart/get", () =>
HttpResponse.json({
cart: {
id: "cart_1",
items: [
{ id: "item_1", name: "Winch Plate", unitAmount: 19900, currency: "usd", quantity: 1 },
],
},
})
),
http.post("/api/cart/add", () => HttpResponse.json({ ok: true })),
http.post("/api/cart/update", () => HttpResponse.json({ ok: true })),
http.post("/api/cart/remove", () => HttpResponse.json({ ok: true })),
http.post("/api/cart/checkout", () => HttpResponse.json({ url: "/success" })),
http.get("/api/store/me", () => HttpResponse.json({ slug: "storeshifted", stripeAccountId: "acct_123" })),
http.get("/api/connect/account/status", () =>
HttpResponse.json({ readyToProcessPayments: true, onboardingComplete: true })
),
http.post("/api/connect/account/create", () =>
HttpResponse.json({ ok: true, accountId: "acct_123", url: "/connect" })
),
http.post("/api/connect/account/link", () =>
HttpResponse.json({ ok: true, accountId: "acct_123", url: "/connect" })
),
http.post("/api/connect/products/create", () => HttpResponse.json({ ok: true })),
http.post("/api/connect/subscription/create", () => HttpResponse.json({ ok: true })),
http.post("/api/connect/subscription/portal", () => HttpResponse.json({ ok: true })),
http.post("/api/auth/signup", () => HttpResponse.json({ ok: true })),
http.post("/api/auth/signup-customer", () => HttpResponse.json({ ok: true })),
http.post("/api/printful/sync-products", () => HttpResponse.json({ result: { id: "sync_1" } })),
];