Skip to content

Conversation

@sylwia-werner
Copy link
Collaborator

@sylwia-werner sylwia-werner commented Oct 26, 2025

Fix pt-4

Link to ticket: MM2-1362

Note: to review and merge after part 1, 2 and 3 is merged

Suggested review approach - by commits

  • ~100 of unused order module files removed
  • Order type mismatches removed
  • Refactor OrderTimeline component into separate files for readability

@sylwia-werner sylwia-werner requested a review from mikolvj October 26, 2025 08:02
@vercel
Copy link

vercel bot commented Oct 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
mercurvendor-testing Ready Ready Preview Comment Nov 4, 2025 2:02pm
vendor-panel Ready Ready Preview Comment Nov 4, 2025 2:02pm
vendor-plugin-test Ready Ready Preview Comment Nov 4, 2025 2:02pm
vendor-sandbox Ready Ready Preview Comment Nov 4, 2025 2:02pm


export type DataTableOrderByKey<TData> = {
key: keyof TData
key: keyof TData | (string & Record<never, never>)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO those nevers should be removed
I tried something more strict but looks horrible
key: keyof TData | keyof TData[keyof TData][keyof TData[keyof TData]]

or

type NestedKeys = keyof T | keyof T[keyof T][keyof T[keyof T]]

export type DataTableOrderByKey = {
key: keyof TData | NestedKeys
label: string
}

another proposed by (AI)an

type NestedKeys = {
[K in keyof T]: T[K] extends object
? ${string & K}.${string & keyof T[K]}
: never
}[keyof T]

export type DataTableOrderByKey = {
key: keyof TData | NestedKeys
label: string
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My version kept autocomplete, will take a look at yours 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it as it was: key: keyof TData

I flattened the data before passing it to the table, problem solved

Comment on lines 147 to 158
isLoading={isLoading}
count={customer_groups?.length ?? 0}
prefix={PREFIX}
navigateTo={(row) => `/customer-groups/${row.id}`}
navigateTo={(row) => `/customer-groups/${row.original.customer_group_id}`}
filters={filters}
search
pagination
orderBy={[
{ key: "name", label: t("fields.name") },
{
key: "created_at",
label: t("fields.createdAt"),
},
{
key: "updated_at",
label: t("fields.updatedAt"),
},
{ key: "customer_group.name", label: t("fields.name") },
{ key: "customer_group.created_at", label: t("fields.createdAt") },
{ key: "customer_group.updated_at", label: t("fields.updatedAt") },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe those keys could be changed to avoid those nevers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved, look at first comment

Comment on lines 160 to 162
{ key: "customer_group.name", label: t("fields.name") },
{ key: "customer_group.created_at", label: t("fields.createdAt") },
{ key: "customer_group.updated_at", label: t("fields.updatedAt") },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe those keys could be changed to avoid those nevers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved, look at first comment

Comment on lines 42 to 45
item.variant?.inventory &&
item.variant.inventory.length > 0 &&
item.quantity &&
item.detail &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about
item.variant?.manage_inventory && !!item.variant.inventory?.length && item?.quantity - item.detail?.fulfilled_quantity > 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

const onQuantityChange = (
inventoryItem: InventoryItemDTO,
lineItem: OrderLineItemDTO,
inventoryItem: { id: string; location_levels?: { location_id: string; available_quantity: number }[] },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about defining custom type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

onQuantityChange: (
inventoryItem: InventoryItemDTO,
lineItem: OrderLineItemDTO,
inventoryItem: { id: string; location_levels?: { location_id: string; available_quantity: number }[] },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls define this in custom types

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

Comment on lines 46 to 49
items: fulfillment?.items?.map((i) => ({
id: i.line_item_id,
id: i.line_item_id ?? "",
quantity: i.quantity,
})),
})).filter((item) => item.id !== "") ?? [],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about
items: fulfillment?.items ?.map((i) => ({ id: i?.line_item_id, quantity: i.quantity, })) .filter((item) => !!item.id) ?? [],

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

{fulfillment.labels.map((tlink) => {
const hasUrl =
tlink.url && tlink.url.length > 0 && tlink.url !== "#"
tlink.tracking_url && tlink.tracking_url.length > 0 && tlink.tracking_url !== "#"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about just
!!tlink.tracking_url?.length

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected

order,
}: {
order: AdminOrder & { region?: AdminRegion | null }
order: ExtendedAdminOrder & { region?: AdminRegion | null }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we extend definition of ExtendedAdminOrder?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extended


export interface ExtendedAdminOrderFulfillment
extends HttpTypes.AdminOrderFulfillment {
items?: Array<{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about
(AdminOrderLineItem & { line_item_id: string })[]

same to other large types which are very similar to default types from medusa

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

mikolvj
mikolvj previously approved these changes Nov 5, 2025
@sylwia-werner sylwia-werner changed the base branch from fix/mm2-1318/typescript-errors-pt-3 to test November 5, 2025 08:35
@sylwia-werner sylwia-werner dismissed mikolvj’s stale review November 5, 2025 08:35

The base branch was changed.

@kamilkieres09 kamilkieres09 merged commit 5411bb2 into test Nov 5, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants