feat(admin-ui, medusa, medusa-react, medusa-js): Price List UI revamp (#5233)
* progress on cleanup * rm forceMount * close modal on succesful submit * fix: invalidate price list query on useAdminCreatePriceListPrices * sync translation keys * add last translations * sync translation keys * improve tabbing between cells * add comment * fix: remove double variant, set collision boundary on column dropdown * add widgets * update lock file * decrease details info size, and add missing status update function * sync translation keys * add snapshots and remove min/max * add missing filter menu for customer groups table * add translation keys for filter menu * rm unused code * Create tall-apricots-run.md * Update tall-apricots-run.md * fix: discard invalid paste values * add translation keys * bump snapshots + minor fixes * rm console.log * bump snapshots * bump ui packages, and add missing tax inclusive display in New form * update lock file * fix filter menu * update snapshot * update ui package and fix sub menu position --------- Co-authored-by: Sebastian Rindom <skrindom@gmail.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
This commit is contained in:
co-authored by
Sebastian Rindom
Oli Juhl
parent
4ca70a0d0c
commit
0f34e0f381
@@ -0,0 +1,86 @@
|
||||
import { DateComparisonOperator } from "@medusajs/types"
|
||||
|
||||
/**
|
||||
* Takes a key and a URLSearchParams and returns the parsed DateComparisonOperator if found
|
||||
* @param key - The key to search for
|
||||
* @param search - The URLSearchParams to search in
|
||||
* @returns - The parsed DateComparisonOperator or undefined if not found
|
||||
*/
|
||||
export const getDateComparisonOperatorFromSearchParams = (
|
||||
key: string,
|
||||
search: URLSearchParams
|
||||
): DateComparisonOperator | undefined => {
|
||||
const value = search.get(key)
|
||||
|
||||
if (!value) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const parsed = JSON.parse(value)
|
||||
|
||||
const acceptedKeys = ["lt", "gt", "gte", "lte"]
|
||||
|
||||
const filtered = Object.keys(parsed).reduce((acc, key) => {
|
||||
if (acceptedKeys.includes(key)) {
|
||||
acc[key as keyof DateComparisonOperator] = parsed[key]
|
||||
}
|
||||
|
||||
return acc
|
||||
}, {} as DateComparisonOperator)
|
||||
|
||||
if (Object.keys(filtered).length === 0) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const parsedDates = Object.keys(filtered).reduce((acc, key) => {
|
||||
if (filtered[key as keyof DateComparisonOperator]) {
|
||||
const stringValue = filtered[
|
||||
key as keyof DateComparisonOperator
|
||||
] as unknown as string
|
||||
|
||||
acc[key as keyof DateComparisonOperator] = new Date(stringValue)
|
||||
}
|
||||
|
||||
return acc
|
||||
}, {} as DateComparisonOperator)
|
||||
|
||||
return parsedDates
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a key and a URLSearchParams and returns the parsed string array if found
|
||||
* @param key - The key to search for
|
||||
* @param search - The URLSearchParams to search in
|
||||
* @returns - The parsed string array or undefined if not found
|
||||
*/
|
||||
export const getStringArrayFromSearchParams = (
|
||||
key: string,
|
||||
search: URLSearchParams
|
||||
): string[] | undefined => {
|
||||
const value = search.get(key)
|
||||
|
||||
if (!value) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return value.split(",").filter((s) => !!s)
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a key and a URLSearchParams and returns the parsed string if found
|
||||
* @param key - The key to search for
|
||||
* @param search - The URLSearchParams to search in
|
||||
* @returns - The parsed string or undefined if not found
|
||||
*/
|
||||
export const getStringFromSearchParams = (
|
||||
key: string,
|
||||
search: URLSearchParams
|
||||
): string | undefined => {
|
||||
const value = search.get(key)
|
||||
|
||||
if (!value) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user