diff --git a/packages/evershop/src/modules/oms/pages/admin/dashboard/Bestcustomers.jsx b/packages/evershop/src/modules/oms/pages/admin/dashboard/Bestcustomers.jsx index a51b75eb4..5e63dc1d4 100644 --- a/packages/evershop/src/modules/oms/pages/admin/dashboard/Bestcustomers.jsx +++ b/packages/evershop/src/modules/oms/pages/admin/dashboard/Bestcustomers.jsx @@ -3,9 +3,8 @@ import React from 'react'; import { useAppState } from '@components/common/context/app'; import { Card } from '@components/admin/cms/Card'; -export default function BestCustomers({ listUrl }) { +export default function BestCustomers({ listUrl, setting }) { const context = useAppState(); - const currency = context.currency || 'USD'; const customers = context.bestCustomers || []; return ( @@ -33,7 +32,7 @@ export default function BestCustomers({ listUrl }) { {customers.map((c, i) => { const grandTotal = new Intl.NumberFormat('en', { style: 'currency', - currency + currency: setting.storeCurrency }).format(c.total); return ( // eslint-disable-next-line react/no-array-index-key @@ -54,5 +53,17 @@ export default function BestCustomers({ listUrl }) { } BestCustomers.propTypes = { + setting: PropTypes.shape({ + storeCurrency: PropTypes.string + }).isRequired, listUrl: PropTypes.string.isRequired }; + +export const query = ` + query Query { + setting { + storeCurrency + } + listUrl: url(routeId: "productGrid") + } +`; \ No newline at end of file diff --git a/packages/evershop/src/modules/oms/pages/admin/dashboard/Bestsellers.jsx b/packages/evershop/src/modules/oms/pages/admin/dashboard/Bestsellers.jsx index 691f164a8..ec844da20 100644 --- a/packages/evershop/src/modules/oms/pages/admin/dashboard/Bestsellers.jsx +++ b/packages/evershop/src/modules/oms/pages/admin/dashboard/Bestsellers.jsx @@ -1,13 +1,10 @@ import PropTypes from 'prop-types'; import React from 'react'; import { toast } from 'react-toastify'; -import { useAppState } from '@components/common/context/app'; import { Card } from '@components/admin/cms/Card'; import './Bestsellers.scss'; -export default function BestSellers({ api, listUrl }) { - const context = useAppState(); - const currency = context.currency || 'USD'; +export default function BestSellers({ api, listUrl, setting }) { const [products, setProducts] = React.useState([]); const [fetching, setFetching] = React.useState(true); @@ -66,9 +63,9 @@ export default function BestSellers({ api, listUrl }) { )} {products.map((p, i) => { - const formatedPrice = new Intl.NumberFormat('en', { + const formattedPrice = new Intl.NumberFormat('en', { style: 'currency', - currency + currency: setting.storeCurrency }).format(p.price); return ( // eslint-disable-next-line react/no-array-index-key @@ -112,7 +109,7 @@ export default function BestSellers({ api, listUrl }) { {p.name} -