Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(admin-ui): Bulk editor default fields #5829

Merged
merged 4 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/admin-ui/ui/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,7 @@
"price-list-prices-form-prices-count_other": "{{count}} prices",
"price-list-product-prices-form-invalid-data-title": "Invalid data",
"price-list-product-prices-form-invalid-data-body": "The data you pasted contains values that are not numbers.",
"price-list-product-prices-form-column-visibility-button": "View",
"price-list-product-prices-form-column-visibility-button": "Currencies",
"price-list-product-prices-form-column-visibility-currencies-label": "Currencies",
"price-list-product-prices-form-column-visibility-regions-label": "Regions",
"price-list-product-prices-form-column-product-label": "Product",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function EditPricesActions(props: EditPricesActionsProps) {
<DropdownMenu.Root>
<DropdownMenu.Trigger asChild>
<Button variant="secondary" size="small" className="text-gray-700">
View
Currencies
<AdjustmentsIcon size={20} />
</Button>
</DropdownMenu.Trigger>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { MoneyAmount, Product } from "@medusajs/client-types"
import { useAdminRegions, useAdminUpdateVariant } from "medusa-react"
import {
useAdminRegions,
useAdminStore,
useAdminUpdateVariant,
} from "medusa-react"
import { useEffect, useMemo, useRef, useState } from "react"
import {
getAllProductPricesCurrencies,
Expand Down Expand Up @@ -52,6 +56,7 @@ function EditPricesModal(props: EditPricesModalProps) {
const { regions: storeRegions } = useAdminRegions({
limit: 1000,
})
const { store } = useAdminStore()

const regionCurrenciesMap = useRegionsCurrencyMap()
const regions = getAllProductPricesRegions(props.product).sort()
Expand All @@ -64,7 +69,14 @@ function EditPricesModal(props: EditPricesModalProps) {
useState(false)
const [showSaveConfirmationPrompt, setShowSaveConfirmationPrompt] =
useState(false)
const [selectedCurrencies, setSelectedCurrencies] = useState(currencies)

const initialCurrencies =
!currencies.length && !regions.length
? store?.currencies.map((c) => c.code)
: currencies

const [selectedCurrencies, setSelectedCurrencies] =
useState(initialCurrencies)
const [selectedRegions, setSelectedRegions] = useState<string[]>(regions)

const toggleCurrency = (currencyCode: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ const PriceListProductPricesForm = ({
<Adjustments className="text-ui-fg-subtle" />
{t(
"price-list-product-prices-form-column-visibility-button",
"View"
"Currencies"
)}
</Button>
</DropdownMenu.Trigger>
Expand Down