Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] develop from medusajs:develop #5

Merged
merged 7 commits into from
Dec 4, 2024
Merged
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
5 changes: 5 additions & 0 deletions .changeset/nice-tools-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/framework": patch
---

fix(framework): Apply CORS and auth middleware for global middleware that is not already applied by routes
5 changes: 5 additions & 0 deletions .changeset/rotten-spoons-brake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/dashboard": patch
---

fix(dashboard): Add Shipping Profile metadata route
91 changes: 69 additions & 22 deletions integration-tests/http/__tests__/order/admin/order.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,41 @@ medusaIntegrationTestRunner({
version: 1,
change_type: "update_order",
status: "confirmed",
created_by: expect.any(String),
confirmed_by: expect.any(String),
confirmed_at: expect.any(String),
actions: expect.arrayContaining([
expect.objectContaining({
version: 1,
applied: true,
reference_id: addressBefore.id,
reference: "shipping_address",
action: "UPDATE_ORDER_PROPERTIES",
details: {
city: "New New York",
address_1: "New Main street 123",
},
details: expect.objectContaining({
type: "shipping_address",
old: expect.objectContaining({
address_1: addressBefore.address_1,
city: addressBefore.city,
country_code: addressBefore.country_code,
province: addressBefore.province,
postal_code: addressBefore.postal_code,
phone: addressBefore.phone,
company: addressBefore.company,
first_name: addressBefore.first_name,
last_name: addressBefore.last_name,
address_2: addressBefore.address_2,
}),
new: expect.objectContaining({
address_1: "New Main street 123",
city: "New New York",
country_code: addressBefore.country_code,
province: addressBefore.province,
postal_code: addressBefore.postal_code,
phone: addressBefore.phone,
company: addressBefore.company,
first_name: addressBefore.first_name,
last_name: addressBefore.last_name,
address_2: addressBefore.address_2,
}),
}),
}),
]),
})
Expand Down Expand Up @@ -162,18 +185,33 @@ medusaIntegrationTestRunner({
version: 1,
change_type: "update_order",
status: "confirmed",
created_by: expect.any(String),
confirmed_by: expect.any(String),
confirmed_at: expect.any(String),
actions: expect.arrayContaining([
expect.objectContaining({
version: 1,
applied: true,
reference_id: addressBefore.id,
reference: "billing_address",
action: "UPDATE_ORDER_PROPERTIES",
details: {
city: "New New York",
address_1: "New Main street 123",
},
details: expect.objectContaining({
type: "billing_address",
old: expect.objectContaining({
address_1: addressBefore.address_1,
city: addressBefore.city,
country_code: addressBefore.country_code,
province: addressBefore.province,
postal_code: addressBefore.postal_code,
phone: addressBefore.phone,
}),
new: expect.objectContaining({
address_1: "New Main street 123",
city: "New New York",
country_code: addressBefore.country_code,
province: addressBefore.province,
postal_code: addressBefore.postal_code,
phone: addressBefore.phone,
}),
}),
}),
]),
})
Expand Down Expand Up @@ -239,16 +277,23 @@ medusaIntegrationTestRunner({
change_type: "update_order",
status: "confirmed",
confirmed_at: expect.any(String),
created_by: expect.any(String),
confirmed_by: expect.any(String),
actions: expect.arrayContaining([
expect.objectContaining({
version: 1,
applied: true,
reference_id: order.shipping_address.id,
reference: "shipping_address",
action: "UPDATE_ORDER_PROPERTIES",
details: {
address_1: "New Main street 123",
},
details: expect.objectContaining({
type: "shipping_address",
old: expect.objectContaining({
address_1: order.shipping_address.address_1,
city: order.shipping_address.city,
}),
new: expect.objectContaining({
address_1: "New Main street 123",
}),
}),
}),
]),
}),
Expand All @@ -257,16 +302,18 @@ medusaIntegrationTestRunner({
change_type: "update_order",
status: "confirmed",
confirmed_at: expect.any(String),
created_by: expect.any(String),
confirmed_by: expect.any(String),
actions: expect.arrayContaining([
expect.objectContaining({
version: 1,
applied: true,
reference_id: order.email,
reference: "email",
action: "UPDATE_ORDER_PROPERTIES",
details: {
email: "[email protected]",
},
details: expect.objectContaining({
type: "email",
old: order.email,
new: "[email protected]",
}),
}),
]),
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Avatar, Text } from "@medusajs/ui"
import { Link } from "react-router-dom"
import { useUser } from "../../../hooks/api/users"

type UserLinkProps = {
id: string
Expand Down Expand Up @@ -32,3 +33,13 @@ export const UserLink = ({
</Link>
)
}

export const By = ({ id }: { id: string }) => {
const { user } = useUser(id) // todo: extend to support customers

if (!user) {
return null
}

return <UserLink {...user} />
}
31 changes: 31 additions & 0 deletions packages/admin/dashboard/src/hooks/api/orders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,37 @@ export const useOrder = (
return { ...data, ...rest }
}

export const useUpdateOrder = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminOrderResponse,
FetchError,
HttpTypes.AdminUpdateOrder
>
) => {
return useMutation({
mutationFn: (payload: HttpTypes.AdminUpdateOrder) =>
sdk.admin.order.update(id, payload),
onSuccess: (data: any, variables: any, context: any) => {
queryClient.invalidateQueries({
queryKey: ordersQueryKeys.detail(id),
})

queryClient.invalidateQueries({
queryKey: ordersQueryKeys.changes(id),
})

// TODO: enable when needed
// queryClient.invalidateQueries({
// queryKey: ordersQueryKeys.lists(),
// })

options?.onSuccess?.(data, variables, context)
},
...options,
})
}

export const useOrderPreview = (
id: string,
query?: HttpTypes.AdminOrderFilters,
Expand Down
26 changes: 26 additions & 0 deletions packages/admin/dashboard/src/hooks/api/shipping-profiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,32 @@ export const useShippingProfiles = (
return { ...data, ...rest }
}

export const useUpdateShippingProfile = (
id: string,
options?: UseMutationOptions<
HttpTypes.AdminShippingProfileResponse,
FetchError,
HttpTypes.AdminUpdateShippingProfile
>
) => {
const { data, ...rest } = useMutation({
mutationFn: (payload) => sdk.admin.shippingProfile.update(id, payload),
onSuccess: (data, variables, context) => {
queryClient.invalidateQueries({
queryKey: shippingProfileQueryKeys.detail(id),
})
queryClient.invalidateQueries({
queryKey: shippingProfileQueryKeys.lists(),
})

options?.onSuccess?.(data, variables, context)
},
...options,
})

return { ...data, ...rest }
}

export const useDeleteShippingProfile = (
id: string,
options?: UseMutationOptions<
Expand Down
97 changes: 95 additions & 2 deletions packages/admin/dashboard/src/i18n/translations/$schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4146,6 +4146,65 @@
],
"additionalProperties": false
},
"edit": {
"type": "object",
"properties": {
"email": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"requestSuccess": {
"type": "string"
}
},
"required": [
"title",
"requestSuccess"
],
"additionalProperties": false
},
"shippingAddress": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"requestSuccess": {
"type": "string"
}
},
"required": [
"title",
"requestSuccess"
],
"additionalProperties": false
},
"billingAddress": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"requestSuccess": {
"type": "string"
}
},
"required": [
"title",
"requestSuccess"
],
"additionalProperties": false
}
},
"required": [
"email",
"shippingAddress",
"billingAddress"
],
"additionalProperties": false
},
"returns": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -5364,6 +5423,26 @@
"declined"
],
"additionalProperties": false
},
"update_order": {
"type": "object",
"properties": {
"shipping_address": {
"type": "string"
},
"billing_address": {
"type": "string"
},
"email": {
"type": "string"
}
},
"required": [
"shipping_address",
"billing_address",
"email"
],
"additionalProperties": false
}
},
"required": [
Expand All @@ -5377,7 +5456,8 @@
"claim",
"exchange",
"edit",
"transfer"
"transfer",
"update_order"
],
"additionalProperties": false
}
Expand Down Expand Up @@ -5426,6 +5506,7 @@
"transfer",
"payment",
"edits",
"edit",
"returns",
"claims",
"exchanges",
Expand Down Expand Up @@ -10849,6 +10930,12 @@
},
"removed": {
"type": "string"
},
"from": {
"type": "string"
},
"to": {
"type": "string"
}
},
"required": [
Expand All @@ -10857,7 +10944,9 @@
"available",
"inStock",
"added",
"removed"
"removed",
"from",
"to"
],
"additionalProperties": false
},
Expand Down Expand Up @@ -10951,6 +11040,9 @@
"subtitle": {
"type": "string"
},
"by": {
"type": "string"
},
"item": {
"type": "string"
},
Expand Down Expand Up @@ -11360,6 +11452,7 @@
"discountable",
"handle",
"subtitle",
"by",
"item",
"qty",
"limit",
Expand Down
Loading
Loading