mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 22:16:58 +00:00
18 lines
552 B
TypeScript
18 lines
552 B
TypeScript
import { MedusaProductOption } from './medusa/types';
|
|
|
|
export const createUrl = (pathname: string, params: URLSearchParams) => {
|
|
const paramsString = params.toString();
|
|
const queryString = `${paramsString.length ? '?' : ''}${paramsString}`;
|
|
|
|
return `${pathname}${queryString}`;
|
|
};
|
|
|
|
export const mapOptionIds = (productOptions: MedusaProductOption[]) => {
|
|
// Maps the option titles to their respective ids
|
|
const map: Record<string, string> = {};
|
|
productOptions.forEach((option) => {
|
|
map[option.id] = option.title;
|
|
});
|
|
return map;
|
|
};
|