2022-05-11 16:33:27 +00:00
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
import { useNavigation } from '@react-navigation/native';
|
2019-05-18 19:31:33 +00:00
|
|
|
import { WebView } from 'react-native-webview';
|
2022-05-11 16:33:27 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
import { StackNavigationProp } from '@react-navigation/stack';
|
2019-05-18 19:31:33 +00:00
|
|
|
|
|
|
|
import I18n from '../../i18n';
|
|
|
|
import StatusBar from '../../containers/StatusBar';
|
2020-10-30 16:15:58 +00:00
|
|
|
import * as HeaderButton from '../../containers/HeaderButton';
|
2020-02-11 14:09:14 +00:00
|
|
|
import { getUserSelector } from '../../selectors/login';
|
2020-06-15 14:00:46 +00:00
|
|
|
import SafeAreaView from '../../containers/SafeAreaView';
|
2021-12-03 19:27:57 +00:00
|
|
|
import { AdminPanelStackParamList } from '../../stacks/types';
|
2022-05-11 16:33:27 +00:00
|
|
|
import { IApplicationState } from '../../definitions';
|
2019-05-18 19:31:33 +00:00
|
|
|
|
2022-05-11 16:33:27 +00:00
|
|
|
const AdminPanelView = () => {
|
|
|
|
const navigation = useNavigation<StackNavigationProp<AdminPanelStackParamList, 'AdminPanelView'>>();
|
|
|
|
const baseUrl = useSelector((state: IApplicationState) => state.server.server);
|
|
|
|
const token = useSelector((state: IApplicationState) => getUserSelector(state).token);
|
|
|
|
const isMasterDetail = useSelector((state: IApplicationState) => state.app.isMasterDetail);
|
2021-09-15 13:18:53 +00:00
|
|
|
|
2022-05-11 16:33:27 +00:00
|
|
|
useEffect(() => {
|
|
|
|
navigation.setOptions({
|
|
|
|
headerLeft: isMasterDetail ? undefined : () => <HeaderButton.Drawer navigation={navigation} />,
|
|
|
|
title: I18n.t('Admin_Panel')
|
|
|
|
});
|
|
|
|
}, [isMasterDetail, navigation]);
|
2021-09-15 13:18:53 +00:00
|
|
|
|
2022-05-11 16:33:27 +00:00
|
|
|
if (!baseUrl) {
|
|
|
|
return null;
|
2019-05-18 19:31:33 +00:00
|
|
|
}
|
2019-08-07 13:51:34 +00:00
|
|
|
|
2022-05-11 16:33:27 +00:00
|
|
|
return (
|
|
|
|
<SafeAreaView>
|
|
|
|
<StatusBar />
|
|
|
|
<WebView
|
|
|
|
// https://github.com/react-native-community/react-native-webview/issues/1311
|
|
|
|
onMessage={() => {}}
|
|
|
|
source={{ uri: `${baseUrl}/admin/info?layout=embedded` }}
|
|
|
|
injectedJavaScript={`Meteor.loginWithToken('${token}', function() { })`}
|
|
|
|
/>
|
|
|
|
</SafeAreaView>
|
|
|
|
);
|
|
|
|
};
|
2019-08-07 13:51:34 +00:00
|
|
|
|
2022-05-11 16:33:27 +00:00
|
|
|
export default AdminPanelView;
|