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

Show is gift boolean at order datagrid #4661

Merged
merged 8 commits into from
Feb 12, 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/smart-dingos-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": minor
---

Introduce is gift column in order and draft order details datagrid
4 changes: 4 additions & 0 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3093,6 +3093,10 @@
"context": "column label",
"string": "Warehouse"
},
"J3W5LI": {
"context": "order line is gift",
"string": "Is gift"
},
"J3uE0t": {
"context": "section header",
"string": "Attribute Values"
Expand Down
6 changes: 5 additions & 1 deletion src/components/Datagrid/customCells/cells.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,13 @@ export function tagsCell(
};
}

export function booleanCell(value: boolean): GridCell {
export function booleanCell(
value: boolean,
options: Partial<GridCell> = {},
): GridCell {
return {
...common,
...options,
allowOverlay: false,
kind: GridCellKind.Boolean,
data: value,
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export const defaultListSettings: AppListViewSettings = {
"quantity",
"price",
"total",
"isGift",
"metadata",
],
},
Expand All @@ -182,6 +183,7 @@ export const defaultListSettings: AppListViewSettings = {
"quantity",
"price",
"total",
"isGift",
"metadata",
],
},
Expand Down
1 change: 1 addition & 0 deletions src/fragments/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const fragmentOrderLine = gql`
}
productName
productSku
isGift
quantity
quantityFulfilled
quantityToFulfill
Expand Down
1 change: 1 addition & 0 deletions src/graphql/hooks.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,7 @@ export const OrderLineFragmentDoc = gql`
}
productName
productSku
isGift
quantity
quantityFulfilled
quantityToFulfill
Expand Down
76 changes: 38 additions & 38 deletions src/graphql/types.generated.ts

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/orders/components/OrderDetailsDatagrid/datagrid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-strict-ignore
import {
booleanCell,
buttonCell,
loadingCell,
moneyCell,
Expand Down Expand Up @@ -49,6 +50,11 @@ export const orderDetailsStaticColumnsAdapter = (
title: intl.formatMessage(columnsMessages.total),
width: 150,
},
{
id: "isGift",
title: intl.formatMessage(columnsMessages.isGift),
width: 150,
},
{
id: "metadata",
title: intl.formatMessage(commonMessages.metadata),
Expand Down Expand Up @@ -106,6 +112,11 @@ export const createGetCellContent =
rowData.totalPrice.gross.currency,
readonyOptions,
);
case "isGift":
return booleanCell(rowData?.isGift, {
readonly: true,
allowOverlay: false,
});
case "metadata":
return buttonCell(
intl.formatMessage(commonMessages.viewMetadata),
Expand Down
5 changes: 5 additions & 0 deletions src/orders/components/OrderDetailsDatagrid/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export const columnsMessages = defineMessages({
defaultMessage: "Total",
description: "order line total price",
},
isGift: {
id: "J3W5LI",
defaultMessage: "Is gift",
description: "order line is gift",
},
});

export const messages = defineMessages({
Expand Down
12 changes: 11 additions & 1 deletion src/orders/components/OrderDraftDetailsDatagrid/datagrid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @ts-strict-ignore
import {
booleanCell,
buttonCell,
moneyCell,
moneyDiscountedCell,
Expand Down Expand Up @@ -62,6 +63,11 @@ export const orderDraftDetailsStaticColumnsAdapter = (
title: intl.formatMessage(columnsMessages.total),
width: 150,
},
{
id: "isGift",
title: intl.formatMessage(columnsMessages.isGift),
width: 150,
},
{
id: "metadata",
title: intl.formatMessage(commonMessages.metadata),
Expand Down Expand Up @@ -165,7 +171,11 @@ export const useGetCellContent = ({
allowOverlay: false,
},
);

case "isGift":
return booleanCell(rowData?.isGift, {
allowOverlay: false,
readonly: true,
});
case "metadata":
return buttonCell(
intl.formatMessage(commonMessages.viewMetadata),
Expand Down
5 changes: 5 additions & 0 deletions src/orders/components/OrderDraftDetailsDatagrid/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export const columnsMessages = defineMessages({
defaultMessage: "Total",
description: "total price of ordered products",
},
isGift: {
id: "J3W5LI",
defaultMessage: "Is gift",
description: "order line is gift",
},
status: {
id: "tzMNF3",
defaultMessage: "Status",
Expand Down
6 changes: 6 additions & 0 deletions src/orders/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,7 @@ export const order = (
quantity: 2,
quantityFulfilled: 2,
quantityToFulfill: 0,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1353,6 +1354,7 @@ export const order = (
quantity: 2,
quantityFulfilled: 2,
quantityToFulfill: 0,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1488,6 +1490,7 @@ export const order = (
quantity: 3,
quantityFulfilled: 0,
quantityToFulfill: 3,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1600,6 +1603,7 @@ export const order = (
quantity: 2,
quantityFulfilled: 2,
quantityToFulfill: 0,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1879,6 +1883,7 @@ export const draftOrder = (
quantity: 2,
quantityFulfilled: 0,
quantityToFulfill: 2,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1991,6 +1996,7 @@ export const draftOrder = (
quantity: 2,
quantityFulfilled: 0,
quantityToFulfill: 2,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down
20 changes: 20 additions & 0 deletions src/orders/utils/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ describe("Get the total value of all replaced products", () => {
{
id: "1",
isShippingRequired: false,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -638,6 +639,8 @@ describe("Get the total value of all replaced products", () => {
{
id: "2",
isShippingRequired: false,
isGift: false,

allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -750,6 +753,8 @@ describe("Get the total value of all replaced products", () => {
{
id: "3",
isShippingRequired: true,
isGift: false,

allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -869,6 +874,8 @@ describe("Get the total value of all replaced products", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ1",
isShippingRequired: false,
isGift: false,

allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -986,6 +993,7 @@ describe("Get the total value of all replaced products", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ1",
isShippingRequired: false,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1103,6 +1111,7 @@ describe("Get the total value of all replaced products", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ3",
isShippingRequired: true,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1220,6 +1229,7 @@ describe("Get the total value of all replaced products", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ1",
isShippingRequired: false,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1337,6 +1347,7 @@ describe("Get the total value of all replaced products", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ1",
isShippingRequired: false,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1588,6 +1599,7 @@ describe("Get the total value of all selected products", () => {
{
id: "1",
isShippingRequired: false,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1700,6 +1712,7 @@ describe("Get the total value of all selected products", () => {
{
id: "2",
isShippingRequired: false,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1812,6 +1825,7 @@ describe("Get the total value of all selected products", () => {
{
id: "3",
isShippingRequired: true,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -1931,6 +1945,7 @@ describe("Get the total value of all selected products", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ1",
isShippingRequired: false,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -2048,6 +2063,7 @@ describe("Get the total value of all selected products", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ1",
isShippingRequired: false,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -2165,6 +2181,7 @@ describe("Get the total value of all selected products", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ3",
isShippingRequired: true,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -2411,6 +2428,7 @@ describe("Merge repeated order lines of fulfillment lines", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ1",
isShippingRequired: false,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -2528,6 +2546,7 @@ describe("Merge repeated order lines of fulfillment lines", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ1",
isShippingRequired: false,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down Expand Up @@ -2645,6 +2664,7 @@ describe("Merge repeated order lines of fulfillment lines", () => {
orderLine: {
id: "T3JkZXJMaW5lOjQ3",
isShippingRequired: true,
isGift: false,
allocations: [
{
id: "allocation_test_id",
Expand Down
Loading