modaq
Version:
Quiz Bowl Reader using TypeScript, React, and MobX
49 lines • 3.14 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProtestDialogBase = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const React = __importStar(require("react"));
const Dialog_1 = require("@fluentui/react/lib/Dialog");
const Button_1 = require("@fluentui/react/lib/Button");
const mobx_react_lite_1 = require("mobx-react-lite");
const TextField_1 = require("@fluentui/react/lib/TextField");
require("../../state/AppState");
const ModalDialog_1 = require("./ModalDialog");
require("../../state/ModalVisibilityStatus");
exports.ProtestDialogBase = mobx_react_lite_1.observer(function ProtestDialogBase(props) {
const givenAnswerChangeHandler = React.useCallback((ev, newValue) => props.appState.uiState.updatePendingProtestGivenAnswer(newValue !== null && newValue !== void 0 ? newValue : ""), [props]);
const reasonChangeHandler = React.useCallback((ev, newValue) => props.appState.uiState.updatePendingProtestReason(newValue !== null && newValue !== void 0 ? newValue : ""), [props]);
const submitHandler = React.useCallback(() => onSubmit(props), [props]);
const cancelHandler = React.useCallback(() => onCancel(props), [props]);
return (jsx_runtime_1.jsxs(ModalDialog_1.ModalDialog, Object.assign({ title: "Add Protest", visibilityStatus: props.visibilityStatus, onDismiss: cancelHandler }, { children: [props.children, jsx_runtime_1.jsx(TextField_1.TextField, { label: "Given answer", value: props.givenAnswer, multiline: true, onChange: givenAnswerChangeHandler, autoFocus: props.autoFocusOnGivenAnswer }, void 0),
jsx_runtime_1.jsx(TextField_1.TextField, { label: "Reason for the protest", value: props.reason, multiline: true, onChange: reasonChangeHandler }, void 0),
jsx_runtime_1.jsxs(Dialog_1.DialogFooter, { children: [jsx_runtime_1.jsx(Button_1.PrimaryButton, { text: "OK", onClick: submitHandler }, void 0),
jsx_runtime_1.jsx(Button_1.DefaultButton, { text: "Cancel", onClick: cancelHandler }, void 0)] }, void 0)] }), void 0));
});
function onSubmit(props) {
props.onSubmit();
props.hideDialog();
}
function onCancel(props) {
props.hideDialog();
}
//# sourceMappingURL=ProtestDialogBase.js.map