import { TextInput, Alert, Switch, TouchableOpacity, View, Text, Modal, FlatList, KeyboardAvoidingView } from 'react-native'; import Clipboard from '@react-native-clipboard/clipboard'; import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context'; import AntIcon from '@expo/vector-icons/AntDesign'; import MatIcon from '@expo/vector-icons/MaterialCommunityIcons'; import { styles } from './Dashboard.styled'; import { useLocation } from 'react-router-dom'; import { useDashboard } from './useDashboard.hook'; import { Logo } from 'utils/Logo'; export function Dashboard(props) { const location = useLocation(); const { config, server, token } = location.state; const { state, actions } = useDashboard(config, server, token); const saveConfig = async () => { try { await actions.saveConfig(); actions.hideEditConfig(); } catch (err) { console.log(err); Alert.alert( 'Failed to Save Settings', 'Please try again.', ); } } const addUser = async () => { try { await actions.addUser(); } catch (err) { console.log(err); Alert.alert( 'Failed to Generate Access Token', 'Please try again.', ); } } const accessUser = async (accountId) => { try { await actions.accessUser(accountId); } catch (err) { console.log(err); Alert.alert( 'Failed to Generate Access Token', 'Please try again.', ); } } const removeUser = (accountId) => { Alert.alert( "Deleting Account", "Confirm?", [ { text: "Cancel", onPress: () => {}, }, { text: "Delete", onPress: async() => { try { await actions.removeUser(accountId); } catch (err) { console.log(err); Alert.alert( "Failed to Delete Account", "Please try again.", ); } }} ] ) } const enableUser = async (accountId, enabled) => { try { await actions.enableUser(accountId, enabled); } catch (err) { console.log(err); Alert.alert( 'Failed to Update Account', 'Please try again.', ); } } return ( Accounts item.accountId} renderItem={({ item }) => ( { item.name } { item.handle } accessUser(item.accountId)}> { item.disabled && ( enableUser(item.accountId, true)}> )} { !item.disabled && ( enableUser(item.accountId, false)}> )} removeUser(item.accountId)}> )} /> Settings: Account Key Type: actions.setKeyType('RSA2048')}> { state.keyType === 'RSA2048' && ( )} { state.keyType === 'RSA4096' && ( )} RSA 2048 actions.setKeyType('RSA4096')}> { state.keyType === 'RSA2048' && ( )} { state.keyType === 'RSA4096' && ( )} RSA 4096 actions.setPushSupported(!state.pushSupported)}> Enable Push Notifications: actions.setEnableImage(!state.enableImage)}> Enable Image Queue: actions.setEnableAudio(!state.enableAudio)}> Enable Audio Queue: actions.setEnableVideo(!state.enableVideo)}> Enable Video Queue: Cancel Save Create Account: Token: Clipboard.setString(state.createToken)}> { state.createToken } Done Access Account: Token: Clipboard.setString(state.accessToken)}> { state.accessToken } Done ) }