Skip to content

Commit

Permalink
Merge branch 'develop' into feat/bulk-editor-improvements-part-two
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperkristensen authored Aug 12, 2024
2 parents cd5f13c + 24985cf commit 51a4615
Show file tree
Hide file tree
Showing 70 changed files with 933 additions and 462 deletions.
1 change: 1 addition & 0 deletions .github/teams.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
- "@sradevski"
- "@edast"
- "@thetutlage"
- "@christiananese"
129 changes: 116 additions & 13 deletions integration-tests/http/__tests__/claims/claims.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ medusaIntegrationTestRunner({
let baseClaim
let order, order2
let returnShippingOption
let outboundShippingOption
let shippingProfile
let fulfillmentSet
let returnReason
Expand Down Expand Up @@ -348,6 +349,37 @@ medusaIntegrationTestRunner({
],
}

const outboundShippingOptionPayload = {
name: "Oubound shipping",
service_zone_id: fulfillmentSet.service_zones[0].id,
shipping_profile_id: shippingProfile.id,
provider_id: shippingProviderId,
price_type: "flat",
type: {
label: "Test type",
description: "Test description",
code: "test-code",
},
prices: [
{
currency_code: "usd",
amount: 1000,
},
],
rules: [
{
operator: RuleOperator.EQ,
attribute: "is_return",
value: "false",
},
{
operator: RuleOperator.EQ,
attribute: "enabled_in_store",
value: "true",
},
],
}

returnShippingOption = (
await api.post(
"/admin/shipping-options",
Expand All @@ -356,6 +388,14 @@ medusaIntegrationTestRunner({
)
).data.shipping_option

outboundShippingOption = (
await api.post(
"/admin/shipping-options",
outboundShippingOptionPayload,
adminHeaders
)
).data.shipping_option

item = order.items[0]

await api.post(
Expand Down Expand Up @@ -411,30 +451,69 @@ medusaIntegrationTestRunner({
const claimId2 = r2.data.claim.id
const item2 = order2.items[0]

await api.post(
const {
data: {
order_preview: {
items: [previewItem],
},
},
} = await api.post(
`/admin/claims/${claimId2}/inbound/items`,
{ items: [{ id: item2.id, quantity: 1 }] },
adminHeaders
)

// Delete & recreate again to ensure it works for both delete and create
await api.delete(
`/admin/claims/${claimId2}/inbound/items/${previewItem.actions[0].id}`,
adminHeaders
)

const {
data: { return: returnData },
} = await api.post(
`/admin/claims/${claimId2}/inbound/items`,
{ items: [{ id: item2.id, quantity: 1 }] },
adminHeaders
)

await api.post(
`/admin/returns/${returnData.id}`,
{
items: [
{
id: item2.id,
quantity: 1,
},
],
location_id: location.id,
no_notification: true,
},
adminHeaders
)

const {
data: {
order_preview: { shipping_methods: inboundShippingMethods },
},
} = await api.post(
`/admin/claims/${claimId2}/inbound/shipping-method`,
{ shipping_option_id: returnShippingOption.id },
adminHeaders
)
const inboundShippingMethod = inboundShippingMethods.find(
(m) => m.shipping_option_id == returnShippingOption.id
)

// Delete & recreate again to ensure it works for both delete and create
await api.delete(
`/admin/claims/${claimId2}/inbound/shipping-method/${inboundShippingMethod.actions[0].id}`,
adminHeaders
)

await api.post(
`/admin/claims/${claimId2}/inbound/shipping-method`,
{
shipping_option_id: returnShippingOption.id,
},
{ shipping_option_id: returnShippingOption.id },
adminHeaders
)

await api.post(`/admin/claims/${claimId2}/request`, {}, adminHeaders)

const claimId = baseClaim.id

const item = order.items[0]

let result = await api.post(
Expand All @@ -453,9 +532,33 @@ medusaIntegrationTestRunner({

await api.post(
`/admin/claims/${claimId}/inbound/shipping-method`,
{
shipping_option_id: returnShippingOption.id,
{ shipping_option_id: returnShippingOption.id },
adminHeaders
)

const {
data: {
order_preview: { shipping_methods: outboundShippingMethods },
},
} = await api.post(
`/admin/claims/${claimId}/outbound/shipping-method`,
{ shipping_option_id: outboundShippingOption.id },
adminHeaders
)

const outboundShippingMethod = outboundShippingMethods.find(
(m) => m.shipping_option_id == outboundShippingOption.id
)

// Delete & recreate again to ensure it works for both delete and create
await api.delete(
`/admin/claims/${claimId}/outbound/shipping-method/${outboundShippingMethod.actions[0].id}`,
adminHeaders
)

await api.post(
`/admin/claims/${claimId}/outbound/shipping-method`,
{ shipping_option_id: outboundShippingOption.id },
adminHeaders
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export interface DataTableRootProps<TData> {
* Whether the table is empty due to no results from the active query
*/
noResults?: boolean
/**
* Whether to display the tables header
*/
noHeader?: boolean
/**
* The layout of the table
*/
Expand Down Expand Up @@ -80,6 +84,7 @@ export const DataTableRoot = <TData,>({
commands,
count = 0,
noResults = false,
noHeader = false,
layout = "fit",
}: DataTableRootProps<TData>) => {
const { t } = useTranslation()
Expand Down Expand Up @@ -133,64 +138,66 @@ export const DataTableRoot = <TData,>({
>
{!noResults ? (
<Table className="relative w-full">
<Table.Header className="border-t-0">
{table.getHeaderGroups().map((headerGroup) => {
return (
<Table.Row
key={headerGroup.id}
className={clx({
"relative border-b-0 [&_th:last-of-type]:w-[1%] [&_th:last-of-type]:whitespace-nowrap":
hasActions,
"[&_th:first-of-type]:w-[1%] [&_th:first-of-type]:whitespace-nowrap":
hasSelect,
})}
>
{headerGroup.headers.map((header, index) => {
const isActionHeader = header.id === "actions"
const isSelectHeader = header.id === "select"
const isSpecialHeader = isActionHeader || isSelectHeader
{!noHeader && (
<Table.Header className="border-t-0">
{table.getHeaderGroups().map((headerGroup) => {
return (
<Table.Row
key={headerGroup.id}
className={clx({
"relative border-b-0 [&_th:last-of-type]:w-[1%] [&_th:last-of-type]:whitespace-nowrap":
hasActions,
"[&_th:first-of-type]:w-[1%] [&_th:first-of-type]:whitespace-nowrap":
hasSelect,
})}
>
{headerGroup.headers.map((header, index) => {
const isActionHeader = header.id === "actions"
const isSelectHeader = header.id === "select"
const isSpecialHeader = isActionHeader || isSelectHeader

const firstHeader = headerGroup.headers.findIndex(
(h) => h.id !== "select"
)
const isFirstHeader =
firstHeader !== -1
? header.id === headerGroup.headers[firstHeader].id
: index === 0
const firstHeader = headerGroup.headers.findIndex(
(h) => h.id !== "select"
)
const isFirstHeader =
firstHeader !== -1
? header.id === headerGroup.headers[firstHeader].id
: index === 0

const isStickyHeader = isSelectHeader || isFirstHeader
const isStickyHeader = isSelectHeader || isFirstHeader

return (
<Table.HeaderCell
data-table-header-id={header.id}
key={header.id}
style={{
width: !isSpecialHeader
? `${colWidth}%`
: undefined,
}}
className={clx({
"bg-ui-bg-base sticky left-0 after:absolute after:inset-y-0 after:right-0 after:h-full after:w-px after:bg-transparent after:content-['']":
isStickyHeader,
"left-[68px]":
isStickyHeader && hasSelect && !isSelectHeader,
"after:bg-ui-border-base":
showStickyBorder &&
isStickyHeader &&
!isSpecialHeader,
})}
>
{flexRender(
header.column.columnDef.header,
header.getContext()
)}
</Table.HeaderCell>
)
})}
</Table.Row>
)
})}
</Table.Header>
return (
<Table.HeaderCell
data-table-header-id={header.id}
key={header.id}
style={{
width: !isSpecialHeader
? `${colWidth}%`
: undefined,
}}
className={clx({
"bg-ui-bg-base sticky left-0 after:absolute after:inset-y-0 after:right-0 after:h-full after:w-px after:bg-transparent after:content-['']":
isStickyHeader,
"left-[68px]":
isStickyHeader && hasSelect && !isSelectHeader,
"after:bg-ui-border-base":
showStickyBorder &&
isStickyHeader &&
!isSpecialHeader,
})}
>
{flexRender(
header.column.columnDef.header,
header.getContext()
)}
</Table.HeaderCell>
)
})}
</Table.Row>
)
})}
</Table.Header>
)}
<Table.Body className="border-b-0">
{table.getRowModel().rows.map((row) => {
const to = navigateTo ? navigateTo(row) : undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const DataTable = <TData,>({
queryObject = {},
pageSize,
isLoading = false,
noHeader = false,
layout = "fit",
noRecords: noRecordsProps = {},
}: DataTableProps<TData>) => {
Expand Down Expand Up @@ -84,6 +85,7 @@ export const DataTable = <TData,>({
navigateTo={navigateTo}
commands={commands}
noResults={noResults}
noHeader={noHeader}
layout={layout}
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion packages/admin-next/dashboard/src/hooks/api/claims.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,9 @@ export const useDeleteClaimOutboundShipping = (
})
}

export const useRequestClaim = (
export const useClaimConfirmRequest = (
id: string,
orderId: string,
options?: UseMutationOptions<
HttpTypes.AdminClaimResponse,
Error,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
import { HttpTypes } from "@medusajs/types"
import { Badge } from "@medusajs/ui"
import { createColumnHelper } from "@tanstack/react-table"
import { useMemo } from "react"
import { useTranslation } from "react-i18next"
import { TextCell } from "../../../components/table/table-cells/common/text-cell"

const columnHelper = createColumnHelper<HttpTypes.AdminReturnReason>()

export const useReturnReasonTableColumns = () => {
const { t } = useTranslation()

return useMemo(
() => [
columnHelper.accessor("value", {
header: () => t("fields.value"),
cell: ({ getValue }) => <TextCell text={getValue()} />,
cell: ({ getValue }) => <Badge size="2xsmall">{getValue()}</Badge>,
}),
columnHelper.accessor("label", {
header: () => t("fields.createdAt"),
cell: ({ getValue }) => <TextCell text={getValue()} />,
cell: ({ row }) => {
const { label, description } = row.original
return (
<div className="flex h-full w-full flex-col justify-center py-4">
<span className="truncate font-medium">{label}</span>
<span className="truncate">
{description ? description : "-"}
</span>
</div>
)
},
}),
],
[t]
[]
)
}
Loading

0 comments on commit 51a4615

Please sign in to comment.