-
Notifications
You must be signed in to change notification settings - Fork 61
Fix/mm2 1280/typescript errors pt 2 #194
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
Changes from 11 commits
a1e05c3
a06405c
c5a20a1
1e7f33b
530860c
0af8c58
c8f84e7
9e8af22
f99de95
8657618
2c6703b
9c6ec4a
35addae
30c8dee
a758438
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,25 +25,27 @@ export const isSameAddress = ( | |
| export const getFormattedAddress = ({ | ||
| address, | ||
| }: { | ||
| address?: HttpTypes.AdminOrderAddress | null | ||
| address?: HttpTypes.AdminOrderAddress | HttpTypes.AdminStockLocationAddress | null | ||
| }) => { | ||
| if (!address) { | ||
| return [] | ||
| } | ||
|
|
||
| const { | ||
| first_name, | ||
| last_name, | ||
| company, | ||
| address_1, | ||
| address_2, | ||
| city, | ||
| postal_code, | ||
| province, | ||
| country, | ||
| country_code, | ||
| } = address | ||
|
|
||
| // Check if it's an AdminOrderAddress (has first_name/last_name) | ||
| const first_name = 'first_name' in address ? address.first_name : undefined | ||
| const last_name = 'last_name' in address ? address.last_name : undefined | ||
| const country = 'country' in address ? address.country : undefined | ||
|
|
||
|
||
| const name = [first_name, last_name].filter(Boolean).join(" ") | ||
|
|
||
| const formattedAddress: string[] = [] | ||
|
|
@@ -75,10 +77,10 @@ export const getFormattedAddress = ({ | |
| if (country) { | ||
| formattedAddress.push(country.display_name!) | ||
| } else if (country_code) { | ||
| const country = getCountryByIso2(country_code) | ||
| const countryData = getCountryByIso2(country_code) | ||
|
|
||
| if (country) { | ||
| formattedAddress.push(country.display_name) | ||
| if (countryData) { | ||
| formattedAddress.push(countryData.display_name) | ||
| } else { | ||
| formattedAddress.push(country_code.toUpperCase()) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| import { PencilSquare, Trash } from "@medusajs/icons" | ||
| import { HttpTypes } from "@medusajs/types" | ||
| import { | ||
| Container, | ||
| createDataTableColumnHelper, | ||
|
|
@@ -19,8 +18,8 @@ import { | |
| useDeleteCustomerGroupLazy, | ||
| } from "../../../../../hooks/api" | ||
| import { useDate } from "../../../../../hooks/use-date" | ||
| import { _DataTable } from "../../../../../components/table/data-table" | ||
| import { TextCell } from "../../../../../components/table/table-cells/common/text-cell" | ||
| import { CustomerGroupData } from "../../../../orders/common/customerGroupFiltering" | ||
|
|
||
| const PAGE_SIZE = 10 | ||
|
|
||
|
|
@@ -56,10 +55,10 @@ export const CustomerGroupListTable = () => { | |
| heading={t("customerGroups.domain")} | ||
| subHeading="Organize customers into groups. Groups can have different promotions and prices." | ||
| rowCount={count} | ||
| getRowId={(row) => row.id} | ||
| rowHref={(row) => { | ||
| return `/customer-groups/${row.original.customer_group_id}` | ||
| }} | ||
| getRowId={(row) => row.customer_group_id} | ||
| // For some reason the table requires accessing data on row.original in this specific case | ||
|
||
| rowHref={(row: any) => `/customer-groups/${row.original.customer_group_id}` | ||
| } | ||
| action={{ | ||
| label: t("actions.create"), | ||
| to: "/customer-groups/create", | ||
|
|
@@ -82,7 +81,7 @@ export const CustomerGroupListTable = () => { | |
| ) | ||
| } | ||
|
|
||
| const columnHelper = createDataTableColumnHelper<HttpTypes.AdminCustomerGroup>() | ||
| const columnHelper = createDataTableColumnHelper<CustomerGroupData>() | ||
|
|
||
| const useColumns = () => { | ||
| const { t } = useTranslation() | ||
|
|
@@ -130,7 +129,7 @@ const useColumns = () => { | |
|
|
||
| return useMemo(() => { | ||
| return [ | ||
| columnHelper.accessor("name", { | ||
| columnHelper.accessor("customer_group.name", { | ||
| header: t("fields.name"), | ||
| enableSorting: true, | ||
| sortAscLabel: t("filters.sorting.alphabeticallyAsc"), | ||
|
|
@@ -139,7 +138,7 @@ const useColumns = () => { | |
| return <TextCell text={row?.original?.customer_group?.name || "-"} /> | ||
| }, | ||
| }), | ||
| columnHelper.accessor("customers", { | ||
| columnHelper.accessor("customer_group.customers", { | ||
| header: t("customers.domain"), | ||
| cell: ({ row }) => { | ||
| return ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,10 +23,11 @@ export const useLocationListTableColumns = () => { | |
|
|
||
| return useMemo( | ||
| () => [ | ||
| columnHelper.accessor("stock_locations.0.name", { | ||
| columnHelper.display({ | ||
| id: "location", | ||
| header: t("fields.location"), | ||
| cell: ({ getValue }) => { | ||
| const locationName = getValue() | ||
| cell: ({ row }) => { | ||
| const locationName = row.original.stock_locations?.[0]?.name | ||
|
||
|
|
||
| if (!locationName) { | ||
| return <PlaceholderCell /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about:
const price_lists: ExtendedPriceList[] = (data?.price_lists || []) .filter((item) => item.price_list) .map((item) => ({ ...item.price_list, id: item.price_list.id, }))