@medusajs/draft-order 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.medusa/server/src/admin/index.js +11326 -0
- package/.medusa/server/src/admin/index.mjs +11322 -0
- package/package.json +16 -16
- package/.medusa/server/src/admin/components/common/action-menu.js +0 -77
- package/.medusa/server/src/admin/components/common/conditional-tooltip.js +0 -15
- package/.medusa/server/src/admin/components/common/data-table.js +0 -249
- package/.medusa/server/src/admin/components/common/form.js +0 -151
- package/.medusa/server/src/admin/components/common/inline-tip.js +0 -42
- package/.medusa/server/src/admin/components/common/keybound-form.js +0 -32
- package/.medusa/server/src/admin/components/common/page-skeleton.js +0 -51
- package/.medusa/server/src/admin/components/common/thumbnail.js +0 -15
- package/.medusa/server/src/admin/components/draft-orders/activity-section.js +0 -205
- package/.medusa/server/src/admin/components/draft-orders/customer-section.js +0 -165
- package/.medusa/server/src/admin/components/draft-orders/general-section.js +0 -36
- package/.medusa/server/src/admin/components/draft-orders/json-view-section.js +0 -140
- package/.medusa/server/src/admin/components/draft-orders/metadata-section.js +0 -28
- package/.medusa/server/src/admin/components/draft-orders/shipping-section.js +0 -211
- package/.medusa/server/src/admin/components/draft-orders/summary-section.js +0 -148
- package/.medusa/server/src/admin/components/inputs/combobox.js +0 -311
- package/.medusa/server/src/admin/components/inputs/country-select.js +0 -59
- package/.medusa/server/src/admin/components/inputs/number-input.js +0 -100
- package/.medusa/server/src/admin/components/inputs/switch-block.js +0 -30
- package/.medusa/server/src/admin/components/modals/index.js +0 -19
- package/.medusa/server/src/admin/components/modals/route-drawer/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-drawer/route-drawer.js +0 -57
- package/.medusa/server/src/admin/components/modals/route-focus-modal/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-focus-modal/route-focus-modal.js +0 -71
- package/.medusa/server/src/admin/components/modals/route-modal-form/index.js +0 -4
- package/.medusa/server/src/admin/components/modals/route-modal-form/route-modal-form.js +0 -60
- package/.medusa/server/src/admin/components/modals/route-modal-provider/index.js +0 -6
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-modal-context.js +0 -5
- package/.medusa/server/src/admin/components/modals/route-modal-provider/route-provider.js +0 -30
- package/.medusa/server/src/admin/components/modals/route-modal-provider/use-route-modal.js +0 -12
- package/.medusa/server/src/admin/components/modals/stacked-drawer/index.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-drawer/stacked-drawer.js +0 -55
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/index.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-focus-modal/stacked-focus-modal.js +0 -63
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/index.js +0 -6
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-context.js +0 -5
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/stacked-modal-provider.js +0 -47
- package/.medusa/server/src/admin/components/modals/stacked-modal-provider/use-stacked-modal.js +0 -14
- package/.medusa/server/src/admin/components/utilities/generic-forward-ref.js +0 -7
- package/.medusa/server/src/admin/hooks/api/customers.js +0 -53
- package/.medusa/server/src/admin/hooks/api/draft-orders.js +0 -161
- package/.medusa/server/src/admin/hooks/api/orders.js +0 -274
- package/.medusa/server/src/admin/hooks/api/product-variants.js +0 -21
- package/.medusa/server/src/admin/hooks/api/regions.js +0 -35
- package/.medusa/server/src/admin/hooks/api/sales-channels.js +0 -35
- package/.medusa/server/src/admin/hooks/api/shipping-options.js +0 -35
- package/.medusa/server/src/admin/hooks/api/users.js +0 -26
- package/.medusa/server/src/admin/hooks/common/use-combobox-data.js +0 -61
- package/.medusa/server/src/admin/hooks/common/use-data-table-date-filters.js +0 -89
- package/.medusa/server/src/admin/hooks/common/use-debounced-search.js +0 -22
- package/.medusa/server/src/admin/hooks/common/use-query-params.js +0 -14
- package/.medusa/server/src/admin/hooks/order-edits/use-cancel-order-edit.js +0 -25
- package/.medusa/server/src/admin/hooks/order-edits/use-initiate-order-edit.js +0 -39
- package/.medusa/server/src/admin/lib/data/countries.js +0 -1762
- package/.medusa/server/src/admin/lib/data/currencies.js +0 -36
- package/.medusa/server/src/admin/lib/queries/draft-order-details.js +0 -1
- package/.medusa/server/src/admin/lib/queries/sdk.js +0 -10
- package/.medusa/server/src/admin/lib/schemas/address.js +0 -16
- package/.medusa/server/src/admin/lib/utils/address-utils.js +0 -57
- package/.medusa/server/src/admin/lib/utils/date-utils.js +0 -27
- package/.medusa/server/src/admin/lib/utils/order-utils.js +0 -13
- package/.medusa/server/src/admin/routes/draft-orders/@create/page.js +0 -659
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@billing-address/page.js +0 -228
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@custom-items/page.js +0 -38
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@email/page.js +0 -89
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@items/page.js +0 -576
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@metadata/page.js +0 -338
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@promotions/page.js +0 -70
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@sales-channel/page.js +0 -113
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@shipping/page.js +0 -465
- package/.medusa/server/src/admin/routes/draft-orders/_id_/@shipping-address/page.js +0 -241
- package/.medusa/server/src/admin/routes/draft-orders/_id_/page.js +0 -70
- package/.medusa/server/src/admin/routes/draft-orders/page.js +0 -148
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const getLocaleAmount = (amount, currencyCode) => {
|
|
2
|
-
const formatter = new Intl.NumberFormat([], {
|
|
3
|
-
style: "currency",
|
|
4
|
-
currencyDisplay: "narrowSymbol",
|
|
5
|
-
currency: currencyCode
|
|
6
|
-
});
|
|
7
|
-
return formatter.format(amount);
|
|
8
|
-
};
|
|
9
|
-
const getNativeSymbol = (currencyCode) => {
|
|
10
|
-
const formatted = new Intl.NumberFormat([], {
|
|
11
|
-
style: "currency",
|
|
12
|
-
currency: currencyCode,
|
|
13
|
-
currencyDisplay: "narrowSymbol"
|
|
14
|
-
}).format(0);
|
|
15
|
-
return formatted.replace(/\d/g, "").replace(/[.,]/g, "").trim();
|
|
16
|
-
};
|
|
17
|
-
const getDecimalDigits = (currencyCode) => {
|
|
18
|
-
const formatter = new Intl.NumberFormat(void 0, {
|
|
19
|
-
style: "currency",
|
|
20
|
-
currency: currencyCode
|
|
21
|
-
});
|
|
22
|
-
return formatter.resolvedOptions().maximumFractionDigits;
|
|
23
|
-
};
|
|
24
|
-
const getStylizedAmount = (amount, currencyCode) => {
|
|
25
|
-
const symbol = getNativeSymbol(currencyCode);
|
|
26
|
-
const decimalDigits = getDecimalDigits(currencyCode);
|
|
27
|
-
const total = amount.toLocaleString(void 0, {
|
|
28
|
-
minimumFractionDigits: decimalDigits,
|
|
29
|
-
maximumFractionDigits: decimalDigits
|
|
30
|
-
});
|
|
31
|
-
return `${symbol} ${total} ${currencyCode.toUpperCase()}`;
|
|
32
|
-
};
|
|
33
|
-
export {
|
|
34
|
-
getLocaleAmount,
|
|
35
|
-
getStylizedAmount
|
|
36
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { z } from "/Users/oliverjuhl/Desktop/medusa/draft-order-plugin/node_modules/zod/lib/index.mjs";
|
|
2
|
-
const addressSchema = z.object({
|
|
3
|
-
country_code: z.string().min(1),
|
|
4
|
-
first_name: z.string().min(1),
|
|
5
|
-
last_name: z.string().min(1),
|
|
6
|
-
address_1: z.string().min(1),
|
|
7
|
-
address_2: z.string().optional(),
|
|
8
|
-
company: z.string().optional(),
|
|
9
|
-
city: z.string().min(1),
|
|
10
|
-
province: z.string().optional(),
|
|
11
|
-
postal_code: z.string().min(1),
|
|
12
|
-
phone: z.string().optional()
|
|
13
|
-
});
|
|
14
|
-
export {
|
|
15
|
-
addressSchema
|
|
16
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { getCountryByIso2 } from "../data/countries.js";
|
|
2
|
-
function isSameAddress(a, b) {
|
|
3
|
-
if (!a || !b) {
|
|
4
|
-
return false;
|
|
5
|
-
}
|
|
6
|
-
return a.first_name === b.first_name && a.last_name === b.last_name && a.address_1 === b.address_1 && a.address_2 === b.address_2 && a.city === b.city && a.postal_code === b.postal_code && a.province === b.province && a.country_code === b.country_code && a.phone === b.phone && a.company === b.company;
|
|
7
|
-
}
|
|
8
|
-
function getFormattedAddress(address) {
|
|
9
|
-
if (!address) {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
const {
|
|
13
|
-
first_name,
|
|
14
|
-
last_name,
|
|
15
|
-
company,
|
|
16
|
-
address_1,
|
|
17
|
-
address_2,
|
|
18
|
-
city,
|
|
19
|
-
postal_code,
|
|
20
|
-
province,
|
|
21
|
-
country_code
|
|
22
|
-
} = address;
|
|
23
|
-
const country = "country" in address ? address.country : null;
|
|
24
|
-
const name = [first_name, last_name].filter(Boolean).join(" ");
|
|
25
|
-
const formattedAddress = [];
|
|
26
|
-
if (name) {
|
|
27
|
-
formattedAddress.push(name);
|
|
28
|
-
}
|
|
29
|
-
if (company) {
|
|
30
|
-
formattedAddress.push(company);
|
|
31
|
-
}
|
|
32
|
-
if (address_1) {
|
|
33
|
-
formattedAddress.push(address_1);
|
|
34
|
-
}
|
|
35
|
-
if (address_2) {
|
|
36
|
-
formattedAddress.push(address_2);
|
|
37
|
-
}
|
|
38
|
-
const cityProvincePostal = [city, province, postal_code].filter(Boolean).join(" ");
|
|
39
|
-
if (cityProvincePostal) {
|
|
40
|
-
formattedAddress.push(cityProvincePostal);
|
|
41
|
-
}
|
|
42
|
-
if (country) {
|
|
43
|
-
formattedAddress.push(country.display_name);
|
|
44
|
-
} else if (country_code) {
|
|
45
|
-
const country2 = getCountryByIso2(country_code);
|
|
46
|
-
if (country2) {
|
|
47
|
-
formattedAddress.push(country2.display_name);
|
|
48
|
-
} else {
|
|
49
|
-
formattedAddress.push(country_code.toUpperCase());
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return formattedAddress;
|
|
53
|
-
}
|
|
54
|
-
export {
|
|
55
|
-
getFormattedAddress,
|
|
56
|
-
isSameAddress
|
|
57
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { formatDistance, sub, format } from "date-fns";
|
|
2
|
-
import { enUS } from "/Users/oliverjuhl/Desktop/medusa/draft-order-plugin/node_modules/date-fns/locale.mjs";
|
|
3
|
-
const LOCALE = enUS;
|
|
4
|
-
function getRelativeDate(date) {
|
|
5
|
-
const now = /* @__PURE__ */ new Date();
|
|
6
|
-
return formatDistance(sub(new Date(date), { minutes: 0 }), now, {
|
|
7
|
-
addSuffix: true,
|
|
8
|
-
locale: LOCALE
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
const getFullDate = ({
|
|
12
|
-
date,
|
|
13
|
-
includeTime = false
|
|
14
|
-
}) => {
|
|
15
|
-
const ensuredDate = new Date(date);
|
|
16
|
-
if (isNaN(ensuredDate.getTime())) {
|
|
17
|
-
return "";
|
|
18
|
-
}
|
|
19
|
-
const timeFormat = includeTime ? "p" : "";
|
|
20
|
-
return format(ensuredDate, `PP ${timeFormat}`, {
|
|
21
|
-
locale: LOCALE
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
getFullDate,
|
|
26
|
-
getRelativeDate
|
|
27
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
function getUniqueShippingProfiles(items) {
|
|
2
|
-
const shippingProfiles = items.map((item) => {
|
|
3
|
-
var _a, _b;
|
|
4
|
-
return (_b = (_a = item.variant) == null ? void 0 : _a.product) == null ? void 0 : _b.shipping_profile;
|
|
5
|
-
}).filter(Boolean);
|
|
6
|
-
const uniqueShippingProfiles = shippingProfiles.filter(
|
|
7
|
-
(profile, index, self) => self.findIndex((p) => p.id === profile.id) === index
|
|
8
|
-
);
|
|
9
|
-
return uniqueShippingProfiles;
|
|
10
|
-
}
|
|
11
|
-
export {
|
|
12
|
-
getUniqueShippingProfiles
|
|
13
|
-
};
|