Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

feat(vendor): add subscription section and improve store settings (#830)

Viktor Holik2d6f62eae967
diff --git a/apps/api/src/scripts/seed.ts b/apps/api/src/scripts/seed.ts
index 0bd5c9d6e..9c50c6e1e 100644
--- a/apps/api/src/scripts/seed.ts
+++ b/apps/api/src/scripts/seed.ts
@@ -31,6 +31,7 @@ import {
} from "@medusajs/medusa/core-flows";
import { ApiKey } from "../../.medusa/types/query-entry-points";
import { MercurModules } from "@mercurjs/types";
+import { createSellerDefaultsWorkflow } from '@mercurjs/core-plugin/workflows'
const updateStoreCurrencies = createWorkflow(
"update-store-currencies",
@@ -1062,154 +1063,7 @@ export default async function seedDemoData({ container }: ExecArgs) {
logger.info("Finished seeding inventory levels data.");
- logger.info("Seeding seller data...");
- const sellerEmail = "[email protected]";
- const sellerModule = container.resolve(MercurModules.SELLER)
- const authModule: IAuthModuleService = container.resolve(Modules.AUTH);
-
- const existingSellers = await sellerModule.listSellers({
- email: sellerEmail,
- });
-
- let seller;
- if (existingSellers.length) {
- seller = existingSellers[0];
- logger.info("Seller already exists, skipping creation.");
- } else {
- seller = await sellerModule.createSellers({
- name: "Test Seller",
- email: sellerEmail,
- });
-
- const authResult = await authModule.register("emailpass", {
- body: { email: sellerEmail, password: "supersecret" },
- });
-
- if (!authResult.success || !authResult.authIdentity) {
- throw new Error(
- `Failed to register seller auth identity: ${authResult.error}`
- );
- }
-
- await authModule.updateAuthIdentities({
- id: authResult.authIdentity.id,
- app_metadata: {
- seller_id: seller.id,
- },
- });
-
- logger.info("Seller created with email: [email protected] / password: supersecret");
- }
-
- // Link entities to seller (idempotent — runs every time)
- logger.info("Linking products to seller...");
- for (const product of seededProducts) {
- try {
- await link.create({
- [Modules.PRODUCT]: {
- product_id: product.id,
- },
- [MercurModules.SELLER]: {
- seller_id: seller.id,
- },
- });
- } catch (error: unknown) {
- if (!(error instanceof Error && error.message.includes("already exists"))) {
- throw error;
- }
- }
- }
-
- logger.info("Linking stock location to seller...");
- try {
- await link.create({
- [Modules.STOCK_LOCATION]: {
- stock_location_id: stockLocation.id,
- },
- [MercurModules.SELLER]: {
- seller_id: seller.id,
- },
- });
- } catch (error: unknown) {
- if (!(error instanceof Error && error.message.includes("already exists"))) {
- throw error;
- }
- }
-
- logger.info("Linking fulfillment set to seller...");
- try {
- await link.create({
- [MercurModules.SELLER]: {
- seller_id: seller.id,
- },
- [Modules.FULFILLMENT]: {
- fulfillment_set_id: fulfillmentSet.id,
- },
- });
- } catch (error: unknown) {
- if (!(error instanceof Error && error.message.includes("already exists"))) {
- throw error;
- }
- }
-
- logger.info("Linking service zones to seller...");
- const fulfillmentSetWithZones = await fulfillmentModuleService.retrieveFulfillmentSet(
- fulfillmentSet.id,
- { relations: ["service_zones"] }
- );
- for (const zone of fulfillmentSetWithZones.service_zones) {
- try {
- await link.create({
- [MercurModules.SELLER]: {
- seller_id: seller.id,
- },
- [Modules.FULFILLMENT]: {
- service_zone_id: zone.id,
- },
- });
- } catch (error: unknown) {
- if (!(error instanceof Error && error.message.includes("already exists"))) {
- throw error;
- }
- }
- }
-
- logger.info("Linking shipping profile to seller...");
- try {
- await link.create({
- [Modules.FULFILLMENT]: {
- shipping_profile_id: shippingProfile.id,
- },
- [MercurModules.SELLER]: {
- seller_id: seller.id,
- },
- });
- } catch (error: unknown) {
- if (!(error instanceof Error && error.message.includes("already exists"))) {
- throw error;
- }
- }
-
- logger.info("Linking shipping options to seller...");
- const shippingOptions = await fulfillmentModuleService.listShippingOptions({
- service_zone: { id: fulfillmentSetWithZones.service_zones.map((z) => z.id) },
- });
- for (const option of shippingOptions) {
- try {
- await link.create({
- [Modules.FULFILLMENT]: {
- shipping_option_id: option.id,
- },
- [MercurModules.SELLER]: {
- seller_id: seller.id,
- },
- });
- } catch (error: unknown) {
- if (!(error instanceof Error && error.message.includes("already exists"))) {
- throw error;
- }
- }
- }
+ await createSellerDefaultsWorkflow(container).run({})
logger.info("Finished seeding seller data.");
}
diff --git a/apps/vendor/src/hooks/use-me.ts b/apps/vendor/src/hooks/use-me.ts
new file mode 100644
index 000000000..17e0cc6d5
--- /dev/null
+++ b/apps/vendor/src/hooks/use-me.ts
@@ -0,0 +1,12 @@
+import { useQuery } from "@tanstack/react-query";
+import { client } from "../lib/client";
+
+export const useMe = (
+) => {
+ const { data, ...rest } = useQuery({
+ queryKey: ['members', 'me'],
+ queryFn: () => client.vendor.members.me.query(),
+ });
+
+ return { ...data, ...rest };
+};
diff --git a/apps/vendor/src/lib/client.ts b/apps/vendor/src/lib/client.ts
index 078a11c58..6116165ca 100644
--- a/apps/vendor/src/lib/client.ts
+++ b/apps/vendor/src/lib/client.ts
@@ -1,5 +1,5 @@
import { createClient, type InferClient } from "@mercurjs/client"
-import type { Routes } from '@acme/api/_generated'
+import type { Routes } from '@mercurjs/core-plugin/_generated'
declare const __BACKEND_URL__: string
diff --git a/apps/vendor/src/routes/setup/page.tsx b/apps/vendor/src/routes/setup/page.tsx
new file mode 100644
index 000000000..47ac94f4d
--- /dev/null
+++ b/apps/vendor/src/routes/setup/page.tsx
@@ -0,0 +1,173 @@
+import { useMemo } from "react";
+import {
+ RocketLaunch,
+ CheckCircleSolid,
+ CircleDottedLine,
+ Spinner,
+} from "@medusajs/icons";
+import { Button, Heading, Text, clx } from "@medusajs/ui";
+import { useNavigate } from "react-router-dom";
+
+import type { RouteConfig } from "@mercurjs/dashboard-sdk";
+import { useMe } from "../../hooks/use-me";
+
+export const config: RouteConfig = {
+ label: "Setup",
+ icon: RocketLaunch,
+};
+
+type SetupStep = {
+ id: string;
+ title: string;
+ description: string;
+ completed: boolean;
+ action: {
+ label: string;
+ to: string;
+ };
+ isNext?: boolean;
+};
+
+function SetupStepRow({ step }: { step: SetupStep }) {
+ const navigate = useNavigate();
+
+ return (
+ <div className="flex items-start gap-x-4 py-6">
+ <div className="shrink-0 pt-0.5">
+ {step.completed ? (
+ <CheckCircleSolid className="h-6 w-6 text-green-500" />
+ ) : (
+ <CircleDottedLine className="text-ui-fg-muted h-6 w-6" />
+ )}
+ </div>
+ <div className="flex flex-1 flex-col gap-y-0.5">
+ <Text
+ size="small"
+ weight="plus"
+ className={clx(!step.completed && !step.isNext && "text-ui-fg-muted")}
+ >
+ {step.title}
+ </Text>
+ <Text
+ size="small"
+ className={clx(
+ "text-ui-fg-subtle max-w-[460px]",
+ !step.completed && !step.isNext && "text-ui-fg-muted",
+ )}
+ >
+ {step.description}
+ </Text>
+ </div>
+ <div className="shrink-0 pt-0.5">
+ <Button
+ variant={step.isNext ? "primary" : "secondary"}
+ size="small"
+ onClick={() => navigate(step.action.to)}
+ >
+ {step.action.label}
+ </Button>
+ </div>
+ </div>
+ );
+}
+
+function SetupPageSkeleton() {
+ return (
+ <div className="flex min-h-[400px] items-center justify-center">
+ <Spinner className="text-ui-fg-muted animate-spin" />
+ </div>
+ );
+}
+
+export default function SetupPage() {
+ const { seller_member, isPending, isError, error } = useMe();
+ const seller = seller_member?.seller;
+
+ const steps = useMemo((): SetupStep[] => {
+ if (!seller) return [];
+
+ const hasCompanyProfile = !!(seller.description && seller.logo);
+ const hasAddress = !!seller.address;
+ const hasPaymentInfo = !!seller.payment_details;
+
+ const steps: SetupStep[] = [
+ {
+ id: "account",
+ title: "Store created",
+ description: "You're ready to start setting up your store.",
+ completed: true,
+ action: {
+ label: "View store",
+ to: "/settings/store",
+ },
+ },
+ {
+ id: "company-profile",
+ title: "Complete company profile",
+ description:
+ "Add your store name, description, logo, and other details so customers can find and trust your store.",
+ completed: hasCompanyProfile,
+ action: {
+ label: hasCompanyProfile ? "Edit" : "Get started",
+ to: "/settings/store/edit",
+ },
+ },
+ {
+ id: "business-address",
+ title: "Business address",
+ description:
+ "Provide your business address for shipping calculations and tax compliance.",
+ completed: hasAddress,
+ action: {
+ label: hasAddress ? "Edit" : "Get started",
+ to: "/settings/store/address",
+ },
+ },
+ {
+ id: "payment-info",
+ title: "Add payment information",
+ description:
+ "Set up your bank account or payment method to receive payouts from your sales.",
+ completed: hasPaymentInfo,
+ action: {
+ label: hasPaymentInfo ? "Edit" : "Get started",
+ to: "/settings/store/payment-details",
+ },
+ },
+ ];
+
+ let foundNext = false;
+ return steps.map((step) => {
+ if (!step.completed && !foundNext) {
+ foundNext = true;
+ return { ...step, isNext: true };
+ }
+ return step;
+ });
+ }, [seller]);
+
+ if (isPending) {
+ return <SetupPageSkeleton />;
+ }
+
+ if (isError) {
+ throw error;
+ }
+
+ return (
+ <div className="mx-auto max-w-[720px] py-8">
+ <Heading level="h1" className="mb-1">
+ Welcome!
+ </Heading>
+ <Text className="text-ui-fg-subtle mb-8" size="small">
+ Complete these steps to get your store approved.
+ </Text>
+
+ <div className="divide-y divide-ui-border-base">
+ {steps.map((step) => (
+ <SetupStepRow key={step.id} step={step} />
+ ))}
+ </div>
+ </div>
+ );
+}
diff --git a/apps/vendor/vite.config.ts b/apps/vendor/vite.config.ts
index c8c24eb22..2a91a9b42 100644
--- a/apps/vendor/vite.config.ts
+++ b/apps/vendor/vite.config.ts
@@ -8,6 +8,7 @@ export default defineConfig({
react(),
mercurDashboardPlugin({
medusaConfigPath: '../../packages/api/medusa-config.ts',
+ initialPage: '/setup',
}),
],
})
diff --git a/packages/core-plugin/.mercur/_generated/index.ts b/packages/core-plugin/.mercur/_generated/index.ts
index 46e8fcba1..3ff1d5e2c 100644
--- a/packages/core-plugin/.mercur/_generated/index.ts
+++ b/packages/core-plugin/.mercur/_generated/index.ts
@@ -737,6 +737,7 @@ export type Routes = {
};
productVariants: typeof import("../../src/api/vendor/product-variants/route");
stores: typeof import("../../src/api/vendor/stores/route");
+ subscription: typeof import("../../src/api/vendor/subscription/route");
};
hooks: {
payout: typeof import("../../src/api/hooks/payout/route");
diff --git a/packages/core-plugin/src/api/admin/sellers/[id]/professional-details/route.ts b/packages/core-plugin/src/api/admin/sellers/[id]/professional-details/route.ts
index eafcfddea..ac759cb2a 100644
--- a/packages/core-plugin/src/api/admin/sellers/[id]/professional-details/route.ts
+++ b/packages/core-plugin/src/api/admin/sellers/[id]/professional-details/route.ts
@@ -3,11 +3,13 @@ import {
MedusaResponse,
} from "@medusajs/framework/http"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
-import { HttpTypes, MercurModules } from "@mercurjs/types"
+import { HttpTypes } from "@mercurjs/types"
import { AdminUpsertSellerProfessionalDetailsType } from "../../validators"
-import { updateSellerProfessionalDetailsWorkflow } from "../../../../../workflows/seller"
-import SellerModuleService from "../../../../../modules/seller/service"
+import {
+ updateSellerProfessionalDetailsWorkflow,
+ deleteSellerProfessionalDetailsWorkflow,
+} from "../../../../../workflows/seller"
export const POST = async (
req: AuthenticatedMedusaRequest<AdminUpsertSellerProfessionalDetailsType>,
@@ -36,15 +38,12 @@ export const DELETE = async (
req: AuthenticatedMedusaRequest,
res: MedusaResponse<HttpTypes.AdminSellerResponse>
) => {
- const service = req.scope.resolve<SellerModuleService>(MercurModules.SELLER)
- const existing = await service.listProfessionalDetails({
- seller_id: req.params.id,
+ await deleteSellerProfessionalDetailsWorkflow(req.scope).run({
+ input: {
+ seller_id: req.params.id,
+ },
})
- if (existing.length > 0) {
- await service.deleteProfessionalDetails([existing[0].id])
- }
-
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
const {
data: [seller],
diff --git a/packages/core-plugin/src/api/utils/ensure-seller-middleware.ts b/packages/core-plugin/src/api/utils/ensure-seller-middleware.ts
index bbd18e24f..cc7dfcf50 100644
--- a/packages/core-plugin/src/api/utils/ensure-seller-middleware.ts
+++ b/packages/core-plugin/src/api/utils/ensure-seller-middleware.ts
@@ -56,6 +56,7 @@ export async function ensureSellerMiddleware(
req.seller_context = {
seller_id: sellerId,
seller_member: sellerMember,
+ currency_code: sellerMember.seller.currency_code
}
if (sellerMember.role_id) {
diff --git a/packages/core-plugin/src/api/vendor/middlewares.ts b/packages/core-plugin/src/api/vendor/middlewares.ts
index db64a53d3..32987ecff 100644
--- a/packages/core-plugin/src/api/vendor/middlewares.ts
+++ b/packages/core-plugin/src/api/vendor/middlewares.ts
@@ -33,6 +33,7 @@ import { vendorShippingOptionTypesMiddlewares } from "./shipping-option-types/mi
import { vendorShippingProfilesMiddlewares } from "./shipping-profiles/middlewares"
import { vendorStockLocationsMiddlewares } from "./stock-locations/middlewares"
import { vendorStoresMiddlewares } from "./stores/middlewares"
+import { vendorSubscriptionMiddlewares } from "./subscription/middlewares"
import { vendorUploadsMiddlewares } from "./uploads/middlewares"
import { ensureSellerMiddleware, scanUnauthenticatedRoutes, unlessBaseUrl, vendorCorsMiddleware } from "../utils"
import { vendorProductTagsMiddlewares } from "./product-tags/middlewares"
@@ -111,4 +112,5 @@ export const vendorMiddlewares: MiddlewareRoute[] = [
...vendorStoresMiddlewares,
...vendorUploadsMiddlewares,
...vendorProductTagsMiddlewares,
+ ...vendorSubscriptionMiddlewares,
]
diff --git a/packages/core-plugin/src/api/vendor/sellers/[id]/professional-details/route.ts b/packages/core-plugin/src/api/vendor/sellers/[id]/professional-details/route.ts
index 0d1c8c5dd..d49965558 100644
--- a/packages/core-plugin/src/api/vendor/sellers/[id]/professional-details/route.ts
+++ b/packages/core-plugin/src/api/vendor/sellers/[id]/professional-details/route.ts
@@ -3,11 +3,15 @@ import {
MedusaResponse,
} from "@medusajs/framework"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
-import { HttpTypes, MercurModules } from "@mercurjs/types"
+import {
+ HttpTypes
+} from "@mercurjs/types"
import { VendorUpsertSellerProfessionalDetailsType } from "../../validators"
-import { updateSellerProfessionalDetailsWorkflow } from "../../../../../workflows/seller"
-import SellerModuleService from "../../../../../modules/seller/service"
+import {
+ updateSellerProfessionalDetailsWorkflow,
+ deleteSellerProfessionalDetailsWorkflow,
+} from "../../../../../workflows/seller"
export const POST = async (
req: AuthenticatedMedusaRequest<VendorUpsertSellerProfessionalDetailsType>,
@@ -32,3 +36,24 @@ export const POST = async (
res.json({ seller })
}
+export const DELETE = async (
+ req: AuthenticatedMedusaRequest,
+ res: MedusaResponse<HttpTypes.VendorSellerResponse>
+) => {
+ await deleteSellerProfessionalDetailsWorkflow(req.scope).run({
+ input: {
+ seller_id: req.params.id,
+ },
+ })
+
+ const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
+ const {
+ data: [seller],
+ } = await query.graph({
+ entity: "seller",
+ fields: req.queryConfig.fields,
+ filters: { id: req.params.id },
+ })
+
+ res.json({ seller })
+}
diff --git a/packages/core-plugin/src/api/vendor/sellers/validators.ts b/packages/core-plugin/src/api/vendor/sellers/validators.ts
index 414f18ee4..1d7e52fb1 100644
--- a/packages/core-plugin/src/api/vendor/sellers/validators.ts
+++ b/packages/core-plugin/src/api/vendor/sellers/validators.ts
@@ -48,6 +48,8 @@ export const VendorCreateSellerAccount = z.object({
export type VendorUpdateSellerType = z.infer<typeof VendorUpdateSeller>
export const VendorUpdateSeller = z.object({
name: z.string().optional(),
+ handle: z.string().optional(),
+ email: z.string().email().optional(),
description: z.string().nullable().optional(),
logo: z.string().url().nullable().optional(),
banner: z.string().url().nullable().optional(),
diff --git a/packages/core-plugin/src/api/vendor/subscription/middlewares.ts b/packages/core-plugin/src/api/vendor/subscription/middlewares.ts
new file mode 100644
index 000000000..a0dcd8c36
--- /dev/null
+++ b/packages/core-plugin/src/api/vendor/subscription/middlewares.ts
@@ -0,0 +1,31 @@
+import { validateAndTransformQuery } from "@medusajs/framework"
+import { MiddlewareRoute } from "@medusajs/medusa"
+
+import { VendorGetSellerParams } from "../sellers/validators"
+
+const retrieveVendorSubscriptionQueryConfig = {
+ defaults: [
+ "id",
+ "currency_code",
+ "monthly_amount",
+ "free_months",
+ "requires_orders",
+ "*overrides",
+ "metadata",
+ "created_at",
+ "updated_at",
+ ],
+}
+
+export const vendorSubscriptionMiddlewares: MiddlewareRoute[] = [
+ {
+ method: ["GET"],
+ matcher: "/vendor/subscription",
+ middlewares: [
+ validateAndTransformQuery(
+ VendorGetSellerParams,
+ retrieveVendorSubscriptionQueryConfig
+ ),
+ ],
+ },
+]
diff --git a/packages/core-plugin/src/api/vendor/subscription/route.ts b/packages/core-plugin/src/api/vendor/subscription/route.ts
new file mode 100644
index 000000000..b60a208f0
--- /dev/null
+++ b/packages/core-plugin/src/api/vendor/subscription/route.ts
@@ -0,0 +1,44 @@
+import {
+ AuthenticatedMedusaRequest,
+ MedusaResponse,
+} from "@medusajs/framework"
+import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
+import { HttpTypes } from "@mercurjs/types"
+
+export const GET = async (
+ req: AuthenticatedMedusaRequest,
+ res: MedusaResponse<HttpTypes.VendorSubscriptionResponse>
+) => {
+ const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
+ const sellerId = req.seller_context!.seller_id
+
+ const { data: plans } = await query.graph({
+ entity: "subscription_plan",
+ fields: req.queryConfig.fields,
+ filters: {
+ currency_code: req.seller_context!.currency_code,
+ },
+ })
+
+ const plan = plans[0]
+
+ if (!plan) {
+ res.json({
+ subscription_plan: null,
+ subscription_override: null,
+ })
+ return
+ }
+
+ const override =
+ (plan).overrides?.find(
+ (o: any) => o.reference === "seller" && o.reference_id === sellerId
+ ) ?? null
+
+ const { overrides, ...planWithoutOverrides } = plan as any
+
+ res.json({
+ subscription_plan: planWithoutOverrides,
+ subscription_override: override,
+ })
+}
diff --git a/packages/core-plugin/src/types/seller-context.ts b/packages/core-plugin/src/types/seller-context.ts
index 3344c56c4..7db333c09 100644
--- a/packages/core-plugin/src/types/seller-context.ts
+++ b/packages/core-plugin/src/types/seller-context.ts
@@ -2,6 +2,7 @@ import { SellerMemberDTO } from "@mercurjs/types"
export interface SellerContext {
seller_id: string
+ currency_code: string
seller_member: SellerMemberDTO
}
diff --git a/packages/core-plugin/src/workflows/seller/steps/delete-seller-professional-details.ts b/packages/core-plugin/src/workflows/seller/steps/delete-seller-professional-details.ts
new file mode 100644
index 000000000..cbc7651f7
--- /dev/null
+++ b/packages/core-plugin/src/workflows/seller/steps/delete-seller-professional-details.ts
@@ -0,0 +1,42 @@
+import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
+import { MercurModules, ProfessionalDetailsDTO } from "@mercurjs/types"
+
+import SellerModuleService from "../../../modules/seller/service"
+
+export const deleteSellerProfessionalDetailsStep = createStep<
+ { seller_id: string },
+ void,
+ ProfessionalDetailsDTO | null
+>(
+ "delete-seller-professional-details",
+ async ({ seller_id }, { container }) => {
+ const service =
+ container.resolve<SellerModuleService>(MercurModules.SELLER)
+
+ const existing = await service.listProfessionalDetails({
+ seller_id,
+ })
+
+ if (existing.length > 0) {
+ await service.deleteProfessionalDetails([existing[0].id])
+ return new StepResponse(void 0, existing[0])
+ }
+
+ return new StepResponse(void 0, null)
+ },
+ async (previous, { container }) => {
+ if (!previous) {
+ return
+ }
+
+ const service =
+ container.resolve<SellerModuleService>(MercurModules.SELLER)
+
+ await service.createProfessionalDetails({
+ corporate_name: previous.corporate_name,
+ registration_number: previous.registration_number,
+ tax_id: previous.tax_id,
+ seller_id: (previous as any).seller_id,
+ })
+ }
+)
diff --git a/packages/core-plugin/src/workflows/seller/steps/index.ts b/packages/core-plugin/src/workflows/seller/steps/index.ts
index b938c122f..2bc0779ee 100644
--- a/packages/core-plugin/src/workflows/seller/steps/index.ts
+++ b/packages/core-plugin/src/workflows/seller/steps/index.ts
@@ -18,5 +18,6 @@ export * from "./update-seller-member"
export * from "./validate-not-owner"
export * from "./update-seller-address"
export * from "./update-seller-professional-details"
+export * from "./delete-seller-professional-details"
export * from "./update-payment-details"
export * from "./create-seller-default-roles"
diff --git a/packages/core-plugin/src/workflows/seller/workflows/delete-seller-professional-details.ts b/packages/core-plugin/src/workflows/seller/workflows/delete-seller-professional-details.ts
new file mode 100644
index 000000000..4cc1410e3
--- /dev/null
+++ b/packages/core-plugin/src/workflows/seller/workflows/delete-seller-professional-details.ts
@@ -0,0 +1,34 @@
+import {
+ createHook,
+ createWorkflow,
+ WorkflowResponse,
+} from "@medusajs/framework/workflows-sdk"
+import { AdditionalData } from "@medusajs/framework/types"
+
+import { deleteSellerProfessionalDetailsStep } from "../steps/delete-seller-professional-details"
+
+export const deleteSellerProfessionalDetailsWorkflowId =
+ "delete-seller-professional-details"
+
+type DeleteSellerProfessionalDetailsWorkflowInput = {
+ seller_id: string
+} & AdditionalData
+
+export const deleteSellerProfessionalDetailsWorkflow = createWorkflow(
+ deleteSellerProfessionalDetailsWorkflowId,
+ function (input: DeleteSellerProfessionalDetailsWorkflowInput) {
+ deleteSellerProfessionalDetailsStep({ seller_id: input.seller_id })
+
+ const professionalDetailsDeleted = createHook(
+ "professionalDetailsDeleted",
+ {
+ seller_id: input.seller_id,
+ additional_data: input.additional_data,
+ }
+ )
+
+ return new WorkflowResponse(void 0, {
+ hooks: [professionalDetailsDeleted],
+ })
+ }
+)
diff --git a/packages/core-plugin/src/workflows/seller/workflows/index.ts b/packages/core-plugin/src/workflows/seller/workflows/index.ts
index b5ff1cfcf..505d3db6f 100644
--- a/packages/core-plugin/src/workflows/seller/workflows/index.ts
+++ b/packages/core-plugin/src/workflows/seller/workflows/index.ts
@@ -15,5 +15,6 @@ export * from "./add-seller-member"
export * from "./update-seller-payment-details"
export * from "./update-seller-address"
export * from "./update-seller-professional-details"
+export * from "./delete-seller-professional-details"
export * from "./create-seller-account"
export * from "./create-seller-defaults"
diff --git a/packages/dashboard-sdk/src/types.ts b/packages/dashboard-sdk/src/types.ts
index dc495d9de..70cbdc8cf 100644
--- a/packages/dashboard-sdk/src/types.ts
+++ b/packages/dashboard-sdk/src/types.ts
@@ -1,19 +1,53 @@
import { ComponentType } from "react";
+/**
+ * Configuration for the Mercur dashboard plugin.
+ *
+ * Passed to `mercurDashboardPlugin()` in `vite.config.ts` to configure
+ * the vendor or admin dashboard at build time.
+ *
+ * @example
+ * ```ts
+ * mercurDashboardPlugin({
+ * medusaConfigPath: '../../packages/api/medusa-config.ts',
+ * initialPage: '/setup',
+ * enableSellerRegistration: true,
+ * })
+ * ```
+ */
export interface MercurConfig {
+ /** Path to the MedusaJS config file, resolved relative to the project root. */
medusaConfigPath: string
+ /**
+ * Backend URL for API requests.
+ * @default "http://localhost:9000"
+ */
backendUrl?: string
+ /** Dashboard display name. */
name?: string
+ /** Path to a logo asset for the dashboard. */
logo?: string
+ /**
+ * Override built-in layout components with custom implementations.
+ * Paths are resolved relative to `src/`.
+ */
components?: {
MainSidebar?: string
SettingsSidebar?: string
TopbarActions?: string
},
+ /** Internationalization settings. */
i18n?: {
+ /** The default language code (e.g. `"en"`). */
defaultLanguage: string
}
+ /** Whether to allow new sellers to register from the login screen. */
enableSellerRegistration?: boolean;
+ /**
+ * The route to redirect to when an authenticated user visits `/`.
+ * @default "/products"
+ */
+ initialPage?: string;
}
export interface BuiltMercurConfig extends MercurConfig {
diff --git a/packages/types/src/http/subscription.ts b/packages/types/src/http/subscription.ts
index c3172f8ae..70009d9db 100644
--- a/packages/types/src/http/subscription.ts
+++ b/packages/types/src/http/subscription.ts
@@ -18,3 +18,8 @@ export interface AdminSubscriptionOverrideResponse {
export type AdminSubscriptionOverrideDeleteResponse =
DeleteResponse<"subscription_override">
+
+export interface VendorSubscriptionResponse {
+ subscription_plan: SubscriptionPlanDTO | null
+ subscription_override: SubscriptionOverrideDTO | null
+}
diff --git a/packages/vendor/src/components/common/file-upload/file-upload.tsx b/packages/vendor/src/components/common/file-upload/file-upload.tsx
index bb052986a..dd70e719c 100644
--- a/packages/vendor/src/components/common/file-upload/file-upload.tsx
+++ b/packages/vendor/src/components/common/file-upload/file-upload.tsx
@@ -1,6 +1,7 @@
-import { ArrowDownTray } from "@medusajs/icons";
-import { Text, clx } from "@medusajs/ui";
+import { ArrowDownTray, XMark } from "@medusajs/icons";
+import { IconButton, Text, clx } from "@medusajs/ui";
import { ChangeEvent, DragEvent, useRef, useState } from "react";
+import { formatFileSize } from "@lib/format-file-size";
export interface FileType {
id: string;
@@ -15,7 +16,10 @@ export interface FileUploadProps {
hasError?: boolean;
formats: string[];
onUploaded: (files: FileType[]) => void;
+ onRemove?: () => void;
uploadedImage?: string | null;
+ fileName?: string;
+ fileSize?: number;
}
export const FileUpload = ({
@@ -25,7 +29,10 @@ export const FileUpload = ({
hasError,
formats,
onUploaded,
+ onRemove,
uploadedImage = "",
+ fileName,
+ fileSize,
}: FileUploadProps) => {
const [isDragOver, setIsDragOver] = useState<boolean>(false);
const inputRef = useRef<HTMLInputElement>(null);
@@ -94,6 +101,56 @@ export const FileUpload = ({
handleUploaded(event.target.files);
};
+ const showFileRow = !multiple && uploadedImage;
+
+ if (showFileRow) {
+ return (
+ <div>
+ <div className="bg-ui-bg-component shadow-borders-base flex items-center gap-x-3 rounded-lg p-3">
+ <div className="flex h-10 w-[30px] shrink-0 items-center justify-center overflow-hidden rounded-md">
+ <img
+ src={uploadedImage}
+ alt={fileName}
+ className="h-full w-full object-cover"
+ />
+ </div>
+ <div className="flex flex-1 flex-col">
+ <Text size="small" leading="compact" weight="plus">
+ {fileName || "image"}
+ </Text>
+ {fileSize != null && (
+ <Text
+ size="small"
+ leading="compact"
+ className="text-ui-fg-subtle"
+ >
+ {formatFileSize(fileSize)}
+ </Text>
+ )}
+ </div>
+ {onRemove && (
+ <IconButton
+ type="button"
+ variant="transparent"
+ size="small"
+ onClick={onRemove}
+ >
+ <XMark />
+ </IconButton>
+ )}
+ </div>
+ <input
+ hidden
+ ref={inputRef}
+ onChange={handleFileChange}
+ type="file"
+ accept={formats.join(",")}
+ multiple={false}
+ />
+ </div>
+ );
+ }
+
return (
<div>
<button
@@ -114,26 +171,18 @@ export const FileUpload = ({
},
)}
>
- {uploadedImage ? (
- <div>
- <img src={uploadedImage} className="w-32 h-32 rounded-md" />
- </div>
- ) : (
- <>
- <div className="text-ui-fg-subtle group-disabled:text-ui-fg-disabled flex items-center gap-x-2">
- <ArrowDownTray />
- <Text>{label}</Text>
- </div>
- {!!hint && (
- <Text
- size="small"
- leading="compact"
- className="text-ui-fg-muted group-disabled:text-ui-fg-disabled"
- >
- {hint}
- </Text>
- )}
- </>
+ <div className="text-ui-fg-subtle group-disabled:text-ui-fg-disabled flex items-center gap-x-2">
+ <ArrowDownTray />
+ <Text>{label}</Text>
+ </div>
+ {!!hint && (
+ <Text
+ size="small"
+ leading="compact"
+ className="text-ui-fg-muted group-disabled:text-ui-fg-disabled"
+ >
+ {hint}
+ </Text>
)}
</button>
<input
diff --git a/packages/vendor/src/components/layout/main-layout/main-layout.tsx b/packages/vendor/src/components/layout/main-layout/main-layout.tsx
index da4c3dd5c..8be6dbfab 100644
--- a/packages/vendor/src/components/layout/main-layout/main-layout.tsx
+++ b/packages/vendor/src/components/layout/main-layout/main-layout.tsx
@@ -22,7 +22,13 @@ import { INavItem, NavItem } from "../../layout/nav-item";
import { Shell } from "../../layout/shell";
import { Link, useLocation, useNavigate } from "react-router-dom";
-import { useFeatureFlags, useLogout, useMe, useSelectSeller, useSellers } from "../../../hooks/api";
+import {
+ useFeatureFlags,
+ useLogout,
+ useMe,
+ useSelectSeller,
+ useSellers,
+} from "../../../hooks/api";
import { MercurFeatureFlags } from "@mercurjs/types";
import { queryClient } from "../../../lib/query-client";
import { useSearch } from "../../../providers/search-provider";
@@ -146,6 +152,7 @@ const Logout = () => {
const SwitchStore = ({ currentSellerId }: { currentSellerId: string }) => {
const { t } = useTranslation();
const navigate = useNavigate();
+ const { seller_member } = useMe();
const { seller_members } = useSellers();
const { mutateAsync: selectSeller } = useSelectSeller();
const { feature_flags } = useFeatureFlags();
@@ -204,7 +211,11 @@ const SwitchStore = ({ currentSellerId }: { currentSellerId: string }) => {
<>
{!!seller_members?.length && <DropdownMenu.Separator />}
<DropdownMenu.Item
- onClick={() => navigate("/onboarding")}
+ onClick={() =>
+ navigate("/onboarding", {
+ state: { email: seller_member?.member.email },
+ })
+ }
className="gap-x-2"
>
<Plus className="text-ui-fg-subtle" />
diff --git a/packages/vendor/src/get-route-map.tsx b/packages/vendor/src/get-route-map.tsx
index 385e6bdf7..97e3a543e 100644
--- a/packages/vendor/src/get-route-map.tsx
+++ b/packages/vendor/src/get-route-map.tsx
@@ -897,9 +897,9 @@ export function getRouteMap({
import("./pages/settings/store/professional-details"),
},
{
- path: "configuration",
+ path: "store-closure",
lazy: () =>
- import("./pages/settings/store/configuration"),
+ import("./pages/settings/store/store-closure"),
},
],
},
diff --git a/packages/vendor/src/hooks/api/index.ts b/packages/vendor/src/hooks/api/index.ts
index bdb053c92..19388d85d 100644
--- a/packages/vendor/src/hooks/api/index.ts
+++ b/packages/vendor/src/hooks/api/index.ts
@@ -31,6 +31,7 @@ export * from "./shipping-options"
export * from "./shipping-profiles"
export * from "./stock-locations"
export * from "./store"
+export * from "./subscription"
export * from "./tags"
export * from "./tax-rates"
export * from "./tax-regions"
diff --git a/packages/vendor/src/hooks/api/sellers.tsx b/packages/vendor/src/hooks/api/sellers.tsx
index b3b0fe388..3b44bf986 100644
--- a/packages/vendor/src/hooks/api/sellers.tsx
+++ b/packages/vendor/src/hooks/api/sellers.tsx
@@ -55,6 +55,136 @@ export const useSelectSeller = (
});
};
+export const useUpdateSeller = (
+ id: string,
+ options?: UseMutationOptions<
+ InferClientOutput<typeof sdk.vendor.sellers.$id.mutate>,
+ ClientError,
+ Omit<InferClientInput<typeof sdk.vendor.sellers.$id.mutate>, "$id">
+ >,
+) => {
+ return useMutation({
+ mutationFn: (payload) =>
+ sdk.vendor.sellers.$id.mutate({ $id: id, ...payload }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({
+ queryKey: sellersQueryKeys.all,
+ });
+ queryClient.invalidateQueries({
+ queryKey: membersQueryKeys.me(),
+ });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
+export const useUpdateSellerAddress = (
+ id: string,
+ options?: UseMutationOptions<
+ InferClientOutput<typeof sdk.vendor.sellers.$id.address.mutate>,
+ ClientError,
+ Omit<InferClientInput<typeof sdk.vendor.sellers.$id.address.mutate>, "$id">
+ >,
+) => {
+ return useMutation({
+ mutationFn: (payload) =>
+ sdk.vendor.sellers.$id.address.mutate({ $id: id, ...payload }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({
+ queryKey: sellersQueryKeys.all,
+ });
+ queryClient.invalidateQueries({
+ queryKey: membersQueryKeys.me(),
+ });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
+export const useUpdateSellerPaymentDetails = (
+ id: string,
+ options?: UseMutationOptions<
+ InferClientOutput<typeof sdk.vendor.sellers.$id.paymentDetails.mutate>,
+ ClientError,
+ Omit<
+ InferClientInput<typeof sdk.vendor.sellers.$id.paymentDetails.mutate>,
+ "$id"
+ >
+ >,
+) => {
+ return useMutation({
+ mutationFn: (payload) =>
+ sdk.vendor.sellers.$id.paymentDetails.mutate({ $id: id, ...payload }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({
+ queryKey: sellersQueryKeys.all,
+ });
+ queryClient.invalidateQueries({
+ queryKey: membersQueryKeys.me(),
+ });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
+export const useUpdateSellerProfessionalDetails = (
+ id: string,
+ options?: UseMutationOptions<
+ InferClientOutput<typeof sdk.vendor.sellers.$id.professionalDetails.mutate>,
+ ClientError,
+ Omit<
+ InferClientInput<
+ typeof sdk.vendor.sellers.$id.professionalDetails.mutate
+ >,
+ "$id"
+ >
+ >,
+) => {
+ return useMutation({
+ mutationFn: (payload) =>
+ sdk.vendor.sellers.$id.professionalDetails.mutate({
+ $id: id,
+ ...payload,
+ }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({
+ queryKey: sellersQueryKeys.all,
+ });
+ queryClient.invalidateQueries({
+ queryKey: membersQueryKeys.me(),
+ });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
+export const useDeleteSellerProfessionalDetails = (
+ id: string,
+ options?: UseMutationOptions<
+ InferClientOutput<typeof sdk.vendor.sellers.$id.professionalDetails.delete>,
+ ClientError
+ >,
+) => {
+ return useMutation({
+ mutationFn: () =>
+ sdk.vendor.sellers.$id.professionalDetails.delete({ $id: id }),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({
+ queryKey: sellersQueryKeys.all,
+ });
+ queryClient.invalidateQueries({
+ queryKey: membersQueryKeys.me(),
+ });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
export const useCreateSellerAccount = (
options?: UseMutationOptions<
InferClientOutput<typeof sdk.vendor.sellers.mutate>,
@@ -66,7 +196,7 @@ export const useCreateSellerAccount = (
mutationFn: (payload) => sdk.vendor.sellers.mutate(payload),
onSuccess: (data, variables, context) => {
queryClient.invalidateQueries({
- queryKey: ["users", "me"],
+ queryKey: sellersQueryKeys.all,
});
options?.onSuccess?.(data, variables, context);
},
diff --git a/packages/vendor/src/hooks/api/subscription.tsx b/packages/vendor/src/hooks/api/subscription.tsx
new file mode 100644
index 000000000..3863f7d33
--- /dev/null
+++ b/packages/vendor/src/hooks/api/subscription.tsx
@@ -0,0 +1,30 @@
+import {
+ ClientError,
+ InferClientInput,
+ InferClientOutput,
+} from "@mercurjs/client";
+import { UseQueryOptions, useQuery } from "@tanstack/react-query";
+import { sdk } from "../../lib/client";
+import { queryKeysFactory } from "../../lib/query-key-factory";
+
+const SUBSCRIPTION_QUERY_KEY = "subscription" as const;
+export const subscriptionQueryKeys = queryKeysFactory(SUBSCRIPTION_QUERY_KEY);
+
+export const useSubscription = (
+ query?: InferClientInput<typeof sdk.vendor.subscription.query>,
+ options?: Omit<
+ UseQueryOptions<
+ InferClientOutput<typeof sdk.vendor.subscription.query>,
+ ClientError
+ >,
+ "queryFn" | "queryKey"
+ >,
+) => {
+ const { data, ...rest } = useQuery({
+ queryKey: subscriptionQueryKeys.details(),
+ queryFn: () => sdk.vendor.subscription.query({ ...query }),
+ ...options,
+ });
+
+ return { ...data, ...rest };
+};
diff --git a/packages/vendor/src/i18n/translations/en.json b/packages/vendor/src/i18n/translations/en.json
index 2e71cd8b7..fced85194 100644
--- a/packages/vendor/src/i18n/translations/en.json
+++ b/packages/vendor/src/i18n/translations/en.json
@@ -47,6 +47,8 @@
"countOfTotalSelected": "{{count}} of {{total}} selected",
"plusCount": "+ {{count}}",
"plusCountMore": "+ {{count}} more",
+ "yes": "Yes",
+ "no": "No",
"areYouSure": "Are you sure?",
"areYouSureDescription": "You are about to delete the {{entity}} {{title}}. This action cannot be undone.",
"noRecordsFound": "No records found",
@@ -2578,6 +2580,26 @@
"domain": "Seller",
"manageYourStoresDetails": "Manage your seller's details",
"editStore": "Edit seller",
+ "status": {
+ "active": "Active",
+ "pendingApproval": "Pending approval",
+ "suspended": "Suspended",
+ "terminated": "Terminated"
+ },
+ "alert": {
+ "pendingApproval": {
+ "title": "Your store is under review",
+ "description": "Your application is being reviewed by our team. You will be notified once your store is approved."
+ },
+ "suspended": {
+ "title": "Your store has been suspended",
+ "description": "Your store has been suspended by the platform administrator. Please contact support for more information."
+ },
+ "terminated": {
+ "title": "Your store has been terminated",
+ "description": "Your store has been permanently terminated by the platform administrator. Please contact support for more information."
+ }
+ },
"defaultCurrency": "Default currency",
"defaultLocale": "Default locale",
"defaultRegion": "Default region",
@@ -2600,12 +2622,22 @@
"company": "Company",
"manageCompanyDetails": "Manage your company details",
"logo": "Logo",
+ "banner": "Banner",
"edit": {
"header": "Edit Store"
},
"editCompany": {
"header": "Edit Company"
},
+ "subscription": {
+ "header": "Subscription",
+ "noPlan": "No subscription plan",
+ "noPlanMessage": "Your store does not have an active subscription plan.",
+ "monthlyAmount": "Monthly amount",
+ "freeMonths": "Free months",
+ "freePeriod": "Free period",
+ "requiresOrders": "Requires orders"
+ },
"toast": {
"update": "Store successfully updated",
"currenciesUpdated": "Currencies updated successfully",
@@ -3002,8 +3034,8 @@
"submitted": {
"title": "Application submitted!",
"description": "Your seller account has been created and is pending approval. We'll notify you at {{email}} once your store is reviewed.",
- "hint": "In the meantime, you can log in to complete your store setup.",
- "action": "Go to login"
+ "hint": "In the meantime, you can select your store and complete your setup.",
+ "action": "Continue to dashboard"
}
},
"invite": {
diff --git a/packages/vendor/src/lib/format-file-size.ts b/packages/vendor/src/lib/format-file-size.ts
new file mode 100644
index 000000000..9920fe17c
--- /dev/null
+++ b/packages/vendor/src/lib/format-file-size.ts
@@ -0,0 +1,6 @@
+export const formatFileSize = (bytes: number): string => {
+ if (bytes === 0) return "0 B"
+ const units = ["B", "KB", "MB", "GB"]
+ const i = Math.floor(Math.log(bytes) / Math.log(1024))
+ return `${(bytes / Math.pow(1024, i)).toFixed(2)} ${units[i]}`
+}
diff --git a/packages/vendor/src/pages/home/home.tsx b/packages/vendor/src/pages/home/home.tsx
index c3550838b..4c8457534 100644
--- a/packages/vendor/src/pages/home/home.tsx
+++ b/packages/vendor/src/pages/home/home.tsx
@@ -1,11 +1,12 @@
import { useEffect } from "react"
import { useNavigate } from "react-router-dom"
+import config from "virtual:mercur/config"
export const Home = () => {
const navigate = useNavigate()
useEffect(() => {
- navigate("/products", { replace: true })
+ navigate(config.initialPage ?? "/products", { replace: true })
}, [navigate])
return <div />
diff --git a/packages/vendor/src/pages/onboarding/onboarding.tsx b/packages/vendor/src/pages/onboarding/onboarding.tsx
index c7cab854d..cbc63ade2 100644
--- a/packages/vendor/src/pages/onboarding/onboarding.tsx
+++ b/packages/vendor/src/pages/onboarding/onboarding.tsx
@@ -906,7 +906,7 @@ const SubmittedStep = ({ email }: { email: string }) => {
<Button
variant="secondary"
className="w-full"
- onClick={() => navigate("/login")}
+ onClick={() => navigate("/store-select")}
>
{t("onboarding.submitted.action")}
</Button>
diff --git a/packages/vendor/src/pages/settings/store/_components/store-configuration-section.tsx b/packages/vendor/src/pages/settings/store/_components/store-configuration-section.tsx
index 5179ba7cd..15cddf4f2 100644
--- a/packages/vendor/src/pages/settings/store/_components/store-configuration-section.tsx
+++ b/packages/vendor/src/pages/settings/store/_components/store-configuration-section.tsx
@@ -28,7 +28,7 @@ export const StoreConfigurationSection = ({
{
label: t("actions.edit"),
icon: <PencilSquare />,
- to: "configuration",
+ to: "store-closure",
},
],
},
diff --git a/packages/vendor/src/pages/settings/store/_components/store-detail-header.tsx b/packages/vendor/src/pages/settings/store/_components/store-detail-header.tsx
index ae6a5f364..1c188c657 100644
--- a/packages/vendor/src/pages/settings/store/_components/store-detail-header.tsx
+++ b/packages/vendor/src/pages/settings/store/_components/store-detail-header.tsx
@@ -29,13 +29,13 @@ const getStatusColor = (status: string) => {
const getStatusLabel = (status: string, t: TFunction) => {
switch (status) {
case SellerStatus.OPEN:
- return t("store.status.active", "Active");
+ return t("store.status.active");
case SellerStatus.PENDING_APPROVAL:
- return t("store.status.pendingApproval", "Pending");
+ return t("store.status.pendingApproval");
case SellerStatus.SUSPENDED:
- return t("store.status.suspended", "Suspended");
+ return t("store.status.suspended");
case SellerStatus.TERMINATED:
- return t("store.status.terminated", "Terminated");
+ return t("store.status.terminated");
default:
return status;
}
diff --git a/packages/vendor/src/pages/settings/store/_components/store-general-section.tsx b/packages/vendor/src/pages/settings/store/_components/store-general-section.tsx
index 3026f1901..115c5310d 100644
--- a/packages/vendor/src/pages/settings/store/_components/store-general-section.tsx
+++ b/packages/vendor/src/pages/settings/store/_components/store-general-section.tsx
@@ -1,6 +1,6 @@
import { Children, ReactNode } from "react";
import { Photo } from "@medusajs/icons";
-import { Container, StatusBadge, Text } from "@medusajs/ui";
+import { Container, Text } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { HttpTypes } from "@mercurjs/types";
@@ -82,11 +82,9 @@ export const StoreGeneralSection = ({
<Text size="small" leading="compact" weight="plus">
{t("fields.premium")}
</Text>
- <div>
- <StatusBadge color={seller.is_premium ? "green" : "grey"}>
- {seller.is_premium ? t("fields.true") : t("fields.false")}
- </StatusBadge>
- </div>
+ <Text size="small" leading="compact">
+ {seller.is_premium ? t("general.yes") : t("general.no")}
+ </Text>
</div>
<div className="text-ui-fg-subtle grid grid-cols-2 items-center px-6 py-4">
<Text size="small" leading="compact" weight="plus">
diff --git a/packages/vendor/src/pages/settings/store/_components/store-professional-details-section.tsx b/packages/vendor/src/pages/settings/store/_components/store-professional-details-section.tsx
index d8e024a52..7c755abfe 100644
--- a/packages/vendor/src/pages/settings/store/_components/store-professional-details-section.tsx
+++ b/packages/vendor/src/pages/settings/store/_components/store-professional-details-section.tsx
@@ -1,5 +1,5 @@
import { PencilSquare } from "@medusajs/icons";
-import { Container, Heading, StatusBadge, Text } from "@medusajs/ui";
+import { Container, Heading, Text } from "@medusajs/ui";
import { useTranslation } from "react-i18next";
import { ActionMenu } from "@components/common/action-menu";
@@ -43,11 +43,9 @@ export const StoreProfessionalDetailsSection = ({
<Text size="small" leading="compact" weight="plus">
{t("fields.professional")}
</Text>
- <div>
- <StatusBadge color={isProfessional ? "green" : "grey"}>
- {isProfessional ? t("fields.true") : t("fields.false")}
- </StatusBadge>
- </div>
+ <Text size="small" leading="compact">
+ {isProfessional ? t("general.yes") : t("general.no")}
+ </Text>
</div>
{isProfessional && (
<>
diff --git a/packages/vendor/src/pages/settings/store/_components/store-subscription-section.tsx b/packages/vendor/src/pages/settings/store/_components/store-subscription-section.tsx
new file mode 100644
index 000000000..5d6034c0c
--- /dev/null
+++ b/packages/vendor/src/pages/settings/store/_components/store-subscription-section.tsx
@@ -0,0 +1,77 @@
+import { Container, Heading, Text } from "@medusajs/ui";
+import { useTranslation } from "react-i18next";
+
+import { NoRecords } from "@components/common/empty-table-content";
+import { HttpTypes } from "@mercurjs/types";
+
+type StoreSubscriptionSectionProps = {
+ subscription_plan?: HttpTypes.VendorSubscriptionResponse["subscription_plan"];
+ subscription_override?: HttpTypes.VendorSubscriptionResponse["subscription_override"];
+};
+
+export const StoreSubscriptionSection = ({
+ subscription_plan,
+ subscription_override,
+}: StoreSubscriptionSectionProps) => {
+ const { t } = useTranslation();
+
+ const effectiveMonthlyAmount =
+ subscription_override?.monthly_amount ?? subscription_plan?.monthly_amount;
+ const effectiveFreeMonths =
+ subscription_override?.free_months ?? subscription_plan?.free_months;
+
+ return (
+ <Container className="divide-y p-0">
+ <div className="flex items-center justify-between px-6 py-4">
+ <Heading level="h2">{t("store.subscription.header")}</Heading>
+ </div>
+ {!subscription_plan ? (
+ <NoRecords
+ className="h-[180px]"
+ icon={null}
+ title={t("store.subscription.noPlan")}
+ message={t("store.subscription.noPlanMessage")}
+ />
+ ) : (
+ <div className="text-ui-fg-subtle grid grid-cols-2 items-start px-6 py-4">
+ <Text size="small" leading="compact" weight="plus">
+ {t("store.subscription.monthlyAmount")}
+ </Text>
+ <Text size="small" leading="compact">
+ {effectiveMonthlyAmount}{" "}
+ {subscription_plan.currency_code?.toUpperCase()}
+ </Text>
+
+ <Text size="small" leading="compact" weight="plus">
+ {t("store.subscription.freeMonths")}
+ </Text>
+ <Text size="small" leading="compact">
+ {effectiveFreeMonths}
+ </Text>
+
+ {subscription_override?.free_from && (
+ <>
+ <Text size="small" leading="compact" weight="plus">
+ {t("store.subscription.freePeriod")}
+ </Text>
+ <Text size="small" leading="compact">
+ {new Date(subscription_override.free_from).toLocaleDateString()}
+ {subscription_override.free_to &&
+ ` – ${new Date(subscription_override.free_to).toLocaleDateString()}`}
+ </Text>
+ </>
+ )}
+
+ <Text size="small" leading="compact" weight="plus">
+ {t("store.subscription.requiresOrders")}
+ </Text>
+ <Text size="small" leading="compact">
+ {subscription_plan.requires_orders
+ ? t("general.yes")
+ : t("general.no")}
+ </Text>
+ </div>
+ )}
+ </Container>
+ );
+};
diff --git a/packages/vendor/src/pages/settings/store/address/store-address-form.tsx b/packages/vendor/src/pages/settings/store/address/store-address-form.tsx
index 780f431c3..c8efe1299 100644
--- a/packages/vendor/src/pages/settings/store/address/store-address-form.tsx
+++ b/packages/vendor/src/pages/settings/store/address/store-address-form.tsx
@@ -9,6 +9,7 @@ import { CountrySelect } from "@components/inputs/country-select";
import { RouteDrawer, useRouteModal } from "@components/modals";
import { KeyboundForm } from "@components/utilities/keybound-form";
import { HttpTypes } from "@mercurjs/types";
+import { useUpdateSellerAddress } from "@hooks/api";
type StoreAddressFormProps = {
seller: HttpTypes.StoreSellerResponse["seller"];
@@ -44,27 +45,19 @@ export const StoreAddressForm = ({ seller }: StoreAddressFormProps) => {
resolver: zodResolver(StoreAddressSchema),
});
- // TODO: replace with actual update hook
- const { mutateAsync, isPending } = {
- isPending: false,
- mutateAsync: async (_payload: any, _options?: any) => {
- _options?.onSuccess?.();
- },
- };
+ const { mutateAsync, isPending } = useUpdateSellerAddress(seller.id);
const handleSubmit = form.handleSubmit(async (values) => {
await mutateAsync(
{
- address: {
- first_name: values.first_name,
- last_name: values.last_name,
- address_1: values.address_1 || null,
- city: values.city || null,
- province: values.province || null,
- postal_code: values.postal_code,
- country_code: values.country_code,
- phone: values.phone,
- },
+ first_name: values.first_name,
+ last_name: values.last_name,
+ address_1: values.address_1 || null,
+ city: values.city || null,
+ province: values.province || null,
+ postal_code: values.postal_code,
+ country_code: values.country_code,
+ phone: values.phone,
},
{
onSuccess: () => {
diff --git a/packages/vendor/src/pages/settings/store/edit/_components/edit-store-form.tsx b/packages/vendor/src/pages/settings/store/edit/_components/edit-store-form.tsx
index 93319b1ed..909582c71 100644
--- a/packages/vendor/src/pages/settings/store/edit/_components/edit-store-form.tsx
+++ b/packages/vendor/src/pages/settings/store/edit/_components/edit-store-form.tsx
@@ -1,18 +1,18 @@
import { zodResolver } from "@hookform/resolvers/zod";
-import { Button, Input, toast } from "@medusajs/ui";
+import { Button, Input, Textarea, toast } from "@medusajs/ui";
import { useFieldArray, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import * as zod from "zod";
+import { useCallback } from "react";
import { FileType, FileUpload } from "@components/common/file-upload";
import { Form } from "@components/common/form";
-import { CountrySelect } from "@components/inputs/country-select";
import { RouteDrawer, useRouteModal } from "@components/modals";
import { KeyboundForm } from "@components/utilities/keybound-form";
import { uploadFilesQuery } from "@lib/client";
import { MediaSchema } from "@pages/products/create/constants";
import { HttpTypes } from "@mercurjs/types";
-import { useCallback } from "react";
+import { useUpdateSeller } from "@hooks/api";
type EditStoreFormProps = HttpTypes.StoreSellerResponse;
@@ -20,17 +20,10 @@ const EditStoreSchema = zod.object({
name: zod.string().min(1),
handle: zod.string().min(1),
email: zod.string().email().optional().or(zod.literal("")),
- phone: zod.string().optional().or(zod.literal("")),
- address: zod.object({
- address_1: zod.string().optional().or(zod.literal("")),
- address_2: zod.string().optional().or(zod.literal("")),
- city: zod.string().optional().or(zod.literal("")),
- province: zod.string().optional().or(zod.literal("")),
- postal_code: zod.string().optional().or(zod.literal("")),
- country_code: zod.string().optional().or(zod.literal("")),
- }),
+ description: zod.string().optional().or(zod.literal("")),
+ website_url: zod.string().url().optional().or(zod.literal("")),
media: zod.array(MediaSchema).optional(),
- coverMedia: zod.array(MediaSchema).optional(),
+ bannerMedia: zod.array(MediaSchema).optional(),
});
const SUPPORTED_FORMATS = [
@@ -60,17 +53,14 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
name: seller.name ?? "",
handle: seller.handle ?? "",
email: seller.email ?? "",
- phone: seller.phone ?? "",
- address: {
- address_1: seller.address_1 ?? "",
- address_2: seller.address_2 ?? "",
- city: seller.city ?? "",
- province: seller.province ?? "",
- postal_code: seller.postal_code ?? "",
- country_code: seller.country_code ?? "",
- },
- media: [],
- coverMedia: [],
+ description: seller.description ?? "",
+ website_url: seller.website_url ?? "",
+ media: seller.logo
+ ? [{ id: "existing-logo", url: seller.logo, isThumbnail: false, file: null }]
+ : [],
+ bannerMedia: seller.banner
+ ? [{ id: "existing-banner", url: seller.banner, isThumbnail: false, file: null }]
+ : [],
},
resolver: zodResolver(EditStoreSchema),
});
@@ -81,34 +71,40 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
keyName: "field_id",
});
- const { fields: coverFields } = useFieldArray({
- name: "coverMedia",
+ const { fields: bannerFields } = useFieldArray({
+ name: "bannerMedia",
control: form.control,
keyName: "field_id",
});
- // const { mutateAsync, isPending } = useUpdateMe();
- const { mutateAsync, isPending } = {
- isPending: false,
- mutateAsync: () => {},
- };
+ const { mutateAsync, isPending } = useUpdateSeller(seller.id);
+
const handleSubmit = form.handleSubmit(async (values) => {
- let logoUrl = seller.logo || "";
- let coverImageUrl = seller.cover_image || "";
+ let logoUrl: string | null = null;
+ let bannerUrl: string | null = null;
+
+ const newLogoFile = values.media?.find((m) => m.file);
+ const newBannerFile = values.bannerMedia?.find((m) => m.file);
try {
- if (values.media?.length) {
- const uploaded = await uploadFilesQuery(values.media);
- logoUrl = uploaded.files?.[0]?.url || logoUrl;
+ if (newLogoFile) {
+ const uploaded = await uploadFilesQuery([newLogoFile]);
+ logoUrl = uploaded.files?.[0]?.url || null;
+ } else if (values.media?.length) {
+ logoUrl = values.media[0].url;
}
- if (values.coverMedia?.length) {
- const uploaded = await uploadFilesQuery(values.coverMedia);
- coverImageUrl = uploaded.files?.[0]?.url || coverImageUrl;
+
+ if (newBannerFile) {
+ const uploaded = await uploadFilesQuery([newBannerFile]);
+ bannerUrl = uploaded.files?.[0]?.url || null;
+ } else if (values.bannerMedia?.length) {
+ bannerUrl = values.bannerMedia[0].url;
}
} catch (error) {
if (error instanceof Error) {
toast.error(error.message);
}
+ return;
}
await mutateAsync(
@@ -116,19 +112,14 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
name: values.name,
handle: values.handle,
email: values.email || undefined,
- phone: values.phone || null,
- logo: logoUrl || null,
- cover_image: coverImageUrl || null,
- address_1: values.address.address_1 || null,
- address_2: values.address.address_2 || null,
- city: values.address.city || null,
- province: values.address.province || null,
- postal_code: values.address.postal_code || null,
- country_code: values.address.country_code || null,
+ description: values.description || null,
+ website_url: values.website_url || null,
+ logo: logoUrl,
+ banner: bannerUrl,
},
{
onSuccess: () => {
- toast.success(t("app.menus.store.storeSettings"));
+ toast.success(t("store.toast.update"));
handleSuccess();
},
onError: (error) => {
@@ -139,13 +130,13 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
});
const hasInvalidFiles = useCallback(
- (fileList: FileType[]) => {
+ (fileList: FileType[], fieldName: "media" | "bannerMedia") => {
const invalidFile = fileList.find(
(f) => !SUPPORTED_FORMATS.includes(f.file.type),
);
if (invalidFile) {
- form.setError("media", {
+ form.setError(fieldName, {
type: "invalid_file",
message: t("products.media.invalidFileType", {
name: invalidFile.file.name,
@@ -163,20 +154,20 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
const onLogoUploaded = (files: FileType[]) => {
form.clearErrors("media");
- if (hasInvalidFiles(files)) {
+ if (hasInvalidFiles(files, "media")) {
return;
}
form.setValue("media", [{ ...files[0], isThumbnail: false }]);
};
- const onCoverUploaded = (files: FileType[]) => {
- form.clearErrors("coverMedia");
- if (hasInvalidFiles(files)) {
+ const onBannerUploaded = (files: FileType[]) => {
+ form.clearErrors("bannerMedia");
+ if (hasInvalidFiles(files, "bannerMedia")) {
return;
}
- form.setValue("coverMedia", [{ ...files[0], isThumbnail: false }]);
+ form.setValue("bannerMedia", [{ ...files[0], isThumbnail: false }]);
};
return (
@@ -186,59 +177,7 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
className="flex flex-1 flex-col overflow-hidden"
>
<RouteDrawer.Body className="flex flex-col gap-y-8 overflow-y-auto">
- <div className="grid grid-cols-1 gap-4">
- <Form.Field
- name="media"
- control={form.control}
- render={() => {
- const previewUrl = logoFields[0]?.url || seller.logo;
-
- return (
- <Form.Item>
- <Form.Label>{t("store.logo", "Logo")}</Form.Label>
- <Form.Control>
- <FileUpload
- uploadedImage={previewUrl}
- multiple={false}
- label={t("products.media.uploadImagesLabel")}
- hint={t("products.media.uploadImagesHint")}
- hasError={!!form.formState.errors.media}
- formats={SUPPORTED_FORMATS}
- onUploaded={onLogoUploaded}
- />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- );
- }}
- />
- <Form.Field
- name="coverMedia"
- control={form.control}
- render={() => {
- const previewUrl = coverFields[0]?.url || seller.cover_image;
-
- return (
- <Form.Item>
- <Form.Label>
- {t("store.coverImage", "Cover image")}
- </Form.Label>
- <Form.Control>
- <FileUpload
- uploadedImage={previewUrl}
- multiple={false}
- label={t("products.media.uploadImagesLabel")}
- hint={t("products.media.uploadImagesHint")}
- hasError={!!form.formState.errors.coverMedia}
- formats={SUPPORTED_FORMATS}
- onUploaded={onCoverUploaded}
- />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- );
- }}
- />
+ <div className="flex flex-col gap-y-4">
<Form.Field
control={form.control}
name="name"
@@ -246,7 +185,7 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
<Form.Item>
<Form.Label>{t("fields.name")}</Form.Label>
<Form.Control>
- <Input size="small" {...field} />
+ <Input {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
@@ -259,7 +198,7 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
<Form.Item>
<Form.Label>{t("fields.handle")}</Form.Label>
<Form.Control>
- <Input size="small" {...field} />
+ <Input {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
@@ -272,7 +211,7 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
<Form.Item>
<Form.Label>{t("fields.email")}</Form.Label>
<Form.Control>
- <Input size="small" type="email" {...field} />
+ <Input type="email" {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
@@ -280,95 +219,89 @@ export const EditStoreForm = ({ seller }: EditStoreFormProps) => {
/>
<Form.Field
control={form.control}
- name="phone"
+ name="description"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>{t("fields.phone")}</Form.Label>
+ <Form.Label optional>{t("fields.description")}</Form.Label>
<Form.Control>
- <Input size="small" {...field} />
+ <Textarea {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
)}
/>
- {/* Address Fields, using address subobject as in edit-location-form */}
<Form.Field
control={form.control}
- name="address.address_1"
+ name="website_url"
render={({ field }) => (
<Form.Item>
- <Form.Label optional>{t("fields.address")}</Form.Label>
+ <Form.Label optional>{t("fields.website")}</Form.Label>
<Form.Control>
- <Input size="small" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="address.address_2"
- render={({ field }) => (
- <Form.Item>
- <Form.Label optional>{t("fields.address2")}</Form.Label>
- <Form.Control>
- <Input size="small" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="address.city"
- render={({ field }) => (
- <Form.Item>
- <Form.Label optional>{t("fields.city")}</Form.Label>
- <Form.Control>
- <Input size="small" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="address.province"
- render={({ field }) => (
- <Form.Item>
- <Form.Label optional>{t("fields.state")}</Form.Label>
- <Form.Control>
- <Input size="small" {...field} />
+ <Input {...field} />
</Form.Control>
<Form.ErrorMessage />
</Form.Item>
)}
/>
+ </div>
+ <div className="flex flex-col gap-y-4">
<Form.Field
+ name="media"
control={form.control}
- name="address.postal_code"
- render={({ field }) => (
- <Form.Item>
- <Form.Label optional>{t("fields.postalCode")}</Form.Label>
- <Form.Control>
- <Input size="small" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
+ render={() => {
+ const logoFile = logoFields[0];
+ const previewUrl = logoFile?.url || null;
+
+ return (
+ <Form.Item>
+ <Form.Label optional>{t("store.logo")}</Form.Label>
+ <Form.Control>
+ <FileUpload
+ uploadedImage={previewUrl}
+ fileName={logoFile?.file?.name}
+ fileSize={logoFile?.file?.size}
+ multiple={false}
+ label={t("products.media.uploadImagesLabel")}
+ hint={t("products.media.uploadImagesHint")}
+ hasError={!!form.formState.errors.media}
+ formats={SUPPORTED_FORMATS}
+ onUploaded={onLogoUploaded}
+ onRemove={() => form.setValue("media", [])}
+ />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ );
+ }}
/>
<Form.Field
+ name="bannerMedia"
control={form.control}
- name="address.country_code"
- render={({ field }) => (
- <Form.Item>
- <Form.Label optional>{t("fields.country")}</Form.Label>
- <Form.Control>
- <CountrySelect {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
+ render={() => {
+ const bannerFile = bannerFields[0];
+ const previewUrl = bannerFile?.url || null;
+
+ return (
+ <Form.Item>
+ <Form.Label optional>{t("store.banner")}</Form.Label>
+ <Form.Control>
+ <FileUpload
+ uploadedImage={previewUrl}
+ fileName={bannerFile?.file?.name}
+ fileSize={bannerFile?.file?.size}
+ multiple={false}
+ label={t("products.media.uploadImagesLabel")}
+ hint={t("products.media.uploadImagesHint")}
+ hasError={!!form.formState.errors.bannerMedia}
+ formats={SUPPORTED_FORMATS}
+ onUploaded={onBannerUploaded}
+ onRemove={() => form.setValue("bannerMedia", [])}
+ />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ );
+ }}
/>
</div>
</RouteDrawer.Body>
diff --git a/packages/vendor/src/pages/settings/store/payment-details/store-payment-details-form.tsx b/packages/vendor/src/pages/settings/store/payment-details/store-payment-details-form.tsx
index 01884f81f..41834fff0 100644
--- a/packages/vendor/src/pages/settings/store/payment-details/store-payment-details-form.tsx
+++ b/packages/vendor/src/pages/settings/store/payment-details/store-payment-details-form.tsx
@@ -8,6 +8,7 @@ import { Form } from "@components/common/form";
import { RouteDrawer, useRouteModal } from "@components/modals";
import { KeyboundForm } from "@components/utilities/keybound-form";
import { HttpTypes } from "@mercurjs/types";
+import { useUpdateSellerPaymentDetails } from "@hooks/api";
type StorePaymentDetailsFormProps = {
seller: HttpTypes.StoreSellerResponse["seller"];
@@ -50,13 +51,7 @@ export const StorePaymentDetailsForm = ({
const selectedType = form.watch("type");
- // TODO: replace with actual update hook
- const { mutateAsync, isPending } = {
- isPending: false,
- mutateAsync: async (_payload: any, _options?: any) => {
- _options?.onSuccess?.();
- },
- };
+ const { mutateAsync, isPending } = useUpdateSellerPaymentDetails(seller.id);
const handleSubmit = form.handleSubmit(async (values) => {
const isABA = values.type === "aba";
diff --git a/packages/vendor/src/pages/settings/store/professional-details/store-professional-details-form.tsx b/packages/vendor/src/pages/settings/store/professional-details/store-professional-details-form.tsx
index 2b291fe38..86164bad5 100644
--- a/packages/vendor/src/pages/settings/store/professional-details/store-professional-details-form.tsx
+++ b/packages/vendor/src/pages/settings/store/professional-details/store-professional-details-form.tsx
@@ -8,6 +8,10 @@ import { Form } from "@components/common/form";
import { RouteDrawer, useRouteModal } from "@components/modals";
import { KeyboundForm } from "@components/utilities/keybound-form";
import { HttpTypes } from "@mercurjs/types";
+import {
+ useUpdateSellerProfessionalDetails,
+ useDeleteSellerProfessionalDetails,
+} from "@hooks/api";
type StoreProfessionalDetailsFormProps = {
seller: HttpTypes.StoreSellerResponse["seller"];
@@ -21,7 +25,9 @@ const StoreProfessionalDetailsSchema = zod
tax_id: zod.string().optional().or(zod.literal("")),
})
.refine(
- (data) => !data.is_professional || (data.corporate_name && data.corporate_name.length > 0),
+ (data) =>
+ !data.is_professional ||
+ (data.corporate_name && data.corporate_name.length > 0),
{
message: "Corporate name is required for professional sellers",
path: ["corporate_name"],
@@ -47,18 +53,15 @@ export const StoreProfessionalDetailsForm = ({
const isProfessional = form.watch("is_professional");
- // TODO: replace with actual update hook
- const { mutateAsync, isPending } = {
- isPending: false,
- mutateAsync: async (_payload: any, _options?: any) => {
- _options?.onSuccess?.();
- },
- };
+ const { mutateAsync, isPending } = useUpdateSellerProfessionalDetails(
+ seller.id,
+ );
+ const { mutateAsync: deleteProfessionalDetails, isPending: isDeleting } =
+ useDeleteSellerProfessionalDetails(seller.id);
const handleSubmit = form.handleSubmit(async (values) => {
if (!values.is_professional) {
- // TODO: handle removing professional details
- await mutateAsync(null, {
+ await deleteProfessionalDetails(undefined, {
onSuccess: () => {
toast.success(
t(
@@ -181,10 +184,7 @@ export const StoreProfessionalDetailsForm = ({
render={({ field }) => (
<Form.Item>
<Form.Label optional>
- {t(
- "store.professionalDetails.fields.taxId",
- "Tax ID",
- )}
+ {t("store.professionalDetails.fields.taxId", "Tax ID")}
</Form.Label>
<Form.Control>
<Input size="small" {...field} />
@@ -203,7 +203,7 @@ export const StoreProfessionalDetailsForm = ({
{t("actions.cancel")}
</Button>
</RouteDrawer.Close>
- <Button type="submit" size="small" isLoading={isPending}>
+ <Button type="submit" size="small" isLoading={isPending || isDeleting}>
{t("actions.save")}
</Button>
</div>
diff --git a/packages/vendor/src/pages/settings/store/configuration/index.tsx b/packages/vendor/src/pages/settings/store/store-closure/index.tsx
similarity index 100%
rename from packages/vendor/src/pages/settings/store/configuration/index.tsx
rename to packages/vendor/src/pages/settings/store/store-closure/index.tsx
diff --git a/packages/vendor/src/pages/settings/store/configuration/store-closure-form.tsx b/packages/vendor/src/pages/settings/store/store-closure/store-closure-form.tsx
similarity index 95%
rename from packages/vendor/src/pages/settings/store/configuration/store-closure-form.tsx
rename to packages/vendor/src/pages/settings/store/store-closure/store-closure-form.tsx
index 0cfad3850..e11c7d16e 100644
--- a/packages/vendor/src/pages/settings/store/configuration/store-closure-form.tsx
+++ b/packages/vendor/src/pages/settings/store/store-closure/store-closure-form.tsx
@@ -8,6 +8,7 @@ import { Form } from "@components/common/form";
import { RouteDrawer, useRouteModal } from "@components/modals";
import { KeyboundForm } from "@components/utilities/keybound-form";
import { HttpTypes } from "@mercurjs/types";
+import { useUpdateSeller } from "@hooks/api";
type StoreClosureFormProps = {
seller: HttpTypes.StoreSellerResponse["seller"];
@@ -37,13 +38,7 @@ export const StoreClosureForm = ({ seller }: StoreClosureFormProps) => {
resolver: zodResolver(StoreClosureSchema),
});
- // TODO: replace with actual update hook
- const { mutateAsync, isPending } = {
- isPending: false,
- mutateAsync: async (_payload: any, _options?: any) => {
- _options?.onSuccess?.();
- },
- };
+ const { mutateAsync, isPending } = useUpdateSeller(seller.id);
const handleSubmit = form.handleSubmit(async (data) => {
await mutateAsync(
diff --git a/packages/vendor/src/pages/settings/store/store-detail-page.tsx b/packages/vendor/src/pages/settings/store/store-detail-page.tsx
index 12eedd22b..d6560607e 100644
--- a/packages/vendor/src/pages/settings/store/store-detail-page.tsx
+++ b/packages/vendor/src/pages/settings/store/store-detail-page.tsx
@@ -1,12 +1,16 @@
import { Children, ReactNode } from "react";
+import { Alert, Text } from "@medusajs/ui";
+import { useTranslation } from "react-i18next";
import { TwoColumnPageSkeleton } from "@components/common/skeleton";
import { TwoColumnPage } from "@components/layout/pages";
-import { useMe } from "@/hooks/api";
+import { useMe, useSubscription } from "@/hooks/api";
+import { SellerStatus } from "@mercurjs/types";
import { StoreAddressSection } from "./_components/store-address-section";
import { StoreConfigurationSection } from "./_components/store-configuration-section";
import { StoreGeneralSection } from "./_components/store-general-section";
+import { StoreSubscriptionSection } from "./_components/store-subscription-section";
import { StorePaymentDetailsSection } from "./_components/store-payment-details-section";
import { StoreProfessionalDetailsSection } from "./_components/store-professional-details-section";
import {
@@ -17,34 +21,85 @@ import {
} from "./_components/store-detail-header";
const Root = ({ children }: { children?: ReactNode }) => {
+ const { t } = useTranslation();
const { seller_member, isPending, isError, error } = useMe();
+ const {
+ subscription_plan,
+ subscription_override,
+ isPending: isSubscriptionPending,
+ } = useSubscription();
const seller = seller_member?.seller;
- if (isPending || !seller) {
- return <TwoColumnPageSkeleton mainSections={3} sidebarSections={2} />;
+ if (isPending || isSubscriptionPending || !seller) {
+ return <TwoColumnPageSkeleton mainSections={3} sidebarSections={3} />;
}
if (isError) {
throw error;
}
- return Children.count(children) > 0 ? (
- <TwoColumnPage data={seller} hasOutlet>
- {children}
- </TwoColumnPage>
- ) : (
- <TwoColumnPage data={seller} hasOutlet>
- <TwoColumnPage.Main>
- <StoreGeneralSection seller={seller} />
- <StorePaymentDetailsSection seller={seller} />
- <StoreProfessionalDetailsSection seller={seller} />
- </TwoColumnPage.Main>
- <TwoColumnPage.Sidebar>
- <StoreConfigurationSection seller={seller} />
- <StoreAddressSection seller={seller} />
- </TwoColumnPage.Sidebar>
- </TwoColumnPage>
+ const statusAlert = (() => {
+ switch (seller.status) {
+ case SellerStatus.PENDING_APPROVAL:
+ return {
+ variant: "warning" as const,
+ title: t("store.alert.pendingApproval.title"),
+ description: t("store.alert.pendingApproval.description"),
+ };
+ case SellerStatus.SUSPENDED:
+ return {
+ variant: "error" as const,
+ title: t("store.alert.suspended.title"),
+ description:
+ seller.status_reason || t("store.alert.suspended.description"),
+ };
+ case SellerStatus.TERMINATED:
+ return {
+ variant: "error" as const,
+ title: t("store.alert.terminated.title"),
+ description:
+ seller.status_reason || t("store.alert.terminated.description"),
+ };
+ default:
+ return null;
+ }
+ })();
+
+ return (
+ <div className="flex flex-col gap-y-3">
+ {statusAlert && (
+ <Alert variant={statusAlert.variant} dismissible className="p-5">
+ <div className="text-ui-fg-subtle txt-small pb-2 font-medium leading-[20px]">
+ {statusAlert.title}
+ </div>
+ <Text className="text-ui-fg-subtle txt-small leading-normal">
+ {statusAlert.description}
+ </Text>
+ </Alert>
+ )}
+ {Children.count(children) > 0 ? (
+ <TwoColumnPage data={seller} hasOutlet>
+ {children}
+ </TwoColumnPage>
+ ) : (
+ <TwoColumnPage data={seller} hasOutlet>
+ <TwoColumnPage.Main>
+ <StoreGeneralSection seller={seller} />
+ <StorePaymentDetailsSection seller={seller} />
+ <StoreProfessionalDetailsSection seller={seller} />
+ </TwoColumnPage.Main>
+ <TwoColumnPage.Sidebar>
+ <StoreConfigurationSection seller={seller} />
+ <StoreAddressSection seller={seller} />
+ <StoreSubscriptionSection
+ subscription_plan={subscription_plan}
+ subscription_override={subscription_override}
+ />
+ </TwoColumnPage.Sidebar>
+ </TwoColumnPage>
+ )}
+ </div>
);
};
@@ -56,6 +111,7 @@ export const StoreDetailPage = Object.assign(Root, {
MainProfessionalDetailsSection: StoreProfessionalDetailsSection,
SidebarConfigurationSection: StoreConfigurationSection,
SidebarAddressSection: StoreAddressSection,
+ SidebarSubscriptionSection: StoreSubscriptionSection,
Header: StoreDetailHeader,
HeaderTitle: StoreDetailTitle,
HeaderActions: StoreDetailActions,