2019-10-21 10:13:23 +00:00
|
|
|
import Card from "@material-ui/core/Card";
|
|
|
|
import CardContent from "@material-ui/core/CardContent";
|
|
|
|
import { Theme } from "@material-ui/core/styles";
|
|
|
|
import TextField from "@material-ui/core/TextField";
|
|
|
|
import Typography from "@material-ui/core/Typography";
|
|
|
|
import { makeStyles } from "@material-ui/styles";
|
|
|
|
import React from "react";
|
|
|
|
import { FormattedMessage, useIntl } from "react-intl";
|
|
|
|
|
|
|
|
import CardTitle from "@saleor/components/CardTitle";
|
|
|
|
import FormSpacer from "@saleor/components/FormSpacer";
|
|
|
|
import Hr from "@saleor/components/Hr";
|
|
|
|
import { FormErrors } from "@saleor/types";
|
|
|
|
|
2019-10-21 11:11:05 +00:00
|
|
|
export interface SiteSettingsMailingFormData {
|
|
|
|
defaultMailSenderName: string;
|
|
|
|
defaultMailSenderAddress: string;
|
2019-10-21 14:14:28 +00:00
|
|
|
customerSetPasswordUrl: string;
|
2019-10-21 11:11:05 +00:00
|
|
|
}
|
2019-10-21 10:13:23 +00:00
|
|
|
interface SiteSettingsMailingProps {
|
2019-10-21 11:11:05 +00:00
|
|
|
data: SiteSettingsMailingFormData;
|
|
|
|
errors: FormErrors<
|
2019-10-21 14:14:28 +00:00
|
|
|
| "defaultMailSenderAddress"
|
|
|
|
| "defaultMailSenderName"
|
|
|
|
| "customerSetPasswordUrl"
|
2019-10-21 11:11:05 +00:00
|
|
|
>;
|
2019-10-21 10:13:23 +00:00
|
|
|
disabled: boolean;
|
|
|
|
onChange: (event: React.ChangeEvent<any>) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const useStyles = makeStyles(
|
|
|
|
(theme: Theme) => ({
|
|
|
|
cardHelperText: {
|
|
|
|
position: "relative",
|
|
|
|
top: -theme.spacing.unit
|
|
|
|
},
|
|
|
|
cardHelperTextCaption: {
|
|
|
|
marginBottom: theme.spacing.unit * 2
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
name: "SiteSettingsMailing"
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
const SiteSettingsMailing: React.FC<SiteSettingsMailingProps> = props => {
|
|
|
|
const { data, disabled, errors, onChange } = props;
|
|
|
|
const classes = useStyles(props);
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Card>
|
|
|
|
<CardTitle
|
|
|
|
title={intl.formatMessage({
|
|
|
|
defaultMessage: "Mailing Configuration",
|
|
|
|
description: "section header"
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
<CardContent>
|
|
|
|
<Typography className={classes.cardHelperText}>
|
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Mailing Configuration"
|
|
|
|
description="helper text"
|
|
|
|
id="siteSettingsMailingHelperText"
|
|
|
|
/>
|
|
|
|
</Typography>
|
|
|
|
<Typography className={classes.cardHelperTextCaption} variant="body1">
|
|
|
|
<FormattedMessage defaultMessage="Configurate your email address from which all automatic emails will be sent to your customers." />
|
|
|
|
</Typography>
|
|
|
|
<TextField
|
|
|
|
disabled={disabled}
|
2019-10-21 11:11:05 +00:00
|
|
|
error={!!errors.defaultMailSenderAddress}
|
2019-10-21 10:13:23 +00:00
|
|
|
fullWidth
|
2019-10-21 11:11:05 +00:00
|
|
|
name="defaultMailSenderAddress"
|
2019-10-21 10:13:23 +00:00
|
|
|
label={intl.formatMessage({
|
|
|
|
defaultMessage: "Mailing email address"
|
|
|
|
})}
|
2019-10-21 11:11:05 +00:00
|
|
|
helperText={errors.defaultMailSenderAddress}
|
|
|
|
value={data.defaultMailSenderAddress}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
<FormSpacer />
|
|
|
|
<TextField
|
|
|
|
disabled={disabled}
|
|
|
|
error={!!errors.defaultMailSenderName}
|
|
|
|
fullWidth
|
2019-10-21 14:14:28 +00:00
|
|
|
name="defaultMailSenderName"
|
2019-10-21 11:11:05 +00:00
|
|
|
label={intl.formatMessage({
|
|
|
|
defaultMessage: "Mailing email sender"
|
|
|
|
})}
|
|
|
|
helperText={
|
|
|
|
errors.defaultMailSenderName ||
|
|
|
|
intl.formatMessage({
|
|
|
|
defaultMessage: 'This will be visible as "from" name',
|
|
|
|
description: "email sender"
|
|
|
|
})
|
|
|
|
}
|
2019-10-21 14:14:28 +00:00
|
|
|
value={data.defaultMailSenderName}
|
2019-10-21 10:13:23 +00:00
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
<FormSpacer />
|
|
|
|
<Hr />
|
|
|
|
<FormSpacer />
|
|
|
|
<TextField
|
|
|
|
disabled={disabled}
|
2019-10-21 14:14:28 +00:00
|
|
|
error={!!errors.customerSetPasswordUrl}
|
2019-10-21 10:13:23 +00:00
|
|
|
fullWidth
|
2019-10-21 14:14:28 +00:00
|
|
|
name="customerSetPasswordUrl"
|
2019-10-21 10:13:23 +00:00
|
|
|
label={intl.formatMessage({
|
2019-10-23 15:20:24 +00:00
|
|
|
defaultMessage: "Customer password reset URL"
|
|
|
|
})}
|
|
|
|
placeholder={intl.formatMessage({
|
2019-10-21 10:13:23 +00:00
|
|
|
defaultMessage: "URL address"
|
|
|
|
})}
|
|
|
|
helperText={
|
2019-10-21 14:14:28 +00:00
|
|
|
errors.customerSetPasswordUrl ||
|
2019-10-21 10:13:23 +00:00
|
|
|
intl.formatMessage({
|
|
|
|
defaultMessage:
|
|
|
|
"This URL will be used as a main URL for password resets. It will be sent via email."
|
|
|
|
})
|
|
|
|
}
|
2019-10-21 14:14:28 +00:00
|
|
|
value={data.customerSetPasswordUrl}
|
2019-10-21 10:13:23 +00:00
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
SiteSettingsMailing.displayName = "SiteSettingsMailing";
|
|
|
|
export default SiteSettingsMailing;
|