-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into docs/router-page
- Loading branch information
Showing
503 changed files
with
233,772 additions
and
229,902 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 34 additions & 13 deletions
47
...s/admin/dashboard/src/routes/locations/common/hooks/use-shipping-option-price-columns.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,53 @@ | ||
import { HttpTypes } from "@medusajs/types" | ||
import { useMemo } from "react" | ||
import { useTranslation } from "react-i18next" | ||
import { | ||
createDataGridHelper, | ||
DataGrid, | ||
} from "../../../../components/data-grid" | ||
import { createDataGridPriceColumns } from "../../../../components/data-grid/helpers/create-data-grid-price-columns" | ||
|
||
const columnHelper = createDataGridHelper() | ||
|
||
export const useShippingOptionPriceColumns = ({ | ||
name, | ||
currencies = [], | ||
regions = [], | ||
pricePreferences = [], | ||
}: { | ||
name: string | ||
currencies?: string[] | ||
regions?: HttpTypes.AdminRegion[] | ||
pricePreferences?: HttpTypes.AdminPricePreference[] | ||
}) => { | ||
const { t } = useTranslation() | ||
|
||
return useMemo(() => { | ||
return createDataGridPriceColumns({ | ||
currencies, | ||
regions, | ||
pricePreferences, | ||
getFieldName: (context, value) => { | ||
if (context.column.id.startsWith("currency_prices")) { | ||
return `currency_prices.${value}` | ||
} | ||
return [ | ||
columnHelper.column({ | ||
id: "name", | ||
header: t("fields.name"), | ||
cell: (context) => { | ||
return ( | ||
<DataGrid.ReadonlyCell context={context}> | ||
{name} | ||
</DataGrid.ReadonlyCell> | ||
) | ||
}, | ||
}), | ||
...createDataGridPriceColumns({ | ||
currencies, | ||
regions, | ||
pricePreferences, | ||
getFieldName: (context, value) => { | ||
if (context.column.id?.startsWith("currency_prices")) { | ||
return `currency_prices.${value}` | ||
} | ||
|
||
return `region_prices.${value}` | ||
}, | ||
t, | ||
}) | ||
}, [t, currencies, regions, pricePreferences]) | ||
return `region_prices.${value}` | ||
}, | ||
t, | ||
}), | ||
] | ||
}, [t, currencies, regions, pricePreferences, name]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.