('');
const submitMail: ContactFormProps['sendMail'] = async (data, reset) => {
const { email, message, name, subject } = data;
const messageHTML = message.replace(/\r?\n/g, '
');
const body = `Message received from ${name} <${email}> on ${website.url}.
${messageHTML}`;
const replyTo = `${name} <${email}>`;
const mailData = {
body,
clientMutationId: 'contact',
replyTo,
subject,
};
const { message: mutationMessage, sent } = await sendMail(mailData);
if (sent) {
setStatus('success');
setStatusMessage(
intl.formatMessage({
defaultMessage:
'Thanks. Your message was successfully sent. I will answer it as soon as possible.',
description: 'Contact: success message',
id: '3Pipok',
})
);
reset();
} else {
const errorPrefix = intl.formatMessage({
defaultMessage: 'An error occurred:',
description: 'Contact: error message',
id: 'TpyFZ6',
});
const error = `${errorPrefix} ${mutationMessage}`;
setStatus('error');
setStatusMessage(error);
}
};
return (
<>
{`${seo.title} - ${website.name}`}
}
/>
>
);
};
ContactPage.getLayout = (page) =>
getLayout(page, { useGrid: true, withExtraPadding: true });
export const getStaticProps: GetStaticProps = async ({ locale }) => {
const translation = await loadTranslation(locale);
return {
props: {
translation,
},
};
};
export default ContactPage;
ref='#n43'>43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import Checkbox, { type CheckboxProps } from '@components/atoms/forms/checkbox';
import Label from '@components/atoms/forms/label';
import Cog from '@components/atoms/icons/cog';
import { FC } from 'react';
import { useIntl } from 'react-intl';
import SettingsModal, {
type SettingsModalProps,
} from '../modals/settings-modal';
import settingsStyles from './settings.module.scss';
import sharedStyles from './toolbar-items.module.scss';
export type SettingsProps = {
/**
* Set additional classnames to the modal wrapper.
*/
className?: string;
/**
* The button state.
*/
isActive: CheckboxProps['value'];
/**
* A callback function to handle button state.
*/
setIsActive: CheckboxProps['setValue'];
/**
* Set additional classnames to the tooltip wrapper.
*/
tooltipClassName?: SettingsModalProps['tooltipClassName'];
};
const Settings: FC<SettingsProps> = ({
className = '',
isActive,
setIsActive,
tooltipClassName = '',
}) => {
const intl = useIntl();
const label = isActive
? intl.formatMessage({
defaultMessage: 'Close settings',
id: '+viX9b',
description: 'Settings: Close label',
})
: intl.formatMessage({
defaultMessage: 'Open settings',
id: 'QCW3cy',
description: 'Settings: Open label',
});
return (
<div className={`${sharedStyles.item} ${settingsStyles.item}`}>
<Checkbox
id="settings-button"
name="settings-button"
value={isActive}
setValue={setIsActive}
className={`${sharedStyles.checkbox} ${settingsStyles.checkbox}`}
/>
<Label
htmlFor="settings-button"
aria-label={label}
className={`${sharedStyles.label} ${settingsStyles.label}`}
>
<Cog />
</Label>
<SettingsModal
className={`${sharedStyles.modal} ${settingsStyles.modal} ${className}`}
tooltipClassName={tooltipClassName}
/>
</div>
);
};
export default Settings;
|