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): replace store settings with seller settings and add logo preview

vholikbccb241a1dc3
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 9f170ad1e..79d4fe56f 100644
--- a/packages/vendor/src/components/layout/main-layout/main-layout.tsx
+++ b/packages/vendor/src/components/layout/main-layout/main-layout.tsx
@@ -210,9 +210,9 @@ const Header = () => {
</div>
<DropdownMenu.Separator />
<DropdownMenu.Item className="gap-x-2" asChild>
- <Link to="/settings/store">
+ <Link to="/settings/seller">
<BuildingStorefront className="text-ui-fg-subtle" />
- {t("app.menus.seller.sellerSettings")}
+ {t("app.menus.seller.editSeller")}
</Link>
</DropdownMenu.Item>
<DropdownMenu.Separator />
diff --git a/packages/vendor/src/components/layout/settings-layout/settings-layout.tsx b/packages/vendor/src/components/layout/settings-layout/settings-layout.tsx
index 1f21305f2..8e3fc000f 100644
--- a/packages/vendor/src/components/layout/settings-layout/settings-layout.tsx
+++ b/packages/vendor/src/components/layout/settings-layout/settings-layout.tsx
@@ -11,7 +11,6 @@ import { UserMenu } from "../user-menu";
import components from "virtual:mercur/components";
import menuItemsModule from "virtual:mercur/menu-items";
import { getMenuItemsByType, getNestedMenuItems } from "../../../utils/routes";
-import { MenuItem } from "../../../utils/routes";
export const SettingsLayout = () => {
const Sidebar = components.SettingsSidebar
@@ -31,9 +30,13 @@ const useSettingRoutes = (): INavItem[] => {
return useMemo(
() => [
{
- label: t("store.domain", "Store"),
- to: "/settings/store",
+ label: t("seller.domain", "Seller"),
+ to: "/settings/seller",
},
+ // {
+ // label: t("users.domain"),
+ // to: "/settings/users",
+ // },
{
label: t("productTypes.domain"),
to: "/settings/product-types",
@@ -47,11 +50,10 @@ const useSettingRoutes = (): INavItem[] => {
to: "/settings/locations",
},
],
- [t]
+ [t],
);
};
-
/**
* Ensure that the `from` prop is not another settings route, to avoid
* the user getting stuck in a navigation loop.
@@ -64,27 +66,6 @@ const getSafeFromValue = (from: string) => {
return from;
};
-const injectNestedSettingsItems = (
- routes: INavItem[],
- allMenuItems: MenuItem[]
-): INavItem[] => {
- return routes.flatMap((route) => {
- const nestedItems = getNestedMenuItems(allMenuItems, route.to);
- if (nestedItems.length === 0) {
- return [route];
- }
-
- return [
- route,
- ...nestedItems.map((item) => ({
- label: item.label,
- to: item.path,
- translationNs: item.translationNs,
- })),
- ];
- });
-};
-
const SettingsSidebar = () => {
const generalRoutes = useSettingRoutes();
const allMenuItems = menuItemsModule.menuItems ?? [];
@@ -148,7 +129,7 @@ const Header = () => {
className={clx(
"bg-ui-bg-subtle transition-fg flex items-center rounded-md outline-none",
"hover:bg-ui-bg-subtle-hover",
- "focus-visible:shadow-borders-focus"
+ "focus-visible:shadow-borders-focus",
)}
>
<div className="flex items-center gap-x-2.5 px-2 py-1">
diff --git a/packages/vendor/src/get-route-map.tsx b/packages/vendor/src/get-route-map.tsx
index 7b6a1aaae..2794a4be7 100644
--- a/packages/vendor/src/get-route-map.tsx
+++ b/packages/vendor/src/get-route-map.tsx
@@ -508,9 +508,7 @@ export function getRouteMap({
{
path: ":ruleType/edit",
lazy: () =>
- import(
- "./pages/promotions/[id]/[ruleType]/edit"
- ),
+ import("./pages/promotions/[id]/[ruleType]/edit"),
},
],
},
@@ -713,23 +711,19 @@ export function getRouteMap({
// STORE
{
- path: "store",
+ path: "seller",
errorElement: <ErrorBoundary />,
handle: {
- breadcrumb: () => t("store.domain", "Store"),
+ breadcrumb: () => t("seller.domain", "Seller"),
},
children: [
{
path: "",
- lazy: () => import("./pages/settings/store"),
+ lazy: () => import("./pages/settings/seller"),
children: [
{
path: "edit",
- lazy: () => import("./pages/settings/store/edit"),
- },
- {
- path: "edit-company",
- lazy: () => import("./pages/settings/store/edit-company"),
+ lazy: () => import("./pages/settings/seller/edit"),
},
],
},
diff --git a/packages/vendor/src/hooks/api/users.tsx b/packages/vendor/src/hooks/api/users.tsx
index 1408e0206..01ade1e27 100644
--- a/packages/vendor/src/hooks/api/users.tsx
+++ b/packages/vendor/src/hooks/api/users.tsx
@@ -120,6 +120,23 @@ export const useDeleteUser = (
});
};
+export const useUpdateMe = (
+ options?: UseMutationOptions<
+ InferClientOutput<typeof sdk.vendor.sellers.me.mutate>,
+ ClientError,
+ Omit<InferClientInput<typeof sdk.vendor.sellers.me.mutate>, "$id">
+ >
+) => {
+ return useMutation({
+ mutationFn: (payload) => sdk.vendor.sellers.me.mutate(payload),
+ onSuccess: (data, variables, context) => {
+ queryClient.invalidateQueries({ queryKey: usersQueryKeys.me() });
+ options?.onSuccess?.(data, variables, context);
+ },
+ ...options,
+ });
+};
+
export const useUserMe = (
query?: Record<string, any>,
options?: UseQueryOptions<any, Error, any>
diff --git a/packages/vendor/src/i18n/translations/en.json b/packages/vendor/src/i18n/translations/en.json
index afccefa4b..8c523acb0 100644
--- a/packages/vendor/src/i18n/translations/en.json
+++ b/packages/vendor/src/i18n/translations/en.json
@@ -250,7 +250,8 @@
},
"seller": {
"label": "Seller",
- "sellerSettings": "Seller settings"
+ "sellerSettings": "Seller settings",
+ "editSeller": "Edit Seller"
},
"actions": {
"logout": "Log out"
@@ -412,6 +413,9 @@
"sales_channels": {
"availableIn": "Available in <0>{{x}}</0> of <1>{{y}}</1> sales channels"
},
+ "seller": {
+ "domain": "Seller"
+ },
"products": {
"domain": "Products",
"bulkDelete": {
diff --git a/packages/vendor/src/pages/products/_components/product-list-table/product-list-header.tsx b/packages/vendor/src/pages/products/_components/product-list-table/product-list-header.tsx
index e66b66fd8..88c0e8d5c 100644
--- a/packages/vendor/src/pages/products/_components/product-list-table/product-list-header.tsx
+++ b/packages/vendor/src/pages/products/_components/product-list-table/product-list-header.tsx
@@ -1,65 +1,37 @@
-import { Children, ReactNode } from "react"
-import { useTranslation } from "react-i18next"
-import { Link } from "react-router-dom"
-import { Button, Heading } from "@medusajs/ui"
+import { Children, ReactNode } from "react";
+import { useTranslation } from "react-i18next";
+import { Link } from "react-router-dom";
+import { Button, Heading } from "@medusajs/ui";
export const ProductListTitle = () => {
- const { t } = useTranslation()
- return <Heading level="h2">{t("products.domain")}</Heading>
-}
+ const { t } = useTranslation();
+ return <Heading level="h2">{t("products.domain")}</Heading>;
+};
export const ProductListCreateButton = () => {
- const { t } = useTranslation()
+ const { t } = useTranslation();
return (
<Button size="small" variant="primary" asChild>
<Link to="create">{t("actions.create")}</Link>
</Button>
- )
-}
+ );
+};
-export const ProductListImportButton = () => {
- const { t } = useTranslation()
- return (
- <Button size="small" variant="secondary" asChild>
- <Link to="import">{t("actions.import")}</Link>
- </Button>
- )
-}
-
-export const ProductListExportButton = () => {
- const { t } = useTranslation()
- return (
- <Button size="small" variant="secondary" asChild>
- <Link to={`export${location.search}`}>{t("actions.export")}</Link>
- </Button>
- )
-}
-
-export const ProductListActions = ({
- children,
-}: {
- children?: ReactNode
-}) => {
+export const ProductListActions = ({ children }: { children?: ReactNode }) => {
return (
<div className="flex items-center justify-center gap-x-2">
{Children.count(children) > 0 ? (
children
) : (
<>
- <ProductListExportButton />
- <ProductListImportButton />
<ProductListCreateButton />
</>
)}
</div>
- )
-}
+ );
+};
-export const ProductListHeader = ({
- children,
-}: {
- children?: ReactNode
-}) => {
+export const ProductListHeader = ({ children }: { children?: ReactNode }) => {
return (
<div className="flex items-center justify-between px-6 py-4">
{Children.count(children) > 0 ? (
@@ -71,5 +43,5 @@ export const ProductListHeader = ({
</>
)}
</div>
- )
-}
+ );
+};
diff --git a/packages/vendor/src/pages/products/product-list-page.tsx b/packages/vendor/src/pages/products/product-list-page.tsx
index 38a8bf9b2..48c0154fc 100644
--- a/packages/vendor/src/pages/products/product-list-page.tsx
+++ b/packages/vendor/src/pages/products/product-list-page.tsx
@@ -1,6 +1,6 @@
-import { Children, ReactNode } from "react"
+import { Children, ReactNode } from "react";
-import { SingleColumnPage } from "@components/layout/pages"
+import { SingleColumnPage } from "@components/layout/pages";
import {
ProductListTable,
@@ -9,17 +9,15 @@ import {
ProductListActions,
ProductListTitle,
ProductListCreateButton,
- ProductListImportButton,
- ProductListExportButton,
-} from "./_components/product-list-table"
+} from "./_components/product-list-table";
const Root = ({ children }: { children?: ReactNode }) => {
return (
<SingleColumnPage>
{Children.count(children) > 0 ? children : <ProductListTable />}
</SingleColumnPage>
- )
-}
+ );
+};
export const ProductListPage = Object.assign(Root, {
// Backward compat
@@ -31,6 +29,4 @@ export const ProductListPage = Object.assign(Root, {
// Individual elements
Title: ProductListTitle,
CreateButton: ProductListCreateButton,
- ImportButton: ProductListImportButton,
- ExportButton: ProductListExportButton,
-})
+});
diff --git a/packages/vendor/src/pages/settings/store/_components/store-general-section.tsx b/packages/vendor/src/pages/settings/seller/_components/seller-general-section.tsx
similarity index 64%
rename from packages/vendor/src/pages/settings/store/_components/store-general-section.tsx
rename to packages/vendor/src/pages/settings/seller/_components/seller-general-section.tsx
index 4a4fab82b..eb1bc690b 100644
--- a/packages/vendor/src/pages/settings/store/_components/store-general-section.tsx
+++ b/packages/vendor/src/pages/settings/seller/_components/seller-general-section.tsx
@@ -1,28 +1,27 @@
-import { PencilSquare } from "@medusajs/icons"
-import { HttpTypes } from "@medusajs/types"
-import { Container, Heading, Text } from "@medusajs/ui"
-import { useTranslation } from "react-i18next"
+import { PencilSquare } from "@medusajs/icons";
+import { Container, Heading, Text } from "@medusajs/ui";
+import { useTranslation } from "react-i18next";
-import { ActionMenu } from "@components/common/action-menu"
-import ImageAvatar from "@components/common/image-avatar/image-avatar"
+import { ActionMenu } from "@components/common/action-menu";
+import ImageAvatar from "@components/common/image-avatar/image-avatar";
+import { HttpTypes } from "@mercurjs/types";
type StoreGeneralSectionProps = {
- store: HttpTypes.AdminStore
-}
+ seller: HttpTypes.StoreSellerResponse["seller"];
+};
-export const StoreGeneralSection = ({ store }: StoreGeneralSectionProps) => {
- const { t } = useTranslation()
- const storeAny = store as any
+export const SellerGeneralSection = ({ seller }: StoreGeneralSectionProps) => {
+ const { t } = useTranslation();
return (
<Container className="divide-y p-0">
<div className="flex items-center justify-between px-6 py-4">
<div className="flex items-center gap-x-4">
- {storeAny.photo && <ImageAvatar src={storeAny.photo} size={12} />}
+ {seller.logo && <ImageAvatar src={seller.logo} size={12} />}
<div>
- <Heading>{t("store.domain", "Store")}</Heading>
+ <Heading>{seller.name}</Heading>
<Text className="text-ui-fg-subtle" size="small">
- {t("store.manageYourStoresDetails", "Manage your store's details")}
+ {seller.handle}
</Text>
</div>
</div>
@@ -45,7 +44,7 @@ export const StoreGeneralSection = ({ store }: StoreGeneralSectionProps) => {
{t("fields.name")}
</Text>
<Text size="small" leading="compact">
- {store.name || "-"}
+ {seller.name || "-"}
</Text>
</div>
<div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
@@ -53,7 +52,7 @@ export const StoreGeneralSection = ({ store }: StoreGeneralSectionProps) => {
{t("fields.email")}
</Text>
<Text size="small" leading="compact">
- {storeAny.email || "-"}
+ {seller.email || "-"}
</Text>
</div>
<div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
@@ -61,17 +60,25 @@ export const StoreGeneralSection = ({ store }: StoreGeneralSectionProps) => {
{t("fields.phone")}
</Text>
<Text size="small" leading="compact">
- {storeAny.phone || "-"}
+ {seller.phone || "-"}
</Text>
</div>
<div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
<Text size="small" leading="compact" weight="plus">
- {t("fields.description")}
+ {t("fields.address")}
</Text>
<Text size="small" leading="compact">
- {storeAny.description || "-"}
+ {[
+ seller.address_1,
+ seller.city,
+ seller.province,
+ seller.postal_code,
+ seller.country_code,
+ ]
+ .filter(Boolean)
+ .join(", ") || "-"}
</Text>
</div>
</Container>
- )
-}
+ );
+};
diff --git a/packages/vendor/src/pages/settings/seller/edit/_components/edit-seller-form.tsx b/packages/vendor/src/pages/settings/seller/edit/_components/edit-seller-form.tsx
new file mode 100644
index 000000000..aea42acc5
--- /dev/null
+++ b/packages/vendor/src/pages/settings/seller/edit/_components/edit-seller-form.tsx
@@ -0,0 +1,355 @@
+import { zodResolver } from "@hookform/resolvers/zod";
+import { Button, Input, toast } from "@medusajs/ui";
+import { useFieldArray, useForm } from "react-hook-form";
+import { useTranslation } from "react-i18next";
+import * as zod from "zod";
+
+import { FileType, FileUpload } from "@components/common/file-upload";
+import { Form } from "@components/common/form";
+import ImageAvatar from "@components/common/image-avatar/image-avatar";
+import { CountrySelect } from "@components/inputs/country-select";
+import { RouteDrawer, useRouteModal } from "@components/modals";
+import { KeyboundForm } from "@components/utilities/keybound-form";
+import { useUpdateMe } from "@hooks/api";
+import { uploadFilesQuery } from "@lib/client";
+import { MediaSchema } from "@pages/products/create/constants";
+import { HttpTypes } from "@mercurjs/types";
+
+type EditSellerFormProps = HttpTypes.StoreSellerResponse;
+
+const EditSellerSchema = 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("")),
+ }),
+ media: zod.array(MediaSchema).optional(),
+});
+
+const SUPPORTED_FORMATS = [
+ "image/jpeg",
+ "image/png",
+ "image/gif",
+ "image/webp",
+ "image/heic",
+ "image/svg+xml",
+];
+
+const SUPPORTED_FORMATS_FILE_EXTENSIONS = [
+ ".jpeg",
+ ".png",
+ ".gif",
+ ".webp",
+ ".heic",
+ ".svg",
+];
+
+export const EditSellerForm = ({ seller }: EditSellerFormProps) => {
+ const { t } = useTranslation();
+ const { handleSuccess } = useRouteModal();
+
+ const form = useForm<zod.infer<typeof EditSellerSchema>>({
+ defaultValues: {
+ 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: [],
+ },
+ resolver: zodResolver(EditSellerSchema),
+ });
+
+ const { fields } = useFieldArray({
+ name: "media",
+ control: form.control,
+ keyName: "field_id",
+ });
+
+ const { mutateAsync, isPending } = useUpdateMe();
+
+ const handleSubmit = form.handleSubmit(async (values) => {
+ let logoUrl = seller.logo || "";
+
+ try {
+ if (values.media?.length) {
+ const uploaded = await uploadFilesQuery(values.media);
+ logoUrl = uploaded.files?.[0]?.url || logoUrl;
+ }
+ } catch (error) {
+ if (error instanceof Error) {
+ toast.error(error.message);
+ }
+ }
+
+ await mutateAsync(
+ {
+ name: values.name,
+ handle: values.handle,
+ email: values.email || undefined,
+ phone: values.phone || null,
+ logo: logoUrl || 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,
+ } as any,
+ {
+ onSuccess: () => {
+ toast.success(t("app.menus.seller.sellerSettings"));
+ handleSuccess();
+ },
+ onError: (error) => {
+ toast.error(error.message);
+ },
+ },
+ );
+ });
+
+ // File validation and upload — instead of useCallback, inline for simplicity (matches Location Form simpleness)
+ const onUploaded = (files: FileType[]) => {
+ const invalidFile = files.find(
+ (f) => !SUPPORTED_FORMATS.includes(f.file.type),
+ );
+ if (invalidFile) {
+ form.setError("media", {
+ type: "invalid_file",
+ message: t("products.media.invalidFileType", {
+ name: invalidFile.file.name,
+ types: SUPPORTED_FORMATS_FILE_EXTENSIONS.join(", "),
+ }),
+ });
+ return;
+ }
+ form.clearErrors("media");
+ form.setValue("media", [{ ...files[0], isThumbnail: false }]);
+ };
+
+ return (
+ <RouteDrawer.Form form={form}>
+ <KeyboundForm
+ onSubmit={handleSubmit}
+ 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 = fields[0]?.url || seller.logo;
+
+ return (
+ <Form.Item>
+ <Form.Label>{t("store.logo", "Logo")}</Form.Label>
+ {previewUrl && (
+ <div className="mb-2">
+ <ImageAvatar src={previewUrl} size={16} />
+ </div>
+ )}
+ <Form.Control>
+ <FileUpload
+ multiple={false}
+ label={t("products.media.uploadImagesLabel")}
+ hint={t("products.media.uploadImagesHint")}
+ hasError={!!form.formState.errors.media}
+ formats={SUPPORTED_FORMATS}
+ onUploaded={onUploaded}
+ />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ );
+ }}
+ />
+ <Form.Field
+ control={form.control}
+ name="name"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.name")}</Form.Label>
+ <Form.Control>
+ <Input size="small" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="handle"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.handle")}</Form.Label>
+ <Form.Control>
+ <Input size="small" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="email"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label>{t("fields.email")}</Form.Label>
+ <Form.Control>
+ <Input size="small" type="email" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="phone"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.phone")}</Form.Label>
+ <Form.Control>
+ <Input size="small" {...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"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.address")}</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.company"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.company")}</Form.Label>
+ <Form.Control>
+ <Input size="small" {...field} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ control={form.control}
+ name="address.phone"
+ render={({ field }) => (
+ <Form.Item>
+ <Form.Label optional>{t("fields.phone")}</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} />
+ </Form.Control>
+ <Form.ErrorMessage />
+ </Form.Item>
+ )}
+ />
+ <Form.Field
+ 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>
+ )}
+ />
+ <Form.Field
+ 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>
+ )}
+ />
+ </div>
+ </RouteDrawer.Body>
+ <RouteDrawer.Footer>
+ <div className="flex items-center justify-end gap-x-2">
+ <RouteDrawer.Close asChild>
+ <Button size="small" variant="secondary">
+ {t("actions.cancel")}
+ </Button>
+ </RouteDrawer.Close>
+ <Button size="small" type="submit" isLoading={isPending}>
+ {t("actions.save")}
+ </Button>
+ </div>
+ </RouteDrawer.Footer>
+ </KeyboundForm>
+ </RouteDrawer.Form>
+ );
+};
diff --git a/packages/vendor/src/pages/settings/seller/edit/index.tsx b/packages/vendor/src/pages/settings/seller/edit/index.tsx
new file mode 100644
index 000000000..bd7bca0b9
--- /dev/null
+++ b/packages/vendor/src/pages/settings/seller/edit/index.tsx
@@ -0,0 +1,29 @@
+import { Heading } from "@medusajs/ui";
+import { useTranslation } from "react-i18next";
+import { RouteDrawer } from "@components/modals";
+import { useMe } from "@hooks/api";
+import { EditSellerForm } from "./_components/edit-seller-form";
+
+const SellerEdit = () => {
+ const { t } = useTranslation();
+ const { seller, isPending, isError, error } = useMe();
+
+ const ready = !isPending && !!seller;
+
+ if (isError) {
+ throw error;
+ }
+
+ return (
+ <RouteDrawer>
+ <RouteDrawer.Header>
+ <Heading className="capitalize">
+ {t("app.menus.seller.editSeller")}
+ </Heading>
+ </RouteDrawer.Header>
+ {ready && <EditSellerForm seller={seller} />}
+ </RouteDrawer>
+ );
+};
+
+export const Component = SellerEdit;
diff --git a/packages/vendor/src/pages/settings/seller/index.tsx b/packages/vendor/src/pages/settings/seller/index.tsx
new file mode 100644
index 000000000..34b950139
--- /dev/null
+++ b/packages/vendor/src/pages/settings/seller/index.tsx
@@ -0,0 +1,24 @@
+import { SingleColumnPageSkeleton } from "@components/common/skeleton";
+import { SingleColumnPage } from "@components/layout/pages";
+import { SellerGeneralSection } from "./_components/seller-general-section";
+import { useMe } from "@/hooks/api";
+
+const SellerDetail = () => {
+ const { seller, isPending, isError, error } = useMe();
+
+ if (isPending || !seller) {
+ return <SingleColumnPageSkeleton sections={2} />;
+ }
+
+ if (isError) {
+ throw error;
+ }
+
+ return (
+ <SingleColumnPage data={seller} hasOutlet>
+ <SellerGeneralSection seller={seller} />
+ </SingleColumnPage>
+ );
+};
+
+export const Component = SellerDetail;
diff --git a/packages/vendor/src/pages/settings/settings.tsx b/packages/vendor/src/pages/settings/settings.tsx
index 8144bf050..d69b23846 100644
--- a/packages/vendor/src/pages/settings/settings.tsx
+++ b/packages/vendor/src/pages/settings/settings.tsx
@@ -1,15 +1,15 @@
-import { useEffect } from "react"
-import { Outlet, useLocation, useNavigate } from "react-router-dom"
+import { useEffect } from "react";
+import { Outlet, useLocation, useNavigate } from "react-router-dom";
export const Settings = () => {
- const navigate = useNavigate()
- const location = useLocation()
+ const navigate = useNavigate();
+ const location = useLocation();
useEffect(() => {
if (location.pathname === "/settings") {
- navigate("/settings/store", { replace: true })
+ navigate("/settings/seller", { replace: true });
}
- }, [location.pathname, navigate])
+ }, [location.pathname, navigate]);
- return <Outlet />
-}
+ return <Outlet />;
+};
diff --git a/packages/vendor/src/pages/settings/store/_components/company-section.tsx b/packages/vendor/src/pages/settings/store/_components/company-section.tsx
deleted file mode 100644
index f35f22230..000000000
--- a/packages/vendor/src/pages/settings/store/_components/company-section.tsx
+++ /dev/null
@@ -1,81 +0,0 @@
-import { PencilSquare } from "@medusajs/icons"
-import { HttpTypes } from "@medusajs/types"
-import { Container, Heading, Text } from "@medusajs/ui"
-import { useTranslation } from "react-i18next"
-
-import { ActionMenu } from "@components/common/action-menu"
-
-type CompanySectionProps = {
- store: HttpTypes.AdminStore
-}
-
-export const CompanySection = ({ store }: CompanySectionProps) => {
- const { t } = useTranslation()
- const storeAny = store as any
-
- return (
- <Container className="divide-y p-0">
- <div className="flex items-center justify-between px-6 py-4">
- <div>
- <Heading>{t("store.company", "Company")}</Heading>
- <Text className="text-ui-fg-subtle" size="small">
- {t("store.manageCompanyDetails", "Manage your company details")}
- </Text>
- </div>
- <ActionMenu
- groups={[
- {
- actions: [
- {
- icon: <PencilSquare />,
- label: t("actions.edit"),
- to: "edit-company",
- },
- ],
- },
- ]}
- />
- </div>
- <div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
- <Text size="small" leading="compact" weight="plus">
- {t("fields.address")}
- </Text>
- <Text size="small" leading="compact">
- {storeAny.address_line || "-"}
- </Text>
- </div>
- <div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
- <Text size="small" leading="compact" weight="plus">
- {t("fields.postalCode", "Postal code")}
- </Text>
- <Text size="small" leading="compact">
- {storeAny.postal_code || "-"}
- </Text>
- </div>
- <div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
- <Text size="small" leading="compact" weight="plus">
- {t("fields.city")}
- </Text>
- <Text size="small" leading="compact">
- {storeAny.city || "-"}
- </Text>
- </div>
- <div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
- <Text size="small" leading="compact" weight="plus">
- {t("fields.country")}
- </Text>
- <Text size="small" leading="compact">
- {storeAny.country_code || "-"}
- </Text>
- </div>
- <div className="text-ui-fg-subtle grid grid-cols-2 px-6 py-4">
- <Text size="small" leading="compact" weight="plus">
- {t("fields.taxId", "Tax ID")}
- </Text>
- <Text size="small" leading="compact">
- {storeAny.tax_id || "-"}
- </Text>
- </div>
- </Container>
- )
-}
diff --git a/packages/vendor/src/pages/settings/store/edit-company/_components/edit-store-company-form.tsx b/packages/vendor/src/pages/settings/store/edit-company/_components/edit-store-company-form.tsx
deleted file mode 100644
index bd5db2a14..000000000
--- a/packages/vendor/src/pages/settings/store/edit-company/_components/edit-store-company-form.tsx
+++ /dev/null
@@ -1,143 +0,0 @@
-import { zodResolver } from "@hookform/resolvers/zod"
-import { HttpTypes } from "@medusajs/types"
-import { Button, Input, toast } from "@medusajs/ui"
-import { useForm } from "react-hook-form"
-import { useTranslation } from "react-i18next"
-import { z } from "zod"
-
-import { Form } from "@components/common/form"
-import { RouteDrawer, useRouteModal } from "@components/modals"
-import { KeyboundForm } from "@components/utilities/keybound-form"
-import { useUpdateStore } from "@hooks/api/store"
-
-type EditStoreCompanyFormProps = {
- store: HttpTypes.AdminStore
-}
-
-const EditStoreCompanySchema = z.object({
- address_line: z.string().optional(),
- postal_code: z.string().optional(),
- city: z.string().optional(),
- country_code: z.string().optional(),
- tax_id: z.string().optional(),
-})
-
-export const EditStoreCompanyForm = ({ store }: EditStoreCompanyFormProps) => {
- const { t } = useTranslation()
- const { handleSuccess } = useRouteModal()
-
- const storeAny = store as any
-
- const form = useForm<z.infer<typeof EditStoreCompanySchema>>({
- defaultValues: {
- address_line: storeAny.address_line ?? "",
- postal_code: storeAny.postal_code ?? "",
- city: storeAny.city ?? "",
- country_code: storeAny.country_code ?? "",
- tax_id: storeAny.tax_id ?? "",
- },
- resolver: zodResolver(EditStoreCompanySchema),
- })
-
- const { mutateAsync, isPending } = useUpdateStore(store.id)
-
- const handleSubmit = form.handleSubmit(async (values) => {
- await mutateAsync(values as any, {
- onSuccess: () => {
- toast.success(t("store.toast.update", "Store successfully updated"))
- handleSuccess()
- },
- onError: (error) => {
- toast.error(error.message)
- },
- })
- })
-
- return (
- <RouteDrawer.Form form={form}>
- <KeyboundForm onSubmit={handleSubmit} className="flex h-full flex-col overflow-hidden">
- <RouteDrawer.Body className="overflow-y-auto">
- <div className="flex flex-col gap-y-8">
- <Form.Field
- control={form.control}
- name="address_line"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.address")}</Form.Label>
- <Form.Control>
- <Input {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="postal_code"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.postalCode", "Postal code")}</Form.Label>
- <Form.Control>
- <Input {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="city"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.city")}</Form.Label>
- <Form.Control>
- <Input {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="country_code"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.country")}</Form.Label>
- <Form.Control>
- <Input {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="tax_id"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.taxId", "Tax ID")}</Form.Label>
- <Form.Control>
- <Input {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- </div>
- </RouteDrawer.Body>
- <RouteDrawer.Footer>
- <div className="flex items-center justify-end gap-x-2">
- <RouteDrawer.Close asChild>
- <Button size="small" variant="secondary">
- {t("actions.cancel")}
- </Button>
- </RouteDrawer.Close>
- <Button size="small" isLoading={isPending} type="submit">
- {t("actions.save")}
- </Button>
- </div>
- </RouteDrawer.Footer>
- </KeyboundForm>
- </RouteDrawer.Form>
- )
-}
diff --git a/packages/vendor/src/pages/settings/store/edit-company/index.tsx b/packages/vendor/src/pages/settings/store/edit-company/index.tsx
deleted file mode 100644
index 6cc62261b..000000000
--- a/packages/vendor/src/pages/settings/store/edit-company/index.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { Heading } from "@medusajs/ui"
-import { useTranslation } from "react-i18next"
-
-import { RouteDrawer } from "@components/modals"
-import { useStore } from "@hooks/api/store"
-import { EditStoreCompanyForm } from "./_components/edit-store-company-form"
-
-const StoreCompanyEdit = () => {
- const { t } = useTranslation()
- const { store, isPending: isLoading, isError, error } = useStore()
-
- if (isError) {
- throw error
- }
-
- const ready = !!store && !isLoading
-
- return (
- <RouteDrawer>
- <RouteDrawer.Header>
- <Heading>{t("store.editCompany.header", "Edit Company")}</Heading>
- </RouteDrawer.Header>
- {ready && <EditStoreCompanyForm store={store} />}
- </RouteDrawer>
- )
-}
-
-export const Component = StoreCompanyEdit
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
deleted file mode 100644
index e14945ad5..000000000
--- a/packages/vendor/src/pages/settings/store/edit/_components/edit-store-form.tsx
+++ /dev/null
@@ -1,240 +0,0 @@
-import { zodResolver } from "@hookform/resolvers/zod"
-import { HttpTypes } from "@medusajs/types"
-import { Button, Input, Textarea, toast } from "@medusajs/ui"
-import { useCallback } from "react"
-import { useFieldArray, useForm } from "react-hook-form"
-import { useTranslation } from "react-i18next"
-import { z } from "zod"
-
-import { FileType, FileUpload } from "@components/common/file-upload"
-import { Form } from "@components/common/form"
-import { RouteDrawer, useRouteModal } from "@components/modals"
-import { KeyboundForm } from "@components/utilities/keybound-form"
-import { useUpdateStore } from "@hooks/api/store"
-import { uploadFilesQuery } from "@lib/client"
-import { MediaSchema } from "@pages/products/create/constants"
-
-type EditStoreFormProps = {
- store: HttpTypes.AdminStore
-}
-
-const EditStoreSchema = z.object({
- name: z.string().min(1),
- email: z.string().email().optional().or(z.literal("")),
- phone: z.string().optional(),
- description: z.string().optional(),
- media: z.array(MediaSchema).optional(),
-})
-
-const SUPPORTED_FORMATS = [
- "image/jpeg",
- "image/png",
- "image/gif",
- "image/webp",
- "image/heic",
- "image/svg+xml",
-]
-
-const SUPPORTED_FORMATS_FILE_EXTENSIONS = [
- ".jpeg",
- ".png",
- ".gif",
- ".webp",
- ".heic",
- ".svg",
-]
-
-export const EditStoreForm = ({ store }: EditStoreFormProps) => {
- const { t } = useTranslation()
- const { handleSuccess } = useRouteModal()
-
- const storeAny = store as any
-
- const form = useForm<z.infer<typeof EditStoreSchema>>({
- defaultValues: {
- name: store.name ?? "",
- email: storeAny.email ?? "",
- phone: storeAny.phone ?? "",
- description: storeAny.description ?? "",
- media: [],
- },
- resolver: zodResolver(EditStoreSchema),
- })
-
- const { fields } = useFieldArray({
- name: "media",
- control: form.control,
- keyName: "field_id",
- })
-
- const { mutateAsync, isPending } = useUpdateStore(store.id)
-
- const handleSubmit = form.handleSubmit(async (values) => {
- let photoUrl = storeAny.photo || ""
-
- try {
- if (values.media?.length) {
- const uploaded = await uploadFilesQuery(values.media)
- photoUrl = uploaded.files?.[0]?.url || photoUrl
- }
- } catch (error) {
- if (error instanceof Error) {
- toast.error(error.message)
- }
- }
-
- await mutateAsync(
- {
- name: values.name,
- email: values.email,
- phone: values.phone,
- description: values.description,
- photo: photoUrl,
- } as any,
- {
- onSuccess: () => {
- toast.success(t("store.toast.update", "Store successfully updated"))
- handleSuccess()
- },
- onError: (error) => {
- toast.error(error.message)
- },
- }
- )
- })
-
- const hasInvalidFiles = useCallback(
- (fileList: FileType[]) => {
- const invalidFile = fileList.find(
- (f) => !SUPPORTED_FORMATS.includes(f.file.type)
- )
-
- if (invalidFile) {
- form.setError("media", {
- type: "invalid_file",
- message: t("products.media.invalidFileType", {
- name: invalidFile.file.name,
- types: SUPPORTED_FORMATS_FILE_EXTENSIONS.join(", "),
- }),
- })
-
- return true
- }
-
- return false
- },
- [form, t]
- )
-
- const onUploaded = useCallback(
- (files: FileType[]) => {
- form.clearErrors("media")
- if (hasInvalidFiles(files)) {
- return
- }
-
- form.setValue("media", [{ ...files[0], isThumbnail: false }])
- },
- [form, hasInvalidFiles]
- )
-
- return (
- <RouteDrawer.Form form={form}>
- <KeyboundForm onSubmit={handleSubmit} className="flex h-full flex-col overflow-hidden">
- <RouteDrawer.Body className="overflow-y-auto">
- <div className="flex flex-col gap-y-8">
- <Form.Field
- name="media"
- control={form.control}
- render={() => (
- <Form.Item>
- <div className="flex flex-col gap-y-2">
- <div className="flex flex-col gap-y-1">
- <Form.Label>{t("store.logo", "Logo")}</Form.Label>
- </div>
- <Form.Control>
- <FileUpload
- uploadedImage={fields[0]?.url || storeAny.photo || ""}
- multiple={false}
- label={t("products.media.uploadImagesLabel")}
- hint={t("products.media.uploadImagesHint")}
- hasError={!!form.formState.errors.media}
- formats={SUPPORTED_FORMATS}
- onUploaded={onUploaded}
- />
- </Form.Control>
- <Form.ErrorMessage />
- </div>
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="name"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.name")}</Form.Label>
- <Form.Control>
- <Input {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="email"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.email")}</Form.Label>
- <Form.Control>
- <Input type="email" {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="phone"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.phone")}</Form.Label>
- <Form.Control>
- <Input {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- <Form.Field
- control={form.control}
- name="description"
- render={({ field }) => (
- <Form.Item>
- <Form.Label>{t("fields.description")}</Form.Label>
- <Form.Control>
- <Textarea {...field} />
- </Form.Control>
- <Form.ErrorMessage />
- </Form.Item>
- )}
- />
- </div>
- </RouteDrawer.Body>
- <RouteDrawer.Footer>
- <div className="flex items-center justify-end gap-x-2">
- <RouteDrawer.Close asChild>
- <Button size="small" variant="secondary">
- {t("actions.cancel")}
- </Button>
- </RouteDrawer.Close>
- <Button size="small" isLoading={isPending} type="submit">
- {t("actions.save")}
- </Button>
- </div>
- </RouteDrawer.Footer>
- </KeyboundForm>
- </RouteDrawer.Form>
- )
-}
diff --git a/packages/vendor/src/pages/settings/store/edit/index.tsx b/packages/vendor/src/pages/settings/store/edit/index.tsx
deleted file mode 100644
index b7ff842ee..000000000
--- a/packages/vendor/src/pages/settings/store/edit/index.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import { Heading } from "@medusajs/ui"
-import { useTranslation } from "react-i18next"
-
-import { RouteDrawer } from "@components/modals"
-import { useStore } from "@hooks/api/store"
-import { EditStoreForm } from "./_components/edit-store-form"
-
-const StoreEdit = () => {
- const { t } = useTranslation()
- const { store, isPending: isLoading, isError, error } = useStore()
-
- if (isError) {
- throw error
- }
-
- const ready = !!store && !isLoading
-
- return (
- <RouteDrawer>
- <RouteDrawer.Header>
- <Heading>{t("store.edit.header", "Edit Store")}</Heading>
- </RouteDrawer.Header>
- {ready && <EditStoreForm store={store} />}
- </RouteDrawer>
- )
-}
-
-export const Component = StoreEdit
diff --git a/packages/vendor/src/pages/settings/store/index.tsx b/packages/vendor/src/pages/settings/store/index.tsx
deleted file mode 100644
index 58bee2693..000000000
--- a/packages/vendor/src/pages/settings/store/index.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { useStore } from "@hooks/api/store"
-
-import { SingleColumnPageSkeleton } from "@components/common/skeleton"
-import { SingleColumnPage } from "@components/layout/pages"
-import { StoreGeneralSection } from "./_components/store-general-section"
-import { CompanySection } from "./_components/company-section"
-
-const StoreDetail = () => {
- const { store, isPending, isError, error } = useStore()
-
- if (isPending || !store) {
- return <SingleColumnPageSkeleton sections={2} />
- }
-
- if (isError) {
- throw error
- }
-
- return (
- <SingleColumnPage data={store} hasOutlet>
- <StoreGeneralSection store={store} />
- <CompanySection store={store} />
- </SingleColumnPage>
- )
-}
-
-export const Component = StoreDetail
diff --git a/packages/vendor/src/providers/keybind-provider/hooks.tsx b/packages/vendor/src/providers/keybind-provider/hooks.tsx
index 9e0a6a72d..07fff1b83 100644
--- a/packages/vendor/src/providers/keybind-provider/hooks.tsx
+++ b/packages/vendor/src/providers/keybind-provider/hooks.tsx
@@ -1,74 +1,74 @@
-import { default as debounceFn } from "lodash.debounce"
-import { useCallback, useContext, useEffect, useState } from "react"
-import { useTranslation } from "react-i18next"
-import { useNavigate } from "react-router-dom"
+import { default as debounceFn } from "lodash.debounce";
+import { useCallback, useContext, useEffect, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { useNavigate } from "react-router-dom";
-import { useLogout } from "../../hooks/api/auth"
-import { queryClient } from "../../lib/query-client"
-import { KeybindContext } from "./keybind-context"
-import { Shortcut } from "./types"
-import { findShortcut } from "./utils"
+import { useLogout } from "../../hooks/api/auth";
+import { queryClient } from "../../lib/query-client";
+import { KeybindContext } from "./keybind-context";
+import { Shortcut } from "./types";
+import { findShortcut } from "./utils";
export const useKeybind = () => {
- const context = useContext(KeybindContext)
+ const context = useContext(KeybindContext);
if (!context) {
- throw new Error("useKeybind must be used within a KeybindProvider")
+ throw new Error("useKeybind must be used within a KeybindProvider");
}
- return context
-}
+ return context;
+};
-export const useRegisterShortcut = () => {}
+export const useRegisterShortcut = () => {};
export const useShortcuts = ({
shortcuts = [],
debounce,
}: {
- shortcuts?: Shortcut[]
- debounce: number
+ shortcuts?: Shortcut[];
+ debounce: number;
}) => {
- const [keys, setKeys] = useState<string[]>([])
- const navigate = useNavigate()
+ const [keys, setKeys] = useState<string[]>([]);
+ const navigate = useNavigate();
// eslint-disable-next-line react-hooks/exhaustive-deps
const removeKeys = useCallback(
debounceFn(() => setKeys([]), debounce),
- []
- )
+ [],
+ );
// eslint-disable-next-line react-hooks/exhaustive-deps
const invokeShortcut = useCallback(
debounceFn((shortcut: Shortcut | null) => {
if (shortcut && shortcut.callback) {
- shortcut.callback()
- setKeys([])
+ shortcut.callback();
+ setKeys([]);
- return
+ return;
}
if (shortcut && shortcut.to) {
- navigate(shortcut.to)
- setKeys([])
+ navigate(shortcut.to);
+ setKeys([]);
- return
+ return;
}
}, debounce / 2),
- []
- )
+ [],
+ );
useEffect(() => {
if (keys.length > 0 && shortcuts.length > 0) {
- const shortcut = findShortcut(shortcuts, keys)
- invokeShortcut(shortcut)
+ const shortcut = findShortcut(shortcuts, keys);
+ invokeShortcut(shortcut);
}
- return () => invokeShortcut.cancel()
- }, [keys, shortcuts, invokeShortcut])
+ return () => invokeShortcut.cancel();
+ }, [keys, shortcuts, invokeShortcut]);
useEffect(() => {
const listener = (event: KeyboardEvent) => {
- const target = event.target as HTMLElement
+ const target = event.target as HTMLElement;
/**
* Ignore key events from input, textarea and contenteditable elements
@@ -78,36 +78,36 @@ export const useShortcuts = ({
target.tagName === "TEXTAREA" ||
target.contentEditable === "true"
) {
- removeKeys()
- return
+ removeKeys();
+ return;
}
- setKeys((oldKeys) => [...oldKeys, event.key])
- removeKeys()
- }
+ setKeys((oldKeys) => [...oldKeys, event.key]);
+ removeKeys();
+ };
- window.addEventListener("keydown", listener)
+ window.addEventListener("keydown", listener);
return () => {
- window.removeEventListener("keydown", listener)
- }
- }, [removeKeys])
-}
+ window.removeEventListener("keydown", listener);
+ };
+ }, [removeKeys]);
+};
export const useGlobalShortcuts = () => {
- const { t } = useTranslation()
- const navigate = useNavigate()
+ const { t } = useTranslation();
+ const navigate = useNavigate();
- const { mutateAsync } = useLogout()
+ const { mutateAsync } = useLogout();
const handleLogout = async () => {
await mutateAsync(undefined, {
onSuccess: () => {
- queryClient.clear()
- navigate("/login")
+ queryClient.clear();
+ navigate("/login");
},
- })
- }
+ });
+ };
const globalShortcuts: Shortcut[] = [
// Pages
@@ -198,7 +198,7 @@ export const useGlobalShortcuts = () => {
},
label: t("app.keyboardShortcuts.settings.goToStore"),
type: "settingShortcut",
- to: "/settings/store",
+ to: "/settings/seller",
},
{
keys: {
@@ -225,7 +225,7 @@ export const useGlobalShortcuts = () => {
type: "commandShortcut",
callback: () => handleLogout(),
},
- ]
+ ];
- return globalShortcuts
-}
+ return globalShortcuts;
+};