Skip to content
Open
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/app-elements/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ const en = {
"order.country_code": "country code",
"order.currency_code": "currency code",
"order.customer_email": "customer email",
"order.customer.customer_group.id": "customer group id",
"order.customer.customer_group.id": "customer group",
"order.customer.customer_group.name": "customer group name",
"order.customer.email": "customer email",
"order.customer.tags.id": "customer tag",
Expand Down
2 changes: 1 addition & 1 deletion packages/app-elements/src/locales/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ const it: typeof en = {
"order.currency_code": "valuta (3 lettere)",
"order.customer_email": "email del customer",
"order.customer.email": "email del customer",
"order.customer.customer_group.id": "id del customer group",
"order.customer.customer_group.id": "customer group",
"order.customer.customer_group.name": "nome del customer group",
"order.customer.tags.id": "customer tag",
"order.customer.tags.name": "nome del customer tag",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const selectableResources = {
sku: "skus",
sku_list: "sku_lists",
bundle: "bundles",
customer_group: "customer_groups",
} as const satisfies Record<string, ListableResourceType>

export function getResourceType(resourceId: string | undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const InputResourceSelector: React.FC<{
value?: ItemWithValue["value"]
resource: Extract<
ListableResourceType,
"markets" | "tags" | "skus" | "sku_lists" | "bundles"
"markets" | "tags" | "skus" | "sku_lists" | "bundles" | "customer_groups"
>
resourceKey: string
isMulti?: boolean
Expand Down
88 changes: 88 additions & 0 deletions packages/docs/src/mocks/data/customer_groups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { HttpResponse, http } from "msw"

const mockedCustomerGroups = [
{
id: "rlEPzheRgO",
type: "customer_groups",
links: {
self: "https://mock.localhost/api/customer_groups/rlEPzheRgO",
},
attributes: {
name: "VIP",
created_at: "2022-08-23T09:59:25.940Z",
updated_at: "2022-08-23T09:59:25.940Z",
reference: "",
reference_origin: "",
metadata: {},
},
meta: { mode: "test", organization_id: "WXlEOFrjnr" },
},
{
id: "dlQbPhNNop",
type: "customer_groups",
links: {
self: "https://mock.localhost/api/customer_groups/dlQbPhNNop",
},
attributes: {
name: "Wholesale",
created_at: "2022-03-11T09:40:49.000Z",
updated_at: "2023-03-13T13:30:32.184Z",
reference: "customer_group_1",
reference_origin: "CLI",
metadata: {},
},
meta: { mode: "test", organization_id: "WXlEOFrjnr" },
},
{
id: "AlRevhXQga",
type: "customer_groups",
links: {
self: "https://mock.localhost/api/customer_groups/AlRevhXQga",
},
attributes: {
name: "Employees",
created_at: "2022-05-13T12:27:05.075Z",
updated_at: "2022-05-13T12:27:05.075Z",
reference: "",
reference_origin: "",
metadata: {},
},
meta: { mode: "test", organization_id: "WXlEOFrjnr" },
},
]

const singleCustomerGroup = http.get(
`https://mock.localhost/api/customer_groups/:customerGroupId`,
async ({ params }) => {
const customerGroup = mockedCustomerGroups.find(
(item) => item.id === params.customerGroupId,
)
return HttpResponse.json({
data: customerGroup ?? mockedCustomerGroups[0],
})
},
)

const organizationCustomerGroups = http.get(
`https://mock.localhost/api/customer_groups`,
async ({ request }) => {
const url = new URL(request.url)
const name =
url.searchParams.get("filter[q][name_i_cont]")?.toLowerCase() ?? ""
const idIn = url.searchParams.get("filter[q][id_in]")

const filtered = mockedCustomerGroups.filter((customerGroup) => {
if (idIn != null) {
return idIn.split(",").includes(customerGroup.id)
}
return customerGroup.attributes.name.toLowerCase().includes(name)
})

return HttpResponse.json({
data: filtered,
meta: { record_count: filtered.length, page_count: 1 },
})
},
)

export default [singleCustomerGroup, organizationCustomerGroups]
2 changes: 2 additions & 0 deletions packages/docs/src/mocks/handlers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import addresses from "./data/addresses"
import adjustments from "./data/adjustments"
import bundles from "./data/bundles"
import customerGroups from "./data/customer_groups"
import customers from "./data/customers"
import lineItems from "./data/line_items"
import markets from "./data/markets"
Expand All @@ -14,6 +15,7 @@ export const handlers = [
...addresses,
...adjustments,
...bundles,
...customerGroups,
...customers,
...lineItems,
...markets,
Expand Down
Loading