134 lines
6.4 KiB
TypeScript
134 lines
6.4 KiB
TypeScript
// Metro module 14806 (f14807).
|
|
import { useState, memo } from "react";
|
|
import { ScrollView } from "react-native";
|
|
import ChangelogStore from "../../../changelog/ChangelogStore";
|
|
import SurveyStore from "../../../../stores/SurveyStore";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import { ActionSheet } from "../../../../design/components/Sheet/native/ActionSheet.native";
|
|
import { BottomSheetTitleHeader } from "../../../../design/components/Sheet/native/BottomSheetTitleHeader.native";
|
|
import { ActionSheetRow } from "../../../../design/components/Sheet/native/ActionSheetRow.native";
|
|
import { CopyIcon } from "../../../../design/components/Icon/native/redesign/generated/CopyIcon";
|
|
import { copy } from "../../../../utils/ClipboardUtils.native";
|
|
import { TextInput } from "../../../../design/components/TextInput/native/TextInput.native";
|
|
import { Button } from "../../../../design/components/Button/native/Button.native";
|
|
import { overrideSurvey } from "../../../../actions/SurveyActionCreators";
|
|
import ActionSheetActionCreators from "../../../action_sheet/native/ActionSheetActionCreators";
|
|
import { useStateFromStores } from "../../../../_bundle/Module589";
|
|
import usePrevious from "../../../../hooks/usePrevious";
|
|
import { TableRowGroup } from "../../../../design/components/TableRow/native/TableRowGroup.native";
|
|
import { TableRow } from "../../../../design/components/TableRow/native/TableRow.native";
|
|
import { Text } from "../../../../design/components/Text/native/Text";
|
|
import ChangeLogActionCreators from "../../../../actions/ChangeLogActionCreators";
|
|
import { Stack } from "../../../../design/components/Stack/native/Stack.native";
|
|
let useStyles, SurveyOverrideActionSheet, SurveyInfo, ChangelogOverrideDebuggingActionSheet, ChangelogOverrideActionSheet, ChangelogInfo;
|
|
const SurveyOverrideInfoActionSheet = function SurveyOverrideInfoActionSheet(props) {
|
|
return <ActionSheet header={<BottomSheetTitleHeader title="Last Survey Data" />}>
|
|
<ActionSheetRow.Group hasIcons>
|
|
{Object.entries(props.survey).map((item) => {
|
|
let [key, c27812_0] = item;
|
|
return <ActionSheetRow key={key} label={key} subLabel={c27812_0 != null ? JSON.stringify(c27812_0) : "null"} icon={<CopyIcon />} onPress={() => {
|
|
copy(c27812_0 != null ? JSON.stringify(c27812_0) : "null");
|
|
}} />;
|
|
})}
|
|
</ActionSheetRow.Group>
|
|
</ActionSheet>;
|
|
};
|
|
SurveyOverrideActionSheet = function SurveyOverrideActionSheet() {
|
|
const [state, onChange] = useState(() => {
|
|
let r4 = SurveyStore.getSurveyOverride();
|
|
if (r4 == null) {
|
|
r4 = null;
|
|
}
|
|
return r4;
|
|
});
|
|
const props = {
|
|
header: <BottomSheetTitleHeader title="Survey Override" />,
|
|
children: null
|
|
};
|
|
const children = [<TextInput label="Survey Override" size="md" placeholder="Enter the ID of the Survey you want to test" onChange={onChange} isClearable />, ,];
|
|
const r2 = state === "";
|
|
children[1] = <Button text={r2 ? "Reset Survey Override" : "Fetch Survey"} variant={r2 ? "destructive" : state == null ? "secondary" : "primary"} onPress={() => {
|
|
if (state === "") {
|
|
overrideSurvey(null);
|
|
} else {
|
|
overrideSurvey(state);
|
|
}
|
|
ActionSheetActionCreators.hideActionSheet("SurveyOverrideActionSheet");
|
|
}} />;
|
|
props.children = children;
|
|
return <ActionSheet {...props} />;
|
|
};
|
|
SurveyInfo = function SurveyInfo() {
|
|
const survey = usePrevious(useStateFromStores([SurveyStore], () => SurveyStore.getCurrentSurvey()));
|
|
return <TableRowGroup title="Surveys" hasIcons={false}>
|
|
<TableRow label="Survey override" subLabel="Force a survey to be shown." arrow onPress={() => {
|
|
ActionSheetActionCreators.openLazy(Promise.resolve({
|
|
default: SurveyOverrideActionSheet
|
|
}), "SurveyOverrideActionSheet");
|
|
}} />
|
|
<TableRow label="Previous survey data" subLabel={survey == null ? "No survey data" : void 0} arrow={survey != null} onPress={survey != null ? () => {
|
|
ActionSheetActionCreators.openLazy(Promise.resolve({
|
|
default: SurveyOverrideInfoActionSheet
|
|
}), "SurveyOverrideInfoActionSheet", {
|
|
survey
|
|
});
|
|
} : void 0} />
|
|
</TableRowGroup>;
|
|
};
|
|
ChangelogOverrideDebuggingActionSheet = function ChangelogOverrideDebuggingActionSheet() {
|
|
return <ActionSheet header={<BottomSheetTitleHeader title="Changelog Debugging" />}>
|
|
<Text variant="text-md/semibold">
|
|
{`${JSON.stringify(ChangelogStore.getStateForDebugging(), void 0, "\t")}`}
|
|
</Text>
|
|
</ActionSheet>;
|
|
};
|
|
ChangelogOverrideActionSheet = function ChangelogOverrideActionSheet() {
|
|
const [state2, onChange] = useState(() => ChangelogStore.overrideId());
|
|
const props = {
|
|
header: <BottomSheetTitleHeader title="Changelog Override" />,
|
|
children: null
|
|
};
|
|
const children = [<TextInput label="Changelog Override" size="md" placeholder="Enter the ID of the changelog you want to test" onChange={onChange} isClearable />, ,];
|
|
const r2 = state2 === "";
|
|
children[1] = <Button text={r2 ? "Reset Changelog Override" : "Fetch Changelog"} variant={r2 ? "destructive" : state2 == null ? "secondary" : "primary"} onPress={() => {
|
|
if (state2 === "") {
|
|
ChangeLogActionCreators.setChangelogOverride(null);
|
|
} else {
|
|
ChangeLogActionCreators.setChangelogOverride(state2);
|
|
}
|
|
ActionSheetActionCreators.hideActionSheet("ChangelogOverrideActionSheet");
|
|
}} />;
|
|
props.children = children;
|
|
return <ActionSheet {...props} />;
|
|
};
|
|
ChangelogInfo = function ChangelogInfo() {
|
|
return <TableRowGroup title="Changelog" hasIcons={false}>
|
|
<TableRow label="Changelog override" subLabel="Force a changelog to be shown." arrow onPress={() => {
|
|
ActionSheetActionCreators.openLazy(Promise.resolve({
|
|
default: ChangelogOverrideActionSheet
|
|
}), "ChangelogOverrideActionSheet");
|
|
}} />
|
|
<TableRow label="Changelog debugging" arrow onPress={() => {
|
|
ActionSheetActionCreators.openLazy(Promise.resolve({
|
|
default: ChangelogOverrideDebuggingActionSheet
|
|
}), "ChangelogOverrideDebuggingActionSheet");
|
|
}} />
|
|
</TableRowGroup>;
|
|
};
|
|
useStyles = createStyles({
|
|
scrollView: {
|
|
padding: Module712.space.PX_16,
|
|
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW
|
|
}
|
|
});
|
|
const r50 = memo(function UserSettingsSurveyChangelogOverride() {
|
|
return <ScrollView style={useStyles().scrollView}>
|
|
<Stack spacing={16}>
|
|
<SurveyInfo />
|
|
<ChangelogInfo />
|
|
</Stack>
|
|
</ScrollView>;
|
|
});
|
|
export default r50;
|