import Typography from "@material-ui/core/Typography"; import AppHeader from "@saleor/components/AppHeader"; import { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import Container from "@saleor/components/Container"; import Form from "@saleor/components/Form"; import Grid from "@saleor/components/Grid"; import PageHeader from "@saleor/components/PageHeader"; import SaveButtonBar from "@saleor/components/SaveButtonBar"; import { maybe } from "@saleor/misc"; import { UserError } from "@saleor/types"; import React from "react"; import i18n from "../../../i18n"; import { Plugin_plugin, Plugin_plugin_configuration } from "../../types/Plugin"; import PluginInfo from "../PluginInfo"; import PluginSettings from "../PluginSettings"; export interface FormData { active: boolean; configuration: Plugin_plugin_configuration; } export interface PluginsDetailsPageProps { disabled: boolean; errors: UserError[]; plugin: Plugin_plugin; saveButtonBarState: ConfirmButtonTransitionState; onBack: () => void; onSubmit: (data: FormData) => void; } const PluginsDetailsPage: React.StatelessComponent = ({ disabled, errors, plugin, saveButtonBarState, onBack, onSubmit }) => { const initialForm: FormData = { active: maybe(() => plugin.active, false), configuration: maybe(() => plugin.configuration, []) }; return (
{({ data, errors, hasChanged, submit, set, triggerChange }) => { const onChange = event => { const newData = { active: data.active, configuration: data.configuration }; const { name, value } = event.target; name === "active" ? (newData.active = value) : (newData.active = data.active); if (newData.configuration) { newData.configuration.map(item => { if (item.name === name) { item.value = value; } }); } triggerChange(); set(newData); }; return ( {i18n.t("Plugins")} plugin.name, "")} ${i18n.t("Details")}`} />
{i18n.t("Plugin Information and Status")} {i18n.t( "These are general information about your store. They define what is the URL of your store and what is shown in brow sers taskbar." )}
plugin, "")} onChange={onChange} /> {data.configuration && ( <>
{i18n.t("Plugin Settings")} {i18n.t( "This adress will be used to generate invoices and calculate shipping rates. Email adress you provide here will be used as a contact adress for your customers." )}
)}
); }}
); }; PluginsDetailsPage.displayName = "PluginsDetailsPage"; export default PluginsDetailsPage;