import Root from "../../../base/Root"; import React from "react"; import type { IAppDataType } from "../../../server"; import RootRetriever from "../root/RootRetriever"; import I18nRead from "../localization/I18nRead"; interface IUSSDActionProps { label: string; i18nCapitalize?: boolean; useI18n?: boolean; /** * An unique id that should identify this action specifically * in the entire tree, it should be unique accross all actions */ id: string; requestInput?: string; onInput: (appData: IAppDataType, value: string) => string | void | Promise; } interface IActualUSSDActionProps extends IUSSDActionProps { root: Root; } interface IUSSDActionElement { label: string; actionId: string; input: string; } function USSDActionElement(props: IUSSDActionElement) { return (
) } class ActualUSSDAction extends React.Component { public static getDerivedServerSideStateFromProps(props: IActualUSSDActionProps) { const ussdActionId = "USSD_" + props.id; props.root.setStateKey(ussdActionId, props.onInput); return { ussdActionId, } } render() { const actionId = "USSD_" + this.props.id; if (this.props.useI18n) { return ( {(i18nLabel: string) => ( typeof this.props.requestInput === "string" ? {(i18nRequestInput: string) => ( )} : ( ) )} ); } return ( ) } } export default function USSDAction(props: IUSSDActionProps) { return ( {(root) => ( )} ); }