Order page nudges (#3671)
* Capitalize first letter * Use small pills * Add default title * Shorten button label * Move action button to the right * Update messages * Harmonize styles * Align rows * Update src/orders/components/OrderTransaction/components/TransactionEvents/components/EventStatus.tsx Co-authored-by: Jonatan Witoszek <jonatanwitoszek@gmail.com> * Update src/orders/components/OrderTransaction/components/CardTitle/CardTitle.tsx Co-authored-by: Jonatan Witoszek <jonatanwitoszek@gmail.com> * Update src/orders/components/OrderTransaction/components/CardTitle/CardTitle.tsx Co-authored-by: Jonatan Witoszek <jonatanwitoszek@gmail.com> * Update src/orders/components/OrderTransaction/components/TransactionEvents/components/EventType.tsx Co-authored-by: Jonatan Witoszek <jonatanwitoszek@gmail.com> * Fix import * Extract messages * Fix spacing * Changeset --------- Co-authored-by: Jonatan Witoszek <jonatanwitoszek@gmail.com> Co-authored-by: Paweł Chyła <pawel.chyla@saleor.io> Co-authored-by: andrzejewsky <vox3r69@gmail.com>
This commit is contained in:
parent
391b429fce
commit
de098fd520
9 changed files with 64 additions and 66 deletions
5
.changeset/good-beers-wash.md
Normal file
5
.changeset/good-beers-wash.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"saleor-dashboard": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Order page adjustments
|
|
@ -5561,6 +5561,10 @@
|
||||||
"context": "click and collect",
|
"context": "click and collect",
|
||||||
"string": "Click&Collect"
|
"string": "Click&Collect"
|
||||||
},
|
},
|
||||||
|
"biDgQS": {
|
||||||
|
"context": "button, opens modal to create transaction in order",
|
||||||
|
"string": "Manual transaction"
|
||||||
|
},
|
||||||
"biVFKU": {
|
"biVFKU": {
|
||||||
"context": "subsection header",
|
"context": "subsection header",
|
||||||
"string": "Billing Address"
|
"string": "Billing Address"
|
||||||
|
@ -6286,10 +6290,6 @@
|
||||||
"context": "docs link label",
|
"context": "docs link label",
|
||||||
"string": "Learn more..."
|
"string": "Learn more..."
|
||||||
},
|
},
|
||||||
"hnaOnB": {
|
|
||||||
"context": "button, opens modal to create transaction in order",
|
|
||||||
"string": "Capture manual transaction"
|
|
||||||
},
|
|
||||||
"ho75Lr": {
|
"ho75Lr": {
|
||||||
"context": "status label deactivated",
|
"context": "status label deactivated",
|
||||||
"string": "Deactivated"
|
"string": "Deactivated"
|
||||||
|
|
|
@ -2,8 +2,8 @@ import { defineMessages } from "react-intl";
|
||||||
|
|
||||||
export const addTransactionMessages = defineMessages({
|
export const addTransactionMessages = defineMessages({
|
||||||
captureTransaction: {
|
captureTransaction: {
|
||||||
defaultMessage: "Capture manual transaction",
|
defaultMessage: "Manual transaction",
|
||||||
id: "hnaOnB",
|
id: "biDgQS",
|
||||||
description: "button, opens modal to create transaction in order",
|
description: "button, opens modal to create transaction in order",
|
||||||
},
|
},
|
||||||
markAsPaid: {
|
markAsPaid: {
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {
|
||||||
TransactionActionEnum,
|
TransactionActionEnum,
|
||||||
TransactionItemFragment,
|
TransactionItemFragment,
|
||||||
} from "@dashboard/graphql";
|
} from "@dashboard/graphql";
|
||||||
|
import { capitalize } from "@dashboard/misc";
|
||||||
import { FakeTransaction } from "@dashboard/orders/types";
|
import { FakeTransaction } from "@dashboard/orders/types";
|
||||||
import { IconButton } from "@material-ui/core";
|
import { IconButton } from "@material-ui/core";
|
||||||
import { Button, LinkIcon } from "@saleor/macaw-ui";
|
import { Button, LinkIcon } from "@saleor/macaw-ui";
|
||||||
|
@ -44,9 +45,10 @@ export const CardTitle: React.FC<CardTitleProps> = ({
|
||||||
chargePendingAmount,
|
chargePendingAmount,
|
||||||
canceledAmount,
|
canceledAmount,
|
||||||
chargedAmount,
|
chargedAmount,
|
||||||
authorizedAmount,
|
authorizedAmount
|
||||||
} = transaction;
|
} = transaction;
|
||||||
|
|
||||||
|
const title = capitalize(transaction.name || "Transaction")
|
||||||
return (
|
return (
|
||||||
<DefaultCardTitle
|
<DefaultCardTitle
|
||||||
className={className}
|
className={className}
|
||||||
|
@ -61,22 +63,10 @@ export const CardTitle: React.FC<CardTitleProps> = ({
|
||||||
<LinkIcon />
|
<LinkIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
)}
|
)}
|
||||||
{transaction.name}
|
{title}
|
||||||
</TransactionLink>
|
</TransactionLink>
|
||||||
|
|
||||||
<div className={classes.dataDisplay}>
|
<div className={classes.dataDisplay}>
|
||||||
{showActions &&
|
|
||||||
transaction.actions
|
|
||||||
.filter(action => action !== TransactionActionEnum.REFUND)
|
|
||||||
.map(action => (
|
|
||||||
<Button
|
|
||||||
variant="tertiary"
|
|
||||||
onClick={() => onTransactionAction(transaction.id, action)}
|
|
||||||
>
|
|
||||||
<FormattedMessage {...mapActionToMessage[action]} />
|
|
||||||
</Button>
|
|
||||||
))}
|
|
||||||
|
|
||||||
{cancelPendingAmount.amount > 0 && (
|
{cancelPendingAmount.amount > 0 && (
|
||||||
<MoneyDisplay
|
<MoneyDisplay
|
||||||
label={intl.formatMessage(messages.cancelPending)}
|
label={intl.formatMessage(messages.cancelPending)}
|
||||||
|
@ -132,6 +122,22 @@ export const CardTitle: React.FC<CardTitleProps> = ({
|
||||||
money={authorizedAmount}
|
money={authorizedAmount}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{showActions &&
|
||||||
|
transaction.actions
|
||||||
|
.filter(action => action !== TransactionActionEnum.REFUND)
|
||||||
|
.map(action => (
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
variant="tertiary"
|
||||||
|
onClick={() =>
|
||||||
|
onTransactionAction(transaction.id, action)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FormattedMessage {...mapActionToMessage[action]} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { formatMoneyAmount } from "@dashboard/components/Money";
|
import { formatMoneyAmount } from "@dashboard/components/Money";
|
||||||
import useLocale from "@dashboard/hooks/useLocale";
|
import useLocale from "@dashboard/hooks/useLocale";
|
||||||
import { IMoney } from "@dashboard/utils/intl";
|
import { IMoney } from "@dashboard/utils/intl";
|
||||||
import { Typography } from "@material-ui/core";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
import { useMoneyDisplayStyles } from "./styles";
|
import { useMoneyDisplayStyles } from "./styles";
|
||||||
|
@ -18,16 +17,12 @@ export const MoneyDisplay = ({ label, money }: MoneyDisplayProps) => {
|
||||||
const amount = formatMoneyAmount(money, locale);
|
const amount = formatMoneyAmount(money, locale);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dl className={classes.wrapper}>
|
<div className={classes.wrapper}>
|
||||||
<dt className={classes.label}>{label}</dt>
|
<div>{label}</div>
|
||||||
<Typography
|
<div>
|
||||||
component="dd"
|
<span>{money.currency} </span>
|
||||||
variant="body2"
|
<span>{amount}</span>
|
||||||
className={classes.moneyWrapper}
|
</div>
|
||||||
>
|
</div>
|
||||||
<span className={classes.currency}>{money.currency} </span>
|
|
||||||
<span className={classes.amount}>{amount}</span>
|
|
||||||
</Typography>
|
|
||||||
</dl>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { makeStyles } from "@saleor/macaw-ui";
|
import { makeStyles } from "@saleor/macaw-ui";
|
||||||
|
import { vars } from "@saleor/macaw-ui/next";
|
||||||
|
|
||||||
export const useStyles = makeStyles(
|
export const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
|
@ -12,15 +13,11 @@ export const useStyles = makeStyles(
|
||||||
display: "flex",
|
display: "flex",
|
||||||
gap: theme.spacing(1),
|
gap: theme.spacing(1),
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
fontWeight: 600,
|
|
||||||
},
|
},
|
||||||
dataDisplay: {
|
dataDisplay: {
|
||||||
display: "flex",
|
display: "flex",
|
||||||
gap: theme.spacing(2),
|
gap: vars.spacing[7],
|
||||||
|
alignItems: "center",
|
||||||
"& > dl": {
|
|
||||||
minWidth: "73px", // aligns amounts with < 10 to each other
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
{ name: "OrderTransactionCardTitle" },
|
{ name: "OrderTransactionCardTitle" },
|
||||||
|
@ -29,25 +26,10 @@ export const useStyles = makeStyles(
|
||||||
export const useMoneyDisplayStyles = makeStyles(
|
export const useMoneyDisplayStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
wrapper: {
|
wrapper: {
|
||||||
|
fontSize: vars.fontSize.captionSmall,
|
||||||
|
lineHeight: vars.lineHeight.captionSmall,
|
||||||
color: theme.palette.saleor.main[2],
|
color: theme.palette.saleor.main[2],
|
||||||
margin: 0,
|
margin: 0,
|
||||||
textAlign: "left",
|
|
||||||
},
|
|
||||||
label: {
|
|
||||||
fontWeight: 600,
|
|
||||||
lineHeight: "12px",
|
|
||||||
fontSize: theme.spacing(1.25),
|
|
||||||
textTransform: "uppercase",
|
|
||||||
},
|
|
||||||
moneyWrapper: {
|
|
||||||
margin: 0,
|
|
||||||
fontSize: 14,
|
|
||||||
},
|
|
||||||
currency: {
|
|
||||||
fontWeight: 400,
|
|
||||||
},
|
|
||||||
amount: {
|
|
||||||
fontWeight: 600,
|
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { renderCollection } from "@dashboard/misc";
|
||||||
import { TransactionFakeEvent } from "@dashboard/orders/types";
|
import { TransactionFakeEvent } from "@dashboard/orders/types";
|
||||||
import { TableCell, TableRow } from "@material-ui/core";
|
import { TableCell, TableRow } from "@material-ui/core";
|
||||||
import { makeStyles, ResponsiveTable } from "@saleor/macaw-ui";
|
import { makeStyles, ResponsiveTable } from "@saleor/macaw-ui";
|
||||||
|
import { vars } from "@saleor/macaw-ui/next";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
|
||||||
|
@ -18,12 +19,10 @@ const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
table: {
|
table: {
|
||||||
"&& td": {
|
"&& td": {
|
||||||
// Gap = 24px
|
paddingLeft: vars.spacing[4],
|
||||||
paddingLeft: "12px",
|
paddingRight: vars.spacing[4],
|
||||||
paddingRight: "12px",
|
|
||||||
"&:first-child": {
|
"&:first-child": {
|
||||||
// Override for Material first td
|
paddingLeft: vars.spacing[9],
|
||||||
paddingRight: "12px",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -17,6 +17,7 @@ export const EventStatus: React.FC<EventStatusProps> = ({ status }) => {
|
||||||
return (
|
return (
|
||||||
<Pill
|
<Pill
|
||||||
color="warning"
|
color="warning"
|
||||||
|
size="small"
|
||||||
label={intl.formatMessage(statusMessages.pending)}
|
label={intl.formatMessage(statusMessages.pending)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -24,6 +25,7 @@ export const EventStatus: React.FC<EventStatusProps> = ({ status }) => {
|
||||||
return (
|
return (
|
||||||
<Pill
|
<Pill
|
||||||
color="success"
|
color="success"
|
||||||
|
size={"small"}
|
||||||
label={intl.formatMessage(statusMessages.success)}
|
label={intl.formatMessage(statusMessages.success)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
@ -31,16 +33,25 @@ export const EventStatus: React.FC<EventStatusProps> = ({ status }) => {
|
||||||
return (
|
return (
|
||||||
<Pill
|
<Pill
|
||||||
color="error"
|
color="error"
|
||||||
|
size={"small"}
|
||||||
label={intl.formatMessage(statusMessages.failure)}
|
label={intl.formatMessage(statusMessages.failure)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case "REQUEST":
|
case "REQUEST":
|
||||||
return (
|
return (
|
||||||
<Pill color="info" label={intl.formatMessage(statusMessages.request)} />
|
<Pill
|
||||||
|
color="info"
|
||||||
|
size={"small"}
|
||||||
|
label={intl.formatMessage(statusMessages.request)}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
case "INFO":
|
case "INFO":
|
||||||
return (
|
return (
|
||||||
<Pill color="generic" label={intl.formatMessage(statusMessages.info)} />
|
<Pill
|
||||||
|
color="generic"
|
||||||
|
size={"small"}
|
||||||
|
label={intl.formatMessage(statusMessages.info)}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
default:
|
default:
|
||||||
const _exhaustiveCheck: never = status;
|
const _exhaustiveCheck: never = status;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// @ts-strict-ignore
|
// @ts-strict-ignore
|
||||||
|
import { capitalize } from "@dashboard/misc";
|
||||||
import { transactionEventTypeMap } from "@dashboard/orders/messages";
|
import { transactionEventTypeMap } from "@dashboard/orders/messages";
|
||||||
import { TransactionEventType } from "@dashboard/orders/types";
|
import { TransactionEventType } from "@dashboard/orders/types";
|
||||||
import { makeStyles } from "@saleor/macaw-ui";
|
import { makeStyles } from "@saleor/macaw-ui";
|
||||||
|
@ -27,10 +28,9 @@ export const EventType = ({ type, message }: EventTypeProps) => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const mapEventToMessage = transactionEventTypeMap[type];
|
const mapEventToMessage = transactionEventTypeMap[type];
|
||||||
|
|
||||||
const displayType = mapEventToMessage
|
const displayType = capitalize(
|
||||||
? intl.formatMessage(mapEventToMessage)
|
mapEventToMessage ? intl.formatMessage(mapEventToMessage) : message || type,
|
||||||
: message || type;
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box display="flex" alignItems="center">
|
<Box display="flex" alignItems="center">
|
||||||
{displayType}
|
{displayType}
|
||||||
|
|
Loading…
Reference in a new issue