Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Show an error state when a home widget's query fails
Damian Legawiec145b1f1b4471
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/index.tsxindex 8f8e9eb1b4..9212756c53 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/index.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/index.tsx@@ -121,7 +121,7 @@ function DashboardPage() {// No `placeholderData`: it belongs to the channel that was selected before,// and showing another channel's counts under this one's name is worse than// showing the skeleton for a moment.- const { data: operations } = useQuery({+ const { data: operations, error: operationsError } = useQuery({queryKey: useResourceKey('dashboard', 'operations', channelId),queryFn: () => adminClient.dashboard.operations({ channel_id: channelParam }),staleTime: 5 * 60 * 1000,@@ -193,6 +193,7 @@ function DashboardPage() {<div className="grid gap-6 lg:grid-cols-5"><OperationsCarddata={operations}+ failed={!!operationsError}channelId={channelParam}className={rankingTabs.length > 0 ? 'lg:col-span-2' : 'lg:col-span-5'}/>@@ -257,11 +258,14 @@ function OperationsCard({data,className,channelId,+ failed,}: {data: DashboardOperations | undefinedclassName: string/** The screen's channel, or undefined for all channels. */channelId: string | undefined+ /** The counts could not be loaded — show a dash rather than a skeleton forever. */+ failed: boolean}) {const { t } = useTranslation()const { storeId } = Route.useParams()@@ -292,7 +296,11 @@ function OperationsCard({</span><span className="flex-1 text-sm">{t(`admin.pages.home.operations.${key}`)}</span>{count === undefined ? (- <Skeleton className="h-4 w-8" />+ failed ? (+ <span className="text-sm text-muted-foreground">—</span>+ ) : (+ <Skeleton className="h-4 w-8" />+ )) : (<spanclassName={cn(@@ -379,7 +387,7 @@ function RankingsCard({const [tab, setTab] = useState<RankingTab>(tabs[0])const { query, revenueMetric, countMetric } = RANKING_QUERIES[tab]- const { data, isPlaceholderData } = useReportingQuery({ ...query, ...scope })+ const { data, error, isPlaceholderData } = useReportingQuery({ ...query, ...scope })// Placeholder data belongs to the previous tab (other dimension, other// metrics) — show the skeleton until this tab's own rows arrive.@@ -420,7 +428,13 @@ function RankingsCard({</CardHeader><CardContent className="p-0">{rows === undefined ? (- <RankingRowsSkeleton />+ error ? (+ <p className="px-4 pb-6 pt-2 text-sm text-muted-foreground">+ {t('admin.errors.generic')}+ </p>+ ) : (+ <RankingRowsSkeleton />+ )) : rows.length === 0 ? (<p className="px-4 pb-6 pt-2 text-sm text-muted-foreground">{t('admin.pages.home.rankings.empty')}