Files
pole-book/server/node_modules/.strapi/vite/deps/Settings-GIICDRUW.js

460 lines
16 KiB
JavaScript

import {
PERMISSIONS
} from "./chunk-PDGPTUUZ.js";
import "./chunk-QF6GPHA4.js";
import "./chunk-JRLAXHTE.js";
import "./chunk-E4IFZ6ZT.js";
import {
useMutation,
useQuery
} from "./chunk-QLEKUQKW.js";
import "./chunk-4J3VOWQV.js";
import "./chunk-PFI4R5WA.js";
import "./chunk-B3BGMYGX.js";
import "./chunk-W6ICJ5TB.js";
import "./chunk-IHYIPMY2.js";
import "./chunk-UWHSN2C7.js";
import "./chunk-ERK7O2GM.js";
import {
useFetchClient
} from "./chunk-FCIM6RNO.js";
import "./chunk-J33IXKN4.js";
import "./chunk-NP53ZCXD.js";
import "./chunk-MBK4V2X7.js";
import "./chunk-5ESYXDTN.js";
import "./chunk-K65KIEAL.js";
import "./chunk-B7ZLODDO.js";
import "./chunk-PW7XKCYO.js";
import "./chunk-RMBEU7DO.js";
import "./chunk-RI2W2UZ6.js";
import "./chunk-IY256CNP.js";
import {
errorsTrads
} from "./chunk-IFOFBKTA.js";
import {
ValidationError,
create4 as create,
create6 as create2
} from "./chunk-XLSIZGJF.js";
import "./chunk-EGNP2T5O.js";
import "./chunk-GSN7U3BK.js";
import "./chunk-T3B5F2LV.js";
import "./chunk-YXDCVYVT.js";
import "./chunk-QIJGNK42.js";
import "./chunk-7PUJSL55.js";
import "./chunk-C2ZJTFO7.js";
import "./chunk-C75BZXCZ.js";
import "./chunk-APGTER6B.js";
import "./chunk-ZM6TT53G.js";
import "./chunk-6AXVGFVQ.js";
import "./chunk-BFLP6DBI.js";
import "./chunk-CMLQV3Z2.js";
import "./chunk-IGCTEXRF.js";
import {
Layouts
} from "./chunk-TIVRAWTC.js";
import "./chunk-PQINNV4N.js";
import "./chunk-VYSYYPOB.js";
import {
Page
} from "./chunk-5CAWUBTQ.js";
import "./chunk-W2TBR6J3.js";
import "./chunk-QEGMJR7H.js";
import "./chunk-LCL5TIBZ.js";
import "./chunk-WOQNBAGN.js";
import "./chunk-BHLYCXQ7.js";
import "./chunk-76QM3EFM.js";
import "./chunk-CE4VABH2.js";
import "./chunk-5VODLFKF.js";
import {
useNotification
} from "./chunk-N55RVBRV.js";
import {
Box,
Button,
Field,
Flex,
Grid,
SingleSelect,
SingleSelectOption,
TextInput,
Typography,
useIntl
} from "./chunk-7XB6XSWQ.js";
import "./chunk-5ZC4PE57.js";
import "./chunk-TUXTO2Z5.js";
import "./chunk-FOD4ENRR.js";
import {
ForwardRef$2d
} from "./chunk-WRD5KPDH.js";
import {
require_jsx_runtime
} from "./chunk-NIAJZ5MX.js";
import {
dt
} from "./chunk-ACIMPXWY.js";
import {
require_react
} from "./chunk-MADUDGYZ.js";
import {
__toESM
} from "./chunk-PLDDJCW6.js";
// node_modules/@strapi/email/dist/admin/pages/Settings.mjs
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
var React = __toESM(require_react(), 1);
// node_modules/@strapi/email/dist/admin/utils/getYupInnerErrors.mjs
var extractValuesFromYupError = (errorType, errorParams) => {
if (!errorType || !errorParams) {
return {};
}
return {
[errorType]: errorParams[errorType]
};
};
var getYupInnerErrors = (error) => ((error == null ? void 0 : error.inner) || []).reduce((acc, currentError) => {
if (currentError.path) {
acc[currentError.path.split("[").join(".").split("]").join("")] = {
id: currentError.message,
defaultMessage: currentError.message,
values: extractValuesFromYupError(currentError == null ? void 0 : currentError.type, currentError == null ? void 0 : currentError.params)
};
}
return acc;
}, {});
// node_modules/@strapi/email/dist/admin/utils/schema.mjs
var schema = create2().shape({
email: create().email(errorsTrads.email.id).required(errorsTrads.required.id)
});
// node_modules/@strapi/email/dist/admin/pages/Settings.mjs
var DocumentationLink = dt.a`
color: ${({ theme }) => theme.colors.primary600};
`;
var ProtectedSettingsPage = () => (0, import_jsx_runtime.jsx)(Page.Protect, {
permissions: PERMISSIONS.settings,
children: (0, import_jsx_runtime.jsx)(SettingsPage, {})
});
var SettingsPage = () => {
var _a, _b;
const { toggleNotification } = useNotification();
const { formatMessage } = useIntl();
const { get, post } = useFetchClient();
const [testAddress, setTestAddress] = React.useState("");
const [isTestAddressValid, setIsTestAddressValid] = React.useState(false);
const [formErrors, setFormErrors] = React.useState({});
const { data, isLoading } = useQuery([
"email",
"settings"
], async () => {
const res = await get("/email/settings");
const { data: { config } } = res;
return config;
});
const mutation = useMutation(async (body) => {
await post("/email/test", body);
}, {
onError() {
toggleNotification({
type: "danger",
message: formatMessage({
id: "email.Settings.email.plugin.notification.test.error",
defaultMessage: "Failed to send a test mail to {to}"
}, {
to: testAddress
})
});
},
onSuccess() {
toggleNotification({
type: "success",
message: formatMessage({
id: "email.Settings.email.plugin.notification.test.success",
defaultMessage: "Email test succeeded, check the {to} mailbox"
}, {
to: testAddress
})
});
},
retry: false
});
React.useEffect(() => {
schema.validate({
email: testAddress
}, {
abortEarly: false
}).then(() => setIsTestAddressValid(true)).catch(() => setIsTestAddressValid(false));
}, [
testAddress
]);
const handleChange = (event) => {
setTestAddress(() => event.target.value);
};
const handleSubmit = async (event) => {
event.preventDefault();
try {
await schema.validate({
email: testAddress
}, {
abortEarly: false
});
} catch (error) {
if (error instanceof ValidationError) {
setFormErrors(getYupInnerErrors(error));
}
}
mutation.mutate({
to: testAddress
});
};
if (isLoading) {
return (0, import_jsx_runtime.jsx)(Page.Loading, {});
}
return (0, import_jsx_runtime.jsxs)(Page.Main, {
labelledBy: "title",
"aria-busy": isLoading || mutation.isLoading,
children: [
(0, import_jsx_runtime.jsx)(Page.Title, {
children: formatMessage({
id: "Settings.PageTitle",
defaultMessage: "Settings - {name}"
}, {
name: formatMessage({
id: "email.Settings.email.plugin.title",
defaultMessage: "Configuration"
})
})
}),
(0, import_jsx_runtime.jsx)(Layouts.Header, {
id: "title",
title: formatMessage({
id: "email.Settings.email.plugin.title",
defaultMessage: "Configuration"
}),
subtitle: formatMessage({
id: "email.Settings.email.plugin.subTitle",
defaultMessage: "Test the settings for the Email plugin"
})
}),
(0, import_jsx_runtime.jsx)(Layouts.Content, {
children: data && (0, import_jsx_runtime.jsx)("form", {
onSubmit: handleSubmit,
children: (0, import_jsx_runtime.jsxs)(Flex, {
direction: "column",
alignItems: "stretch",
gap: 7,
children: [
(0, import_jsx_runtime.jsx)(Box, {
background: "neutral0",
hasRadius: true,
shadow: "filterShadow",
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
children: (0, import_jsx_runtime.jsxs)(Flex, {
direction: "column",
alignItems: "stretch",
gap: 4,
children: [
(0, import_jsx_runtime.jsxs)(Flex, {
direction: "column",
alignItems: "stretch",
gap: 1,
children: [
(0, import_jsx_runtime.jsx)(Typography, {
variant: "delta",
tag: "h2",
children: formatMessage({
id: "email.Settings.email.plugin.title.config",
defaultMessage: "Configuration"
})
}),
(0, import_jsx_runtime.jsx)(Typography, {
children: formatMessage({
id: "email.Settings.email.plugin.text.configuration",
defaultMessage: "The plugin is configured through the {file} file, checkout this {link} for the documentation."
}, {
file: "./config/plugins.js",
link: (0, import_jsx_runtime.jsx)(DocumentationLink, {
href: "https://docs.strapi.io/developer-docs/latest/plugins/email.html",
target: "_blank",
rel: "noopener noreferrer",
children: formatMessage({
id: "email.link",
defaultMessage: "Link"
})
})
})
})
]
}),
(0, import_jsx_runtime.jsxs)(Grid.Root, {
gap: 5,
children: [
(0, import_jsx_runtime.jsx)(Grid.Item, {
col: 6,
s: 12,
direction: "column",
alignItems: "stretch",
children: (0, import_jsx_runtime.jsxs)(Field.Root, {
name: "shipper-email",
children: [
(0, import_jsx_runtime.jsx)(Field.Label, {
children: formatMessage({
id: "email.Settings.email.plugin.label.defaultFrom",
defaultMessage: "Default sender email"
})
}),
(0, import_jsx_runtime.jsx)(TextInput, {
placeholder: formatMessage({
id: "email.Settings.email.plugin.placeholder.defaultFrom",
defaultMessage: "ex: Strapi No-Reply '<'no-reply@strapi.io'>'"
}),
disabled: true,
value: data.settings.defaultFrom
})
]
})
}),
(0, import_jsx_runtime.jsx)(Grid.Item, {
col: 6,
s: 12,
direction: "column",
alignItems: "stretch",
children: (0, import_jsx_runtime.jsxs)(Field.Root, {
name: "response-email",
children: [
(0, import_jsx_runtime.jsx)(Field.Label, {
children: formatMessage({
id: "email.Settings.email.plugin.label.defaultReplyTo",
defaultMessage: "Default response email"
})
}),
(0, import_jsx_runtime.jsx)(TextInput, {
placeholder: formatMessage({
id: "email.Settings.email.plugin.placeholder.defaultReplyTo",
defaultMessage: `ex: Strapi '<'example@strapi.io'>'`
}),
disabled: true,
value: data.settings.defaultReplyTo
})
]
})
}),
(0, import_jsx_runtime.jsx)(Grid.Item, {
col: 6,
s: 12,
direction: "column",
alignItems: "stretch",
children: (0, import_jsx_runtime.jsxs)(Field.Root, {
name: "email-provider",
children: [
(0, import_jsx_runtime.jsx)(Field.Label, {
children: formatMessage({
id: "email.Settings.email.plugin.label.provider",
defaultMessage: "Email provider"
})
}),
(0, import_jsx_runtime.jsx)(SingleSelect, {
disabled: true,
value: data.provider,
children: (0, import_jsx_runtime.jsx)(SingleSelectOption, {
value: data.provider,
children: data.provider
})
})
]
})
})
]
})
]
})
}),
(0, import_jsx_runtime.jsxs)(Flex, {
alignItems: "stretch",
background: "neutral0",
direction: "column",
gap: 4,
hasRadius: true,
shadow: "filterShadow",
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
children: [
(0, import_jsx_runtime.jsx)(Typography, {
variant: "delta",
tag: "h2",
children: formatMessage({
id: "email.Settings.email.plugin.title.test",
defaultMessage: "Test email delivery"
})
}),
(0, import_jsx_runtime.jsxs)(Grid.Root, {
gap: 5,
children: [
(0, import_jsx_runtime.jsx)(Grid.Item, {
col: 6,
s: 12,
direction: "column",
alignItems: "stretch",
children: (0, import_jsx_runtime.jsxs)(Field.Root, {
name: "test-address",
error: ((_a = formErrors.email) == null ? void 0 : _a.id) && formatMessage({
id: `email.${(_b = formErrors.email) == null ? void 0 : _b.id}`,
defaultMessage: "This is not a valid email"
}),
children: [
(0, import_jsx_runtime.jsx)(Field.Label, {
children: formatMessage({
id: "email.Settings.email.plugin.label.testAddress",
defaultMessage: "Recipient email"
})
}),
(0, import_jsx_runtime.jsx)(TextInput, {
onChange: handleChange,
value: testAddress,
placeholder: formatMessage({
id: "email.Settings.email.plugin.placeholder.testAddress",
defaultMessage: "ex: developer@example.com"
})
})
]
})
}),
(0, import_jsx_runtime.jsx)(Grid.Item, {
col: 7,
s: 12,
direction: "column",
alignItems: "start",
children: (0, import_jsx_runtime.jsx)(Button, {
loading: mutation.isLoading,
disabled: !isTestAddressValid,
type: "submit",
startIcon: (0, import_jsx_runtime.jsx)(ForwardRef$2d, {}),
children: formatMessage({
id: "email.Settings.email.plugin.button.test-email",
defaultMessage: "Send test email"
})
})
})
]
})
]
})
]
})
})
})
]
});
};
export {
ProtectedSettingsPage
};
//# sourceMappingURL=Settings-GIICDRUW.js.map