node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,171 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var designSystem = require('@strapi/design-system');
var admin = require('@strapi/strapi/admin');
var PropTypes = require('prop-types');
var reactIntl = require('react-intl');
require('lodash/isEmpty');
var getTrad = require('../../../utils/getTrad.js');
var schema = require('../utils/schema.js');
const EmailForm = ({ template = {}, onToggle, open, onSubmit })=>{
const { formatMessage } = reactIntl.useIntl();
return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Root, {
open: open,
onOpenChange: onToggle,
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Content, {
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Header, {
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Breadcrumbs, {
label: `${formatMessage({
id: getTrad('PopUpForm.header.edit.email-templates'),
defaultMessage: 'Edit email template'
})}, ${template.display ? formatMessage({
id: getTrad(template.display),
defaultMessage: template.display
}) : ''}`,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Crumb, {
children: formatMessage({
id: getTrad('PopUpForm.header.edit.email-templates'),
defaultMessage: 'Edit email template'
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Crumb, {
isCurrent: true,
children: template.display ? formatMessage({
id: getTrad(template.display),
defaultMessage: template.display
}) : ''
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Title, {
children: `${formatMessage({
id: getTrad('PopUpForm.header.edit.email-templates'),
defaultMessage: 'Edit email template'
})}, ${template.display ? formatMessage({
id: getTrad(template.display),
defaultMessage: template.display
}) : ''}`
})
})
]
}),
/*#__PURE__*/ jsxRuntime.jsx(admin.Form, {
onSubmit: onSubmit,
initialValues: template,
validationSchema: schema,
children: ({ isSubmitting })=>{
return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Body, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Root, {
gap: 5,
children: [
{
label: formatMessage({
id: getTrad('PopUpForm.Email.options.from.name.label'),
defaultMessage: 'Shipper name'
}),
name: 'options.from.name',
size: 6,
type: 'string'
},
{
label: formatMessage({
id: getTrad('PopUpForm.Email.options.from.email.label'),
defaultMessage: 'Shipper email'
}),
name: 'options.from.email',
size: 6,
type: 'string'
},
{
label: formatMessage({
id: getTrad('PopUpForm.Email.options.response_email.label'),
defaultMessage: 'Response email'
}),
name: 'options.response_email',
size: 6,
type: 'string'
},
{
label: formatMessage({
id: getTrad('PopUpForm.Email.options.object.label'),
defaultMessage: 'Subject'
}),
name: 'options.object',
size: 6,
type: 'string'
},
{
label: formatMessage({
id: getTrad('PopUpForm.Email.options.message.label'),
defaultMessage: 'Message'
}),
name: 'options.message',
size: 12,
type: 'text'
}
].map(({ size, ...field })=>/*#__PURE__*/ jsxRuntime.jsx(designSystem.Grid.Item, {
col: size,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsxRuntime.jsx(admin.InputRenderer, {
...field
})
}, field.name))
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Modal.Footer, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Modal.Close, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
variant: "tertiary",
children: "Cancel"
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Button, {
loading: isSubmitting,
type: "submit",
children: "Finish"
})
]
})
]
});
}
})
]
})
});
};
EmailForm.defaultProps = {
template: {}
};
EmailForm.propTypes = {
template: PropTypes.shape({
display: PropTypes.string,
icon: PropTypes.string,
options: PropTypes.shape({
from: PropTypes.shape({
name: PropTypes.string,
email: PropTypes.string
}),
message: PropTypes.string,
object: PropTypes.string,
response_email: PropTypes.string
})
}),
open: PropTypes.bool.isRequired,
onSubmit: PropTypes.func.isRequired,
onToggle: PropTypes.func.isRequired
};
module.exports = EmailForm;
//# sourceMappingURL=EmailForm.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,169 @@
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import 'react';
import { Modal, Breadcrumbs, Crumb, VisuallyHidden, Grid, Button } from '@strapi/design-system';
import { Form, InputRenderer } from '@strapi/strapi/admin';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import 'lodash/isEmpty';
import getTrad from '../../../utils/getTrad.mjs';
import schema from '../utils/schema.mjs';
const EmailForm = ({ template = {}, onToggle, open, onSubmit })=>{
const { formatMessage } = useIntl();
return /*#__PURE__*/ jsx(Modal.Root, {
open: open,
onOpenChange: onToggle,
children: /*#__PURE__*/ jsxs(Modal.Content, {
children: [
/*#__PURE__*/ jsxs(Modal.Header, {
children: [
/*#__PURE__*/ jsxs(Breadcrumbs, {
label: `${formatMessage({
id: getTrad('PopUpForm.header.edit.email-templates'),
defaultMessage: 'Edit email template'
})}, ${template.display ? formatMessage({
id: getTrad(template.display),
defaultMessage: template.display
}) : ''}`,
children: [
/*#__PURE__*/ jsx(Crumb, {
children: formatMessage({
id: getTrad('PopUpForm.header.edit.email-templates'),
defaultMessage: 'Edit email template'
})
}),
/*#__PURE__*/ jsx(Crumb, {
isCurrent: true,
children: template.display ? formatMessage({
id: getTrad(template.display),
defaultMessage: template.display
}) : ''
})
]
}),
/*#__PURE__*/ jsx(VisuallyHidden, {
children: /*#__PURE__*/ jsx(Modal.Title, {
children: `${formatMessage({
id: getTrad('PopUpForm.header.edit.email-templates'),
defaultMessage: 'Edit email template'
})}, ${template.display ? formatMessage({
id: getTrad(template.display),
defaultMessage: template.display
}) : ''}`
})
})
]
}),
/*#__PURE__*/ jsx(Form, {
onSubmit: onSubmit,
initialValues: template,
validationSchema: schema,
children: ({ isSubmitting })=>{
return /*#__PURE__*/ jsxs(Fragment, {
children: [
/*#__PURE__*/ jsx(Modal.Body, {
children: /*#__PURE__*/ jsx(Grid.Root, {
gap: 5,
children: [
{
label: formatMessage({
id: getTrad('PopUpForm.Email.options.from.name.label'),
defaultMessage: 'Shipper name'
}),
name: 'options.from.name',
size: 6,
type: 'string'
},
{
label: formatMessage({
id: getTrad('PopUpForm.Email.options.from.email.label'),
defaultMessage: 'Shipper email'
}),
name: 'options.from.email',
size: 6,
type: 'string'
},
{
label: formatMessage({
id: getTrad('PopUpForm.Email.options.response_email.label'),
defaultMessage: 'Response email'
}),
name: 'options.response_email',
size: 6,
type: 'string'
},
{
label: formatMessage({
id: getTrad('PopUpForm.Email.options.object.label'),
defaultMessage: 'Subject'
}),
name: 'options.object',
size: 6,
type: 'string'
},
{
label: formatMessage({
id: getTrad('PopUpForm.Email.options.message.label'),
defaultMessage: 'Message'
}),
name: 'options.message',
size: 12,
type: 'text'
}
].map(({ size, ...field })=>/*#__PURE__*/ jsx(Grid.Item, {
col: size,
direction: "column",
alignItems: "stretch",
children: /*#__PURE__*/ jsx(InputRenderer, {
...field
})
}, field.name))
})
}),
/*#__PURE__*/ jsxs(Modal.Footer, {
children: [
/*#__PURE__*/ jsx(Modal.Close, {
children: /*#__PURE__*/ jsx(Button, {
variant: "tertiary",
children: "Cancel"
})
}),
/*#__PURE__*/ jsx(Button, {
loading: isSubmitting,
type: "submit",
children: "Finish"
})
]
})
]
});
}
})
]
})
});
};
EmailForm.defaultProps = {
template: {}
};
EmailForm.propTypes = {
template: PropTypes.shape({
display: PropTypes.string,
icon: PropTypes.string,
options: PropTypes.shape({
from: PropTypes.shape({
name: PropTypes.string,
email: PropTypes.string
}),
message: PropTypes.string,
object: PropTypes.string,
response_email: PropTypes.string
})
}),
open: PropTypes.bool.isRequired,
onSubmit: PropTypes.func.isRequired,
onToggle: PropTypes.func.isRequired
};
export { EmailForm as default };
//# sourceMappingURL=EmailForm.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,145 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
require('react');
var designSystem = require('@strapi/design-system');
var icons = require('@strapi/icons');
var PropTypes = require('prop-types');
var reactIntl = require('react-intl');
require('lodash/isEmpty');
var getTrad = require('../../../utils/getTrad.js');
const EmailTable = ({ canUpdate, onEditClick })=>{
const { formatMessage } = reactIntl.useIntl();
return /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Table, {
colCount: 3,
rowCount: 3,
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Thead, {
children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tr, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Th, {
width: "1%",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
children: formatMessage({
id: getTrad('Email.template.table.icon.label'),
defaultMessage: 'icon'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Th, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: getTrad('Email.template.table.name.label'),
defaultMessage: 'name'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Th, {
width: "1%",
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.VisuallyHidden, {
children: formatMessage({
id: getTrad('Email.template.table.action.label'),
defaultMessage: 'action'
})
})
})
]
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tbody, {
children: [
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tr, {
cursor: "pointer",
onClick: ()=>onEditClick('reset_password'),
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
width: "3.2rem",
height: "3.2rem",
padding: "0.8rem",
children: /*#__PURE__*/ jsxRuntime.jsx(icons.ArrowClockwise, {
"aria-label": formatMessage({
id: 'global.reset-password',
defaultMessage: 'Reset password'
})
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
children: formatMessage({
id: 'global.reset-password',
defaultMessage: 'Reset password'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
onClick: (e)=>e.stopPropagation(),
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
onClick: ()=>onEditClick('reset_password'),
label: formatMessage({
id: getTrad('Email.template.form.edit.label'),
defaultMessage: 'Edit a template'
}),
variant: "ghost",
disabled: !canUpdate,
children: /*#__PURE__*/ jsxRuntime.jsx(icons.Pencil, {})
})
})
]
}),
/*#__PURE__*/ jsxRuntime.jsxs(designSystem.Tr, {
cursor: "pointer",
onClick: ()=>onEditClick('email_confirmation'),
children: [
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Box, {
width: "3.2rem",
height: "3.2rem",
padding: "0.8rem",
children: /*#__PURE__*/ jsxRuntime.jsx(icons.Check, {
"aria-label": formatMessage({
id: getTrad('Email.template.email_confirmation'),
defaultMessage: 'Email address confirmation'
})
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Typography, {
children: formatMessage({
id: getTrad('Email.template.email_confirmation'),
defaultMessage: 'Email address confirmation'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(designSystem.Td, {
onClick: (e)=>e.stopPropagation(),
children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.IconButton, {
onClick: ()=>onEditClick('email_confirmation'),
label: formatMessage({
id: getTrad('Email.template.form.edit.label'),
defaultMessage: 'Edit a template'
}),
variant: "ghost",
disabled: !canUpdate,
children: /*#__PURE__*/ jsxRuntime.jsx(icons.Pencil, {})
})
})
]
})
]
})
]
});
};
EmailTable.propTypes = {
canUpdate: PropTypes.bool.isRequired,
onEditClick: PropTypes.func.isRequired
};
module.exports = EmailTable;
//# sourceMappingURL=EmailTable.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,143 @@
import { jsxs, jsx } from 'react/jsx-runtime';
import 'react';
import { Table, Thead, Tr, Th, VisuallyHidden, Typography, Tbody, Td, Box, IconButton } from '@strapi/design-system';
import { ArrowClockwise, Pencil, Check } from '@strapi/icons';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import 'lodash/isEmpty';
import getTrad from '../../../utils/getTrad.mjs';
const EmailTable = ({ canUpdate, onEditClick })=>{
const { formatMessage } = useIntl();
return /*#__PURE__*/ jsxs(Table, {
colCount: 3,
rowCount: 3,
children: [
/*#__PURE__*/ jsx(Thead, {
children: /*#__PURE__*/ jsxs(Tr, {
children: [
/*#__PURE__*/ jsx(Th, {
width: "1%",
children: /*#__PURE__*/ jsx(VisuallyHidden, {
children: formatMessage({
id: getTrad('Email.template.table.icon.label'),
defaultMessage: 'icon'
})
})
}),
/*#__PURE__*/ jsx(Th, {
children: /*#__PURE__*/ jsx(Typography, {
variant: "sigma",
textColor: "neutral600",
children: formatMessage({
id: getTrad('Email.template.table.name.label'),
defaultMessage: 'name'
})
})
}),
/*#__PURE__*/ jsx(Th, {
width: "1%",
children: /*#__PURE__*/ jsx(VisuallyHidden, {
children: formatMessage({
id: getTrad('Email.template.table.action.label'),
defaultMessage: 'action'
})
})
})
]
})
}),
/*#__PURE__*/ jsxs(Tbody, {
children: [
/*#__PURE__*/ jsxs(Tr, {
cursor: "pointer",
onClick: ()=>onEditClick('reset_password'),
children: [
/*#__PURE__*/ jsx(Td, {
children: /*#__PURE__*/ jsx(Box, {
width: "3.2rem",
height: "3.2rem",
padding: "0.8rem",
children: /*#__PURE__*/ jsx(ArrowClockwise, {
"aria-label": formatMessage({
id: 'global.reset-password',
defaultMessage: 'Reset password'
})
})
})
}),
/*#__PURE__*/ jsx(Td, {
children: /*#__PURE__*/ jsx(Typography, {
children: formatMessage({
id: 'global.reset-password',
defaultMessage: 'Reset password'
})
})
}),
/*#__PURE__*/ jsx(Td, {
onClick: (e)=>e.stopPropagation(),
children: /*#__PURE__*/ jsx(IconButton, {
onClick: ()=>onEditClick('reset_password'),
label: formatMessage({
id: getTrad('Email.template.form.edit.label'),
defaultMessage: 'Edit a template'
}),
variant: "ghost",
disabled: !canUpdate,
children: /*#__PURE__*/ jsx(Pencil, {})
})
})
]
}),
/*#__PURE__*/ jsxs(Tr, {
cursor: "pointer",
onClick: ()=>onEditClick('email_confirmation'),
children: [
/*#__PURE__*/ jsx(Td, {
children: /*#__PURE__*/ jsx(Box, {
width: "3.2rem",
height: "3.2rem",
padding: "0.8rem",
children: /*#__PURE__*/ jsx(Check, {
"aria-label": formatMessage({
id: getTrad('Email.template.email_confirmation'),
defaultMessage: 'Email address confirmation'
})
})
})
}),
/*#__PURE__*/ jsx(Td, {
children: /*#__PURE__*/ jsx(Typography, {
children: formatMessage({
id: getTrad('Email.template.email_confirmation'),
defaultMessage: 'Email address confirmation'
})
})
}),
/*#__PURE__*/ jsx(Td, {
onClick: (e)=>e.stopPropagation(),
children: /*#__PURE__*/ jsx(IconButton, {
onClick: ()=>onEditClick('email_confirmation'),
label: formatMessage({
id: getTrad('Email.template.form.edit.label'),
defaultMessage: 'Edit a template'
}),
variant: "ghost",
disabled: !canUpdate,
children: /*#__PURE__*/ jsx(Pencil, {})
})
})
]
})
]
})
]
});
};
EmailTable.propTypes = {
canUpdate: PropTypes.bool.isRequired,
onEditClick: PropTypes.func.isRequired
};
export { EmailTable as default };
//# sourceMappingURL=EmailTable.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,157 @@
'use strict';
var jsxRuntime = require('react/jsx-runtime');
var React = require('react');
var strapiAdmin = require('@strapi/admin/strapi-admin');
var designSystem = require('@strapi/design-system');
var admin = require('@strapi/strapi/admin');
var reactIntl = require('react-intl');
var reactQuery = require('react-query');
var constants = require('../../constants.js');
require('lodash/isEmpty');
var getTrad = require('../../utils/getTrad.js');
var EmailForm = require('./components/EmailForm.js');
var EmailTable = require('./components/EmailTable.js');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
const ProtectedEmailTemplatesPage = ()=>/*#__PURE__*/ jsxRuntime.jsx(admin.Page.Protect, {
permissions: constants.PERMISSIONS.readEmailTemplates,
children: /*#__PURE__*/ jsxRuntime.jsx(EmailTemplatesPage, {})
});
const EmailTemplatesPage = ()=>{
const { formatMessage } = reactIntl.useIntl();
const { trackUsage } = strapiAdmin.useTracking();
const { notifyStatus } = designSystem.useNotifyAT();
const { toggleNotification } = admin.useNotification();
const queryClient = reactQuery.useQueryClient();
const { get, put } = admin.useFetchClient();
const { formatAPIError } = admin.useAPIErrorHandler();
const [isModalOpen, setIsModalOpen] = React__namespace.useState(false);
const [templateToEdit, setTemplateToEdit] = React__namespace.useState(null);
const { isLoading: isLoadingForPermissions, allowedActions: { canUpdate } } = admin.useRBAC({
update: constants.PERMISSIONS.updateEmailTemplates
});
const { isLoading: isLoadingData, data } = reactQuery.useQuery([
'users-permissions',
'email-templates'
], async ()=>{
const { data } = await get('/users-permissions/email-templates');
return data;
}, {
onSuccess () {
notifyStatus(formatMessage({
id: getTrad('Email.template.data.loaded'),
defaultMessage: 'Email templates has been loaded'
}));
},
onError (error) {
toggleNotification({
type: 'danger',
message: formatAPIError(error)
});
}
});
const isLoading = isLoadingForPermissions || isLoadingData;
const handleToggle = ()=>{
setIsModalOpen((prev)=>!prev);
};
const handleEditClick = (template)=>{
setTemplateToEdit(template);
handleToggle();
};
const submitMutation = reactQuery.useMutation((body)=>put('/users-permissions/email-templates', {
'email-templates': body
}), {
async onSuccess () {
await queryClient.invalidateQueries([
'users-permissions',
'email-templates'
]);
toggleNotification({
type: 'success',
message: formatMessage({
id: 'notification.success.saved',
defaultMessage: 'Saved'
})
});
trackUsage('didEditEmailTemplates');
handleToggle();
},
onError (error) {
toggleNotification({
type: 'danger',
message: formatAPIError(error)
});
},
refetchActive: true
});
const handleSubmit = (body)=>{
trackUsage('willEditEmailTemplates');
const editedTemplates = {
...data,
[templateToEdit]: body
};
submitMutation.mutate(editedTemplates);
};
if (isLoading) {
return /*#__PURE__*/ jsxRuntime.jsx(admin.Page.Loading, {});
}
return /*#__PURE__*/ jsxRuntime.jsxs(admin.Page.Main, {
"aria-busy": submitMutation.isLoading,
children: [
/*#__PURE__*/ jsxRuntime.jsx(admin.Page.Title, {
children: formatMessage({
id: 'Settings.PageTitle',
defaultMessage: 'Settings - {name}'
}, {
name: formatMessage({
id: getTrad('HeaderNav.link.emailTemplates'),
defaultMessage: 'Email templates'
})
})
}),
/*#__PURE__*/ jsxRuntime.jsx(admin.Layouts.Header, {
title: formatMessage({
id: getTrad('HeaderNav.link.emailTemplates'),
defaultMessage: 'Email templates'
})
}),
/*#__PURE__*/ jsxRuntime.jsxs(admin.Layouts.Content, {
children: [
/*#__PURE__*/ jsxRuntime.jsx(EmailTable, {
onEditClick: handleEditClick,
canUpdate: canUpdate
}),
/*#__PURE__*/ jsxRuntime.jsx(EmailForm, {
template: data[templateToEdit],
onToggle: handleToggle,
open: isModalOpen,
onSubmit: handleSubmit
})
]
})
]
});
};
exports.EmailTemplatesPage = EmailTemplatesPage;
exports.ProtectedEmailTemplatesPage = ProtectedEmailTemplatesPage;
//# sourceMappingURL=index.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,135 @@
import { jsx, jsxs } from 'react/jsx-runtime';
import * as React from 'react';
import { useTracking } from '@strapi/admin/strapi-admin';
import { useNotifyAT } from '@strapi/design-system';
import { Page, useNotification, useFetchClient, useAPIErrorHandler, useRBAC, Layouts } from '@strapi/strapi/admin';
import { useIntl } from 'react-intl';
import { useQueryClient, useQuery, useMutation } from 'react-query';
import { PERMISSIONS } from '../../constants.mjs';
import 'lodash/isEmpty';
import getTrad from '../../utils/getTrad.mjs';
import EmailForm from './components/EmailForm.mjs';
import EmailTable from './components/EmailTable.mjs';
const ProtectedEmailTemplatesPage = ()=>/*#__PURE__*/ jsx(Page.Protect, {
permissions: PERMISSIONS.readEmailTemplates,
children: /*#__PURE__*/ jsx(EmailTemplatesPage, {})
});
const EmailTemplatesPage = ()=>{
const { formatMessage } = useIntl();
const { trackUsage } = useTracking();
const { notifyStatus } = useNotifyAT();
const { toggleNotification } = useNotification();
const queryClient = useQueryClient();
const { get, put } = useFetchClient();
const { formatAPIError } = useAPIErrorHandler();
const [isModalOpen, setIsModalOpen] = React.useState(false);
const [templateToEdit, setTemplateToEdit] = React.useState(null);
const { isLoading: isLoadingForPermissions, allowedActions: { canUpdate } } = useRBAC({
update: PERMISSIONS.updateEmailTemplates
});
const { isLoading: isLoadingData, data } = useQuery([
'users-permissions',
'email-templates'
], async ()=>{
const { data } = await get('/users-permissions/email-templates');
return data;
}, {
onSuccess () {
notifyStatus(formatMessage({
id: getTrad('Email.template.data.loaded'),
defaultMessage: 'Email templates has been loaded'
}));
},
onError (error) {
toggleNotification({
type: 'danger',
message: formatAPIError(error)
});
}
});
const isLoading = isLoadingForPermissions || isLoadingData;
const handleToggle = ()=>{
setIsModalOpen((prev)=>!prev);
};
const handleEditClick = (template)=>{
setTemplateToEdit(template);
handleToggle();
};
const submitMutation = useMutation((body)=>put('/users-permissions/email-templates', {
'email-templates': body
}), {
async onSuccess () {
await queryClient.invalidateQueries([
'users-permissions',
'email-templates'
]);
toggleNotification({
type: 'success',
message: formatMessage({
id: 'notification.success.saved',
defaultMessage: 'Saved'
})
});
trackUsage('didEditEmailTemplates');
handleToggle();
},
onError (error) {
toggleNotification({
type: 'danger',
message: formatAPIError(error)
});
},
refetchActive: true
});
const handleSubmit = (body)=>{
trackUsage('willEditEmailTemplates');
const editedTemplates = {
...data,
[templateToEdit]: body
};
submitMutation.mutate(editedTemplates);
};
if (isLoading) {
return /*#__PURE__*/ jsx(Page.Loading, {});
}
return /*#__PURE__*/ jsxs(Page.Main, {
"aria-busy": submitMutation.isLoading,
children: [
/*#__PURE__*/ jsx(Page.Title, {
children: formatMessage({
id: 'Settings.PageTitle',
defaultMessage: 'Settings - {name}'
}, {
name: formatMessage({
id: getTrad('HeaderNav.link.emailTemplates'),
defaultMessage: 'Email templates'
})
})
}),
/*#__PURE__*/ jsx(Layouts.Header, {
title: formatMessage({
id: getTrad('HeaderNav.link.emailTemplates'),
defaultMessage: 'Email templates'
})
}),
/*#__PURE__*/ jsxs(Layouts.Content, {
children: [
/*#__PURE__*/ jsx(EmailTable, {
onEditClick: handleEditClick,
canUpdate: canUpdate
}),
/*#__PURE__*/ jsx(EmailForm, {
template: data[templateToEdit],
onToggle: handleToggle,
open: isModalOpen,
onSubmit: handleSubmit
})
]
})
]
});
};
export { EmailTemplatesPage, ProtectedEmailTemplatesPage };
//# sourceMappingURL=index.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,50 @@
'use strict';
var admin = require('@strapi/strapi/admin');
var yup = require('yup');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var yup__namespace = /*#__PURE__*/_interopNamespaceDefault(yup);
const schema = yup__namespace.object().shape({
options: yup__namespace.object().shape({
from: yup__namespace.object().shape({
name: yup__namespace.string().required({
id: admin.translatedErrors.required.id,
defaultMessage: 'This field is required'
}),
email: yup__namespace.string().email(admin.translatedErrors.email).required({
id: admin.translatedErrors.required.id,
defaultMessage: 'This field is required'
})
}).required(),
response_email: yup__namespace.string().email(admin.translatedErrors.email),
object: yup__namespace.string().required({
id: admin.translatedErrors.required.id,
defaultMessage: 'This field is required'
}),
message: yup__namespace.string().required({
id: admin.translatedErrors.required.id,
defaultMessage: 'This field is required'
})
}).required(admin.translatedErrors.required.id)
});
module.exports = schema;
//# sourceMappingURL=schema.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"schema.js","sources":["../../../../../admin/src/pages/EmailTemplates/utils/schema.js"],"sourcesContent":["import { translatedErrors } from '@strapi/strapi/admin';\nimport * as yup from 'yup';\n\nconst schema = yup.object().shape({\n options: yup\n .object()\n .shape({\n from: yup\n .object()\n .shape({\n name: yup.string().required({\n id: translatedErrors.required.id,\n defaultMessage: 'This field is required',\n }),\n email: yup.string().email(translatedErrors.email).required({\n id: translatedErrors.required.id,\n defaultMessage: 'This field is required',\n }),\n })\n .required(),\n response_email: yup.string().email(translatedErrors.email),\n object: yup.string().required({\n id: translatedErrors.required.id,\n defaultMessage: 'This field is required',\n }),\n message: yup.string().required({\n id: translatedErrors.required.id,\n defaultMessage: 'This field is required',\n }),\n })\n .required(translatedErrors.required.id),\n});\n\nexport default schema;\n"],"names":["schema","yup","object","shape","options","from","name","string","required","id","translatedErrors","defaultMessage","email","response_email","message"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAMA,MAASC,GAAAA,cAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;AAChCC,IAAAA,OAAAA,EAASH,cACNC,CAAAA,MAAM,EACNC,CAAAA,KAAK,CAAC;AACLE,QAAAA,IAAAA,EAAMJ,cACHC,CAAAA,MAAM,EACNC,CAAAA,KAAK,CAAC;AACLG,YAAAA,IAAAA,EAAML,cAAIM,CAAAA,MAAM,EAAGC,CAAAA,QAAQ,CAAC;gBAC1BC,EAAIC,EAAAA,sBAAAA,CAAiBF,QAAQ,CAACC,EAAE;gBAChCE,cAAgB,EAAA;AAClB,aAAA,CAAA;YACAC,KAAOX,EAAAA,cAAAA,CAAIM,MAAM,EAAGK,CAAAA,KAAK,CAACF,sBAAiBE,CAAAA,KAAK,CAAEJ,CAAAA,QAAQ,CAAC;gBACzDC,EAAIC,EAAAA,sBAAAA,CAAiBF,QAAQ,CAACC,EAAE;gBAChCE,cAAgB,EAAA;AAClB,aAAA;AACF,SAAA,CAAA,CACCH,QAAQ,EAAA;AACXK,QAAAA,cAAAA,EAAgBZ,eAAIM,MAAM,EAAA,CAAGK,KAAK,CAACF,uBAAiBE,KAAK,CAAA;AACzDV,QAAAA,MAAAA,EAAQD,cAAIM,CAAAA,MAAM,EAAGC,CAAAA,QAAQ,CAAC;YAC5BC,EAAIC,EAAAA,sBAAAA,CAAiBF,QAAQ,CAACC,EAAE;YAChCE,cAAgB,EAAA;AAClB,SAAA,CAAA;AACAG,QAAAA,OAAAA,EAASb,cAAIM,CAAAA,MAAM,EAAGC,CAAAA,QAAQ,CAAC;YAC7BC,EAAIC,EAAAA,sBAAAA,CAAiBF,QAAQ,CAACC,EAAE;YAChCE,cAAgB,EAAA;AAClB,SAAA;AACF,KAAA,CAAA,CACCH,QAAQ,CAACE,sBAAiBF,CAAAA,QAAQ,CAACC,EAAE;AAC1C,CAAA;;;;"}

View File

@@ -0,0 +1,29 @@
import { translatedErrors } from '@strapi/strapi/admin';
import * as yup from 'yup';
const schema = yup.object().shape({
options: yup.object().shape({
from: yup.object().shape({
name: yup.string().required({
id: translatedErrors.required.id,
defaultMessage: 'This field is required'
}),
email: yup.string().email(translatedErrors.email).required({
id: translatedErrors.required.id,
defaultMessage: 'This field is required'
})
}).required(),
response_email: yup.string().email(translatedErrors.email),
object: yup.string().required({
id: translatedErrors.required.id,
defaultMessage: 'This field is required'
}),
message: yup.string().required({
id: translatedErrors.required.id,
defaultMessage: 'This field is required'
})
}).required(translatedErrors.required.id)
});
export { schema as default };
//# sourceMappingURL=schema.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"schema.mjs","sources":["../../../../../admin/src/pages/EmailTemplates/utils/schema.js"],"sourcesContent":["import { translatedErrors } from '@strapi/strapi/admin';\nimport * as yup from 'yup';\n\nconst schema = yup.object().shape({\n options: yup\n .object()\n .shape({\n from: yup\n .object()\n .shape({\n name: yup.string().required({\n id: translatedErrors.required.id,\n defaultMessage: 'This field is required',\n }),\n email: yup.string().email(translatedErrors.email).required({\n id: translatedErrors.required.id,\n defaultMessage: 'This field is required',\n }),\n })\n .required(),\n response_email: yup.string().email(translatedErrors.email),\n object: yup.string().required({\n id: translatedErrors.required.id,\n defaultMessage: 'This field is required',\n }),\n message: yup.string().required({\n id: translatedErrors.required.id,\n defaultMessage: 'This field is required',\n }),\n })\n .required(translatedErrors.required.id),\n});\n\nexport default schema;\n"],"names":["schema","yup","object","shape","options","from","name","string","required","id","translatedErrors","defaultMessage","email","response_email","message"],"mappings":";;;AAGA,MAAMA,MAASC,GAAAA,GAAAA,CAAIC,MAAM,EAAA,CAAGC,KAAK,CAAC;AAChCC,IAAAA,OAAAA,EAASH,GACNC,CAAAA,MAAM,EACNC,CAAAA,KAAK,CAAC;AACLE,QAAAA,IAAAA,EAAMJ,GACHC,CAAAA,MAAM,EACNC,CAAAA,KAAK,CAAC;AACLG,YAAAA,IAAAA,EAAML,GAAIM,CAAAA,MAAM,EAAGC,CAAAA,QAAQ,CAAC;gBAC1BC,EAAIC,EAAAA,gBAAAA,CAAiBF,QAAQ,CAACC,EAAE;gBAChCE,cAAgB,EAAA;AAClB,aAAA,CAAA;YACAC,KAAOX,EAAAA,GAAAA,CAAIM,MAAM,EAAGK,CAAAA,KAAK,CAACF,gBAAiBE,CAAAA,KAAK,CAAEJ,CAAAA,QAAQ,CAAC;gBACzDC,EAAIC,EAAAA,gBAAAA,CAAiBF,QAAQ,CAACC,EAAE;gBAChCE,cAAgB,EAAA;AAClB,aAAA;AACF,SAAA,CAAA,CACCH,QAAQ,EAAA;AACXK,QAAAA,cAAAA,EAAgBZ,IAAIM,MAAM,EAAA,CAAGK,KAAK,CAACF,iBAAiBE,KAAK,CAAA;AACzDV,QAAAA,MAAAA,EAAQD,GAAIM,CAAAA,MAAM,EAAGC,CAAAA,QAAQ,CAAC;YAC5BC,EAAIC,EAAAA,gBAAAA,CAAiBF,QAAQ,CAACC,EAAE;YAChCE,cAAgB,EAAA;AAClB,SAAA,CAAA;AACAG,QAAAA,OAAAA,EAASb,GAAIM,CAAAA,MAAM,EAAGC,CAAAA,QAAQ,CAAC;YAC7BC,EAAIC,EAAAA,gBAAAA,CAAiBF,QAAQ,CAACC,EAAE;YAChCE,cAAgB,EAAA;AAClB,SAAA;AACF,KAAA,CAAA,CACCH,QAAQ,CAACE,gBAAiBF,CAAAA,QAAQ,CAACC,EAAE;AAC1C,CAAA;;;;"}