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.

chore: v2.0.0-canary.24

vholikd004995ebd56
diff --git a/packages/admin/package.json b/packages/admin/package.json
index 7acddc674..bceeb245d 100644
--- a/packages/admin/package.json
+++ b/packages/admin/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/admin",
- "version": "2.0.0-canary.23",
+ "version": "2.0.0-canary.24",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/admin/src/components/layout/notifications/notifications.tsx b/packages/admin/src/components/layout/notifications/notifications.tsx
index 7b5b69646..81a2456ae 100644
--- a/packages/admin/src/components/layout/notifications/notifications.tsx
+++ b/packages/admin/src/components/layout/notifications/notifications.tsx
@@ -2,67 +2,75 @@ import {
BellAlert,
BellAlertDone,
InformationCircleSolid,
-} from "@medusajs/icons"
-import { HttpTypes } from "@medusajs/types"
-import { clx, Drawer, Heading, IconButton, Text } from "@medusajs/ui"
-import { formatDistance } from "date-fns"
-import { TFunction } from "i18next"
-import { useEffect, useState } from "react"
-import { useTranslation } from "react-i18next"
-import { notificationQueryKeys, useNotifications } from "../../../hooks/api"
-import { sdk } from "../../../lib/client"
-import { FilePreview } from "../../common/file-preview"
-import { InfiniteList } from "../../common/infinite-list"
+} from "@medusajs/icons";
+import { HttpTypes } from "@medusajs/types";
+import { clx, Drawer, Heading, IconButton, Text } from "@medusajs/ui";
+import { formatDistance } from "date-fns";
+import { TFunction } from "i18next";
+import { useEffect, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { notificationQueryKeys, useNotifications } from "../../../hooks/api";
+import { sdk } from "../../../lib/client";
+import { FilePreview } from "../../common/file-preview";
+import { InfiniteList } from "../../common/infinite-list";
+import { InferClientInput } from "@mercurjs/client";
interface NotificationData {
- title: string
- description?: string
+ title: string;
+ description?: string;
file?: {
- filename?: string
- url?: string
- mimeType?: string
- }
+ filename?: string;
+ url?: string;
+ mimeType?: string;
+ };
}
-const LAST_READ_NOTIFICATION_KEY = "notificationsLastReadAt"
+const LAST_READ_NOTIFICATION_KEY = "notificationsLastReadAt";
export const Notifications = () => {
- const { t } = useTranslation()
- const [open, setOpen] = useState(false)
- const [hasUnread, setHasUnread] = useUnreadNotifications()
+ const { t } = useTranslation();
+ const [open, setOpen] = useState(false);
+ const [hasUnread, setHasUnread] = useUnreadNotifications();
// This is used to show the unread icon on the notification when the drawer is open,
// so it should lag behind the local storage data and should only be reset on close
const [lastReadAt, setLastReadAt] = useState(
- localStorage.getItem(LAST_READ_NOTIFICATION_KEY)
- )
+ localStorage.getItem(LAST_READ_NOTIFICATION_KEY),
+ );
useEffect(() => {
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === "n" && (e.metaKey || e.ctrlKey)) {
- setOpen((prev) => !prev)
+ setOpen((prev) => !prev);
}
- }
+ };
- document.addEventListener("keydown", onKeyDown)
+ document.addEventListener("keydown", onKeyDown);
return () => {
- document.removeEventListener("keydown", onKeyDown)
- }
- }, [])
+ document.removeEventListener("keydown", onKeyDown);
+ };
+ }, []);
const handleOnOpen = (shouldOpen: boolean) => {
if (shouldOpen) {
- setHasUnread(false)
- setOpen(true)
- localStorage.setItem(LAST_READ_NOTIFICATION_KEY, new Date().toISOString())
+ setHasUnread(false);
+ setOpen(true);
+ localStorage.setItem(
+ LAST_READ_NOTIFICATION_KEY,
+ new Date().toISOString(),
+ );
} else {
- setOpen(false)
- setLastReadAt(localStorage.getItem(LAST_READ_NOTIFICATION_KEY))
+ setOpen(false);
+ setLastReadAt(localStorage.getItem(LAST_READ_NOTIFICATION_KEY));
}
- }
+ };
return (
- <Drawer open={open} onOpenChange={handleOnOpen} data-testid="notifications-drawer">
+ <Drawer
+ open={open}
+ onOpenChange={handleOnOpen}
+ data-testid="notifications-drawer"
+ >
<Drawer.Trigger asChild>
<IconButton
variant="transparent"
@@ -70,19 +78,31 @@ export const Notifications = () => {
className="text-ui-fg-muted hover:text-ui-fg-subtle"
data-testid="notifications-trigger-button"
>
- {hasUnread ? <BellAlertDone data-testid="notifications-icon-unread" /> : <BellAlert data-testid="notifications-icon" />}
+ {hasUnread ? (
+ <BellAlertDone data-testid="notifications-icon-unread" />
+ ) : (
+ <BellAlert data-testid="notifications-icon" />
+ )}
</IconButton>
</Drawer.Trigger>
<Drawer.Content data-testid="notifications-content">
<Drawer.Header data-testid="notifications-header">
<Drawer.Title asChild>
- <Heading data-testid="notifications-title">{t("notifications.domain")}</Heading>
+ <Heading data-testid="notifications-title">
+ {t("notifications.domain")}
+ </Heading>
</Drawer.Title>
- <Drawer.Description className="sr-only" data-testid="notifications-description">
+ <Drawer.Description
+ className="sr-only"
+ data-testid="notifications-description"
+ >
{t("notifications.accessibility.description")}
</Drawer.Description>
</Drawer.Header>
- <Drawer.Body className="overflow-y-auto px-0" data-testid="notifications-body">
+ <Drawer.Body
+ className="overflow-y-auto px-0"
+ data-testid="notifications-body"
+ >
<div data-testid="notifications-list">
<InfiniteList<
HttpTypes.AdminNotificationListResponse,
@@ -91,7 +111,13 @@ export const Notifications = () => {
>
responseKey="notifications"
queryKey={notificationQueryKeys.all}
- queryFn={(params) => sdk.admin.notification.list(params)}
+ queryFn={(params) =>
+ sdk.admin.notifications.query({
+ ...(params as InferClientInput<
+ typeof sdk.admin.notifications.query
+ >),
+ })
+ }
queryOptions={{ enabled: open }}
renderEmpty={() => <NotificationsEmptyState t={t} />}
renderItem={(notification) => {
@@ -104,43 +130,63 @@ export const Notifications = () => {
(lastReadAt ? Date.parse(lastReadAt) : 0)
}
/>
- )
+ );
}}
/>
</div>
</Drawer.Body>
</Drawer.Content>
</Drawer>
- )
-}
+ );
+};
const Notification = ({
notification,
unread,
}: {
- notification: HttpTypes.AdminNotification
- unread?: boolean
+ notification: HttpTypes.AdminNotification;
+ unread?: boolean;
}) => {
- const data = notification.data as unknown as NotificationData | undefined
+ const data = notification.data as unknown as NotificationData | undefined;
// We need at least the title to render a notification in the feed
if (!data?.title) {
- return null
+ return null;
}
return (
<>
- <div className="relative flex items-start justify-center gap-3 border-b p-6" data-testid={`notification-${notification.id}`}>
- <div className="text-ui-fg-muted flex size-5 items-center justify-center" data-testid={`notification-${notification.id}-icon`}>
+ <div
+ className="relative flex items-start justify-center gap-3 border-b p-6"
+ data-testid={`notification-${notification.id}`}
+ >
+ <div
+ className="text-ui-fg-muted flex size-5 items-center justify-center"
+ data-testid={`notification-${notification.id}-icon`}
+ >
<InformationCircleSolid />
</div>
- <div className="flex w-full flex-col gap-y-3" data-testid={`notification-${notification.id}-content`}>
- <div className="flex flex-col" data-testid={`notification-${notification.id}-header`}>
+ <div
+ className="flex w-full flex-col gap-y-3"
+ data-testid={`notification-${notification.id}-content`}
+ >
+ <div
+ className="flex flex-col"
+ data-testid={`notification-${notification.id}-header`}
+ >
<div className="flex items-center justify-between">
- <Text size="small" leading="compact" weight="plus" data-testid={`notification-${notification.id}-title`}>
+ <Text
+ size="small"
+ leading="compact"
+ weight="plus"
+ data-testid={`notification-${notification.id}-title`}
+ >
{data.title}
</Text>
- <div className="align-center flex items-center justify-center gap-2" data-testid={`notification-${notification.id}-meta`}>
+ <div
+ className="align-center flex items-center justify-center gap-2"
+ data-testid={`notification-${notification.id}-meta`}
+ >
<Text
as={"span"}
className={clx("text-ui-fg-subtle", {
@@ -185,14 +231,23 @@ const Notification = ({
</div>
</div>
</>
- )
-}
+ );
+};
const NotificationsEmptyState = ({ t }: { t: TFunction }) => {
return (
- <div className="flex h-full flex-col items-center justify-center" data-testid="notifications-empty-state">
+ <div
+ className="flex h-full flex-col items-center justify-center"
+ data-testid="notifications-empty-state"
+ >
<BellAlertDone data-testid="notifications-empty-icon" />
- <Text size="small" leading="compact" weight="plus" className="mt-3" data-testid="notifications-empty-title">
+ <Text
+ size="small"
+ leading="compact"
+ weight="plus"
+ className="mt-3"
+ data-testid="notifications-empty-title"
+ >
{t("notifications.emptyState.title")}
</Text>
<Text
@@ -203,33 +258,33 @@ const NotificationsEmptyState = ({ t }: { t: TFunction }) => {
{t("notifications.emptyState.description")}
</Text>
</div>
- )
-}
+ );
+};
const useUnreadNotifications = () => {
- const [hasUnread, setHasUnread] = useState(false)
+ const [hasUnread, setHasUnread] = useState(false);
const { notifications } = useNotifications(
{ limit: 1, offset: 0, fields: "created_at" },
- { refetchInterval: 60_000 }
- )
- const lastNotification = notifications?.[0]
+ { refetchInterval: 60_000 },
+ );
+ const lastNotification = notifications?.[0];
useEffect(() => {
if (!lastNotification) {
- return
+ return;
}
- const lastNotificationAsTimestamp = Date.parse(lastNotification.created_at)
+ const lastNotificationAsTimestamp = Date.parse(lastNotification.created_at);
- const lastReadDatetime = localStorage.getItem(LAST_READ_NOTIFICATION_KEY)
+ const lastReadDatetime = localStorage.getItem(LAST_READ_NOTIFICATION_KEY);
const lastReadAsTimestamp = lastReadDatetime
? Date.parse(lastReadDatetime)
- : 0
+ : 0;
if (lastNotificationAsTimestamp > lastReadAsTimestamp) {
- setHasUnread(true)
+ setHasUnread(true);
}
- }, [lastNotification])
+ }, [lastNotification]);
- return [hasUnread, setHasUnread] as const
-}
+ return [hasUnread, setHasUnread] as const;
+};
diff --git a/packages/admin/src/i18n/translations/index.ts b/packages/admin/src/i18n/translations/index.ts
index 457a4c8da..03770d33c 100644
--- a/packages/admin/src/i18n/translations/index.ts
+++ b/packages/admin/src/i18n/translations/index.ts
@@ -27,7 +27,7 @@ import ko from "./ko.json"
import nl from "./nl.json"
import bs from "./bs.json"
import id from "./id.json"
-export default {
+const translations: Record<string, { translation: Record<string, unknown> }> = {
bs: {
translation: bs,
},
@@ -116,3 +116,5 @@ export default {
translation: id,
},
}
+
+export default translations
diff --git a/packages/cli/package.json b/packages/cli/package.json
index b4206b807..547581fa0 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/cli",
- "version": "2.0.0-canary.23",
+ "version": "2.0.0-canary.24",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/client/package.json b/packages/client/package.json
index dff4d0d46..2c6a18cdc 100644
--- a/packages/client/package.json
+++ b/packages/client/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/client",
- "version": "2.0.0-canary.23",
+ "version": "2.0.0-canary.24",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/core-plugin/package.json b/packages/core-plugin/package.json
index 8994163db..b4f665bb5 100644
--- a/packages/core-plugin/package.json
+++ b/packages/core-plugin/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/core-plugin",
- "version": "2.0.0-canary.23",
+ "version": "2.0.0-canary.24",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/dashboard-sdk/package.json b/packages/dashboard-sdk/package.json
index 25e881de3..a4c4e71e5 100644
--- a/packages/dashboard-sdk/package.json
+++ b/packages/dashboard-sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/dashboard-sdk",
- "version": "2.0.0-canary.23",
+ "version": "2.0.0-canary.24",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/dashboard-shared/package.json b/packages/dashboard-shared/package.json
index 7f4e7d788..e918db24b 100644
--- a/packages/dashboard-shared/package.json
+++ b/packages/dashboard-shared/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/dashboard-shared",
- "version": "2.0.0-canary.23",
+ "version": "2.0.0-canary.24",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/types/package.json b/packages/types/package.json
index 2de5364ae..d5896473c 100644
--- a/packages/types/package.json
+++ b/packages/types/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/types",
- "version": "2.0.0-canary.23",
+ "version": "2.0.0-canary.24",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",
diff --git a/packages/vendor/package.json b/packages/vendor/package.json
index 78fc5223e..732ee76c1 100644
--- a/packages/vendor/package.json
+++ b/packages/vendor/package.json
@@ -1,6 +1,6 @@
{
"name": "@mercurjs/vendor",
- "version": "2.0.0-canary.23",
+ "version": "2.0.0-canary.24",
"repository": {
"type": "git",
"url": "https://github.com/mercurjs/mercur",