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.

refactor(vendor): remove copy-payment-link, register page, and storefrontUrl config

vholikdf591a0045d5
diff --git a/packages/dashboard-sdk/src/types.ts b/packages/dashboard-sdk/src/types.ts
index 233f59af3..cf9221fcd 100644
--- a/packages/dashboard-sdk/src/types.ts
+++ b/packages/dashboard-sdk/src/types.ts
@@ -8,8 +8,6 @@ export interface MercurConfig {
SettingsSidebar?: string
},
baseUrl: string;
- storefrontUrl?: string;
- disableSellersRegistration?: boolean;
}
export interface BuiltMercurConfig extends MercurConfig {
diff --git a/packages/vendor/src/get-route-map.tsx b/packages/vendor/src/get-route-map.tsx
index 2794a4be7..cf896c199 100644
--- a/packages/vendor/src/get-route-map.tsx
+++ b/packages/vendor/src/get-route-map.tsx
@@ -1155,10 +1155,6 @@ export function getRouteMap({
path: "/login",
lazy: () => import("./pages/login"),
},
- {
- path: "/register",
- lazy: () => import("./pages/register"),
- },
{
path: "/reset-password",
lazy: () => import("./pages/reset-password"),
diff --git a/packages/vendor/src/i18n/translations/en.json b/packages/vendor/src/i18n/translations/en.json
index b7ace692f..16ec0d282 100644
--- a/packages/vendor/src/i18n/translations/en.json
+++ b/packages/vendor/src/i18n/translations/en.json
@@ -2941,13 +2941,7 @@
"login": {
"forgotPassword": "Forgot password? - <0>Reset</0>",
"title": "Welcome to Mercur",
- "hint": "Sign in to access the vendor area",
- "notSellerYet": "Not a seller yet? - <0>Register</0>"
- },
- "register": {
- "title": "Create your account",
- "hint": "Register as a seller on Mercur",
- "alreadySeller": "Already a seller? - <0>Log in</0>"
+ "hint": "Sign in to access the vendor area"
},
"validation": {
"rules": {
diff --git a/packages/vendor/src/lib/storefront.ts b/packages/vendor/src/lib/storefront.ts
deleted file mode 100644
index a7544bc55..000000000
--- a/packages/vendor/src/lib/storefront.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-import config from "virtual:mercur/config"
-
-export const MEDUSA_STOREFRONT_URL =
- config.storefrontUrl ?? "http://localhost:8000"
diff --git a/packages/vendor/src/pages/login/login.tsx b/packages/vendor/src/pages/login/login.tsx
index ed4ecfc31..ef206b868 100644
--- a/packages/vendor/src/pages/login/login.tsx
+++ b/packages/vendor/src/pages/login/login.tsx
@@ -165,17 +165,6 @@ export const Login = () => {
]}
/>
</span>
- <span className="text-ui-fg-muted txt-small">
- <Trans
- i18nKey="login.notSellerYet"
- components={[
- <Link
- to="/register"
- className="text-ui-fg-interactive transition-fg hover:text-ui-fg-interactive-hover focus-visible:text-ui-fg-interactive-hover font-medium outline-none"
- />,
- ]}
- />
- </span>
</div>
</div>
)
diff --git a/packages/vendor/src/pages/orders/[id]/_components/copy-payment-link/copy-payment-link.tsx b/packages/vendor/src/pages/orders/[id]/_components/copy-payment-link/copy-payment-link.tsx
deleted file mode 100644
index 440773f64..000000000
--- a/packages/vendor/src/pages/orders/[id]/_components/copy-payment-link/copy-payment-link.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import { CheckCircleSolid, SquareTwoStack } from "@medusajs/icons"
-import { HttpTypes } from "@medusajs/types"
-import { Button, Tooltip } from "@medusajs/ui"
-import copy from "copy-to-clipboard"
-import React, { useState } from "react"
-import { useTranslation } from "react-i18next"
-import { getStylizedAmount } from "@lib/money-amount-helpers"
-import { MEDUSA_STOREFRONT_URL } from "@lib/storefront"
-
-type CopyPaymentLinkProps = {
- paymentCollection: Partial<HttpTypes.AdminPaymentCollection>
- order: HttpTypes.AdminOrder
-}
-
-/**
- * This component is based on the `button` element and supports all of its props
- */
-const CopyPaymentLink = React.forwardRef<any, CopyPaymentLinkProps>(
- ({ paymentCollection, order }: CopyPaymentLinkProps, ref) => {
- const [done, setDone] = useState(false)
- const [open, setOpen] = useState(false)
- const [text, setText] = useState("CopyPaymentLink")
- const { t } = useTranslation()
-
- const copyToClipboard = async (
- e:
- | React.MouseEvent<HTMLElement, MouseEvent>
- | React.MouseEvent<HTMLButtonElement, MouseEvent>
- ) => {
- e.stopPropagation()
-
- setDone(true)
- copy(`${MEDUSA_STOREFRONT_URL}/payment-collection/${paymentCollection}`)
-
- setTimeout(() => {
- setDone(false)
- }, 2000)
- }
-
- React.useEffect(() => {
- if (done) {
- setText(t("actions.copied"))
- return
- }
-
- setTimeout(() => {
- setText(t("actions.copy"))
- }, 500)
- }, [done])
-
- return (
- <Tooltip content={text} open={done || open} onOpenChange={setOpen}>
- <Button
- ref={ref}
- variant="secondary"
- size="small"
- aria-label="CopyPaymentLink code snippet"
- onClick={copyToClipboard}
- >
- {done ? (
- <CheckCircleSolid className="inline" />
- ) : (
- <SquareTwoStack className="inline" />
- )}
- {t("orders.payment.paymentLink", {
- amount: getStylizedAmount(
- paymentCollection.amount as number,
- order?.currency_code
- ),
- })}
- </Button>
- </Tooltip>
- )
- }
-)
-CopyPaymentLink.displayName = "CopyPaymentLink"
-
-export { CopyPaymentLink }
diff --git a/packages/vendor/src/pages/orders/[id]/_components/copy-payment-link/index.ts b/packages/vendor/src/pages/orders/[id]/_components/copy-payment-link/index.ts
deleted file mode 100644
index e496ff07b..000000000
--- a/packages/vendor/src/pages/orders/[id]/_components/copy-payment-link/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export * from "./copy-payment-link"
diff --git a/packages/vendor/src/pages/orders/[id]/_components/index.ts b/packages/vendor/src/pages/orders/[id]/_components/index.ts
index 89aefd979..743e91207 100644
--- a/packages/vendor/src/pages/orders/[id]/_components/index.ts
+++ b/packages/vendor/src/pages/orders/[id]/_components/index.ts
@@ -1,4 +1,3 @@
-export * from "./copy-payment-link"
export * from "./order-activity-section"
export * from "./order-customer-section"
export * from "./order-fulfillment-section"
diff --git a/packages/vendor/src/pages/orders/[id]/_components/order-summary-section/order-summary-section.tsx b/packages/vendor/src/pages/orders/[id]/_components/order-summary-section/order-summary-section.tsx
index b8114b454..683ee437e 100644
--- a/packages/vendor/src/pages/orders/[id]/_components/order-summary-section/order-summary-section.tsx
+++ b/packages/vendor/src/pages/orders/[id]/_components/order-summary-section/order-summary-section.tsx
@@ -32,7 +32,6 @@ import {
isAmountLessThenRoundingError,
} from "@lib/money-amount-helpers"
import { getTotalCaptured } from "@lib/payment"
-import { CopyPaymentLink } from "../copy-payment-link/copy-payment-link"
import ShippingInfoPopover from "./shipping-info-popover"
import { Thumbnail } from "@components/common/thumbnail"
@@ -167,13 +166,6 @@ export const OrderSummarySection = ({
</ActionMenu>
))}
- {showPayment && (
- <CopyPaymentLink
- paymentCollection={unpaidPaymentCollection}
- order={order}
- />
- )}
-
{showPayment && (
<Button
size="small"
diff --git a/packages/vendor/src/pages/register/index.ts b/packages/vendor/src/pages/register/index.ts
deleted file mode 100644
index 8952c795d..000000000
--- a/packages/vendor/src/pages/register/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { Register as Component } from "./register"
diff --git a/packages/vendor/src/pages/register/password-hints.tsx b/packages/vendor/src/pages/register/password-hints.tsx
deleted file mode 100644
index 0e0133f8b..000000000
--- a/packages/vendor/src/pages/register/password-hints.tsx
+++ /dev/null
@@ -1,92 +0,0 @@
-import { useEffect, useMemo, type FC } from 'react';
-
-import { CheckCircleMiniSolid } from '@medusajs/icons';
-import { Container } from '@medusajs/ui';
-import { useTranslation } from 'react-i18next';
-
-function validatePassword(password: string) {
- const errors = {
- tooShort: password.length < 12,
- noLower: !/[a-z]/.test(password),
- noUpper: !/[A-Z]/.test(password),
- noDigit: !/[0-9]/.test(password),
- noSpecialChar: !/[!@#$%^&*(),.?":{}|<>_\-+=\[\]\\\/~`]/.test(password),
- };
-
- return {
- isValid: !Object.values(errors).some(Boolean),
- errors,
- };
-}
-
-type ValidationState = {
- isValid: boolean;
- lower: boolean;
- upper: boolean;
- '12chars': boolean;
- digit: boolean;
- specialChar: boolean;
-};
-
-const ruleKeys = ['12chars', 'lower', 'upper', 'digit', 'specialChar'] as const;
-type RuleKey = (typeof ruleKeys)[number];
-
-const PasswordRule: FC<{ passed: boolean; label: string }> = ({
- passed,
- label,
-}) => {
- return (
- <p
- className={`flex items-center gap-2 text-xs ${passed ? 'text-ui-fg-subtle' : 'text-ui-fg-muted'}`}
- >
- <CheckCircleMiniSolid
- className={passed ? 'text-ui-tag-green-icon' : 'text-ui-fg-disabled'}
- />
- {label}
- </p>
- );
-};
-
-export const PasswordValidator = ({
- password,
- setError,
-}: {
- password: string;
- setError: (error: ValidationState) => void;
-}) => {
- const { t } = useTranslation();
-
- const validation = useMemo(() => validatePassword(password), [password]);
-
- const state: ValidationState = useMemo(
- () => ({
- isValid: validation.isValid,
- lower: !validation.errors.noLower,
- upper: !validation.errors.noUpper,
- '12chars': !validation.errors.tooShort,
- digit: !validation.errors.noDigit,
- specialChar: !validation.errors.noSpecialChar,
- }),
- [validation]
- );
-
- useEffect(() => {
- setError(state);
- }, [state, setError]);
-
- const ruleLabels: Record<RuleKey, string> = {
- '12chars': t('validation.rules.12chars'),
- lower: t('validation.rules.lower'),
- upper: t('validation.rules.upper'),
- digit: t('validation.rules.digit'),
- specialChar: t('validation.rules.specialChar'),
- };
-
- return (
- <Container className="flex flex-col gap-y-1 p-2">
- {ruleKeys.map((key) => (
- <PasswordRule key={key} passed={state[key]} label={ruleLabels[key]} />
- ))}
- </Container>
- );
-};
diff --git a/packages/vendor/src/pages/register/register-schema.ts b/packages/vendor/src/pages/register/register-schema.ts
deleted file mode 100644
index 262ac5a09..000000000
--- a/packages/vendor/src/pages/register/register-schema.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import * as z from 'zod';
-
-export const RegisterSchema = z.object({
- name: z.string().min(2, { message: "Name should be a string" }),
- email: z.string().email({ message: "Invalid email" }),
- password: z.string()
- .min(12, { message: "at least 12 characters" })
- .regex(/[a-z]/, { message: "at least one lowercase case" })
- .regex(/[A-Z]/, { message: "at least one upper case" })
- .regex(/[0-9]/, { message: "at least one digit" })
- .regex(/[!@#$%^&*(),.?":{}|<>_\-+=\[\]\\\/~`]/, { message: "at least one special character" }),
- confirmPassword: z.string()
-}) .refine((data) => data.password === data.confirmPassword, {
- message: "passwords don't match",
- path: ['confirmPassword'],
-});
\ No newline at end of file
diff --git a/packages/vendor/src/pages/register/register.tsx b/packages/vendor/src/pages/register/register.tsx
deleted file mode 100644
index 8ab4b97c3..000000000
--- a/packages/vendor/src/pages/register/register.tsx
+++ /dev/null
@@ -1,259 +0,0 @@
-import { useState } from 'react';
-
-import { zodResolver } from '@hookform/resolvers/zod';
-import { Alert, Button, Heading, Hint, Input, Text } from '@medusajs/ui';
-import { useForm } from 'react-hook-form';
-import { Trans, useTranslation } from 'react-i18next';
-import { Link } from 'react-router-dom';
-import * as z from 'zod';
-
-import { Form } from '@components/common/form';
-import AvatarBox from '@components/common/logo-box/avatar-box';
-import { useSignUpWithEmailPass } from '@hooks/api';
-import { PasswordValidator } from './password-hints';
-import { RegisterSchema } from './register-schema';
-
-export const Register = () => {
- const [success, setSuccess] = useState(false);
- const { t } = useTranslation();
-
- const form = useForm<z.infer<typeof RegisterSchema>>({
- resolver: zodResolver(RegisterSchema),
- defaultValues: {
- name: '',
- email: '',
- password: '',
- confirmPassword: ''
- }
- });
-
- const [passwordValidation, setPasswordValidation] = useState({
- isValid: false,
- lower: false,
- upper: false,
- '12chars': false,
- digit: false,
- specialChar: false,
- });
-
- const { mutateAsync, isPending } = useSignUpWithEmailPass();
-
- const handleSubmit = form.handleSubmit(async ({ name, email, password, confirmPassword }) => {
- if (!passwordValidation.isValid) {
- return;
- }
- if (password !== confirmPassword) {
- form.setError('password', {
- type: 'manual',
- message: "Password and Confirm Password don't match"
- });
- form.setError('confirmPassword', {
- type: 'manual',
- message: "Password and Confirm Password don't match"
- });
-
- return null;
- }
-
- await mutateAsync(
- {
- name,
- email,
- password,
- confirmPassword
- },
- {
- onError: error => {
- const status = 'status' in error ? error.status : undefined;
-
- if (status === 401) {
- form.setError('email', {
- type: 'manual',
- message: error.message
- });
-
- return;
- }
-
- if (status === 409) {
- form.setError('email', {
- type: 'manual',
- message: 'Provided email is already taken'
- });
-
- return;
- }
-
- form.setError('root.serverError', {
- type: 'manual',
- message: error.message
- });
- },
- onSuccess: () => {
- setSuccess(true);
- }
- }
- );
- });
-
- const serverError = form.formState.errors?.root?.serverError?.message;
- const validationError =
- form.formState.errors.email?.message ||
- form.formState.errors.password?.message ||
- form.formState.errors.name?.message ||
- form.formState.errors.confirmPassword?.message;
-
- if (success)
- return (
- <div className="flex min-h-dvh w-dvw items-center justify-center bg-ui-bg-subtle">
- <div className="mb-4 flex flex-col items-center">
- <Heading>Thank You for registering!</Heading>
- <Text
- size="small"
- className="mt-2 max-w-[320px] text-center text-ui-fg-subtle"
- >
- You may need to wait for admin authorization before logging in. A confirmation email
- will be sent to you shortly.
- </Text>
-
- <Link to="/login">
- <Button className="mt-8">Back to login page</Button>
- </Link>
- </div>
- </div>
- );
-
- return (
- <div className="flex min-h-dvh w-dvw items-center justify-center bg-ui-bg-subtle">
- <div className="m-4 flex w-full max-w-[280px] flex-col items-center">
- <AvatarBox />
- <div className="mb-4 flex flex-col items-center">
- <Heading>{t('register.title')}</Heading>
- <Text
- size="small"
- className="text-center text-ui-fg-subtle"
- >
- {t('register.hint')}
- </Text>
- </div>
- <div className="flex w-full flex-col gap-y-3">
- <Form {...form}>
- <form
- onSubmit={handleSubmit}
- className="flex w-full flex-col gap-y-6"
- >
- <div className="flex flex-col gap-y-2">
- <Form.Field
- control={form.control}
- name="name"
- render={({ field }) => (
- <Form.Item>
- <Form.Control>
- <Input
- {...field}
- className="mb-2 bg-ui-bg-field-component"
- placeholder="Company name"
- />
- </Form.Control>
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="email"
- render={({ field }) => (
- <Form.Item>
- <Form.Control>
- <Input
- {...field}
- className="bg-ui-bg-field-component"
- placeholder={t('fields.email')}
- />
- </Form.Control>
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="password"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{}</Form.Label>
- <Form.Control>
- <Input
- type="password"
- {...field}
- className="bg-ui-bg-field-component"
- placeholder={t('fields.password')}
- />
- </Form.Control>
- </Form.Item>
- )}
- />
-
- <Form.Field
- control={form.control}
- name="confirmPassword"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{}</Form.Label>
- <Form.Control>
- <Input
- type="password"
- {...field}
- className="bg-ui-bg-field-component"
- placeholder="Confirm Password"
- />
- </Form.Control>
- </Form.Item>
- )}
- />
- <PasswordValidator
- password={form.watch('password')}
- setError={setPasswordValidation}
- />
- </div>
- {validationError && (
- <div className="text-center">
- <Hint
- className="inline-flex"
- variant={'error'}
- >
- {validationError}
- </Hint>
- </div>
- )}
- {serverError && (
- <Alert
- className="items-center bg-ui-bg-base p-2"
- dismissible
- variant="error"
- >
- {serverError}
- </Alert>
- )}
- <Button
- className="w-full"
- type="submit"
- isLoading={isPending}
- >
- Sign up
- </Button>
- </form>
- </Form>
- </div>
- <span className="txt-small my-6 text-ui-fg-muted">
- <Trans
- i18nKey="register.alreadySeller"
- components={[
- <Link
- to="/login"
- className="font-medium text-ui-fg-interactive outline-none transition-fg hover:text-ui-fg-interactive-hover focus-visible:text-ui-fg-interactive-hover"
- />
- ]}
- />
- </span>
- </div>
- </div>
- );
-};