@strawbinary-io/api-video-strapi-5-plugin
Version:
A powerful Strapi plugin to easily manage your videos and integrate them in your project
98 lines (97 loc) • 3.17 kB
JavaScript
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
import { useState, useEffect } from "react";
import { Page, useNotification } from "@strapi/strapi/admin";
import { Button, Box } from "@strapi/design-system";
import "react-dom/client";
import { Check } from "@strapi/icons";
import { L as Layouts } from "./rulesEngine-BdlgvQPi.mjs";
import "react-router-dom";
import "@strapi/icons/symbols";
import "react-intl";
import { F as FieldComp, T as Toggle, s as settingsRequests } from "./index-BBCEpeLD.mjs";
const Settings = () => {
const [settings, setSettings] = useState({
apiKey: "",
defaultPublic: true
});
const { toggleNotification } = useNotification();
const getSettings = async () => {
const settings2 = await settingsRequests.get();
setSettings(settings2.data);
};
useEffect(() => {
getSettings();
}, []);
const handleChange = (event) => {
setSettings({ ...settings, apiKey: event.target.value });
};
const handleSetPublic = (event) => {
setSettings({ ...settings, defaultPublic: event.target.checked });
};
const handleOnSubmit = async () => {
const response = await settingsRequests.update(settings);
if (response) {
toggleNotification({
type: "success",
message: "Changes saved"
});
} else {
toggleNotification({
type: "warning",
message: "Please enter valid settings"
});
}
};
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(
Layouts.Header,
{
title: "api.video plugin settings",
primaryAction: /* @__PURE__ */ jsx(Button, { type: "submit", onClick: handleOnSubmit, startIcon: /* @__PURE__ */ jsx(Check, {}), size: "L", children: "Save" })
}
),
/* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsxs(
Box,
{
background: "neutral0",
hasRadius: true,
shadow: "filterShadow",
paddingTop: 6,
paddingBottom: 6,
paddingLeft: 7,
paddingRight: 7,
children: [
/* @__PURE__ */ jsx(
FieldComp,
{
name: "API Key",
label: "API Key",
value: settings.apiKey,
placeholder: "Enter your API Key",
description: "Generated in the api.video's dashboard and used for authenticating API calls.",
detailsLink: "https://dashboard.api.video",
isPassword: true,
onChange: handleChange
}
),
/* @__PURE__ */ jsx("br", {}),
/* @__PURE__ */ jsx(
Toggle,
{
label: "Default Video Privacy",
checked: settings.defaultPublic,
required: true,
onLabel: "Public",
offLabel: "Private",
onChange: handleSetPublic
}
)
]
}
) })
] });
};
const index = () => /* @__PURE__ */ jsx(Page.Protect, { permissions: [{ action: "plugin::api-video-strapi-5-plugin.settings.read", subject: null }], children: /* @__PURE__ */ jsx(Settings, {}) });
export {
index as default
};