mirror of
https://github.com/balzack/databag.git
synced 2025-05-04 15:35:16 +00:00
adding otp modal prompt
This commit is contained in:
parent
da46fc17e9
commit
870fe1bcf1
@ -140,8 +140,17 @@ export const styles = StyleSheet.create({
|
|||||||
content: {
|
content: {
|
||||||
width: 300,
|
width: 300,
|
||||||
padding: 16,
|
padding: 16,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
gap: 16,
|
||||||
},
|
},
|
||||||
close: {
|
close: {
|
||||||
paddingTop: 8,
|
paddingTop: 8,
|
||||||
},
|
},
|
||||||
|
controls: {
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
gap: 16,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -12,6 +12,7 @@ import left from '../images/login.png';
|
|||||||
import {IconButton, Modal, Surface, Text, TextInput, Button} from 'react-native-paper';
|
import {IconButton, Modal, Surface, Text, TextInput, Button} from 'react-native-paper';
|
||||||
import {SafeAreaView} from 'react-native-safe-area-context';
|
import {SafeAreaView} from 'react-native-safe-area-context';
|
||||||
import { BlurView } from "@react-native-community/blur";
|
import { BlurView } from "@react-native-community/blur";
|
||||||
|
import { InputCode } from '../utils/InputCode';
|
||||||
|
|
||||||
export function Access() {
|
export function Access() {
|
||||||
const [text, setText] = useState('');
|
const [text, setText] = useState('');
|
||||||
@ -20,6 +21,7 @@ export function Access() {
|
|||||||
const [showConfirm, setShowConfirm] = useState(false);
|
const [showConfirm, setShowConfirm] = useState(false);
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
const [alert, setAlert] = useState(false);
|
const [alert, setAlert] = useState(false);
|
||||||
|
const [otp, setOtp] = useState(false);
|
||||||
|
|
||||||
const login = async () => {
|
const login = async () => {
|
||||||
if (!state.loading) {
|
if (!state.loading) {
|
||||||
@ -34,7 +36,7 @@ export function Access() {
|
|||||||
} else if (state.mode === 'admin') {
|
} else if (state.mode === 'admin') {
|
||||||
await actions.adminLogin();
|
await actions.adminLogin();
|
||||||
}
|
}
|
||||||
console.log('OTP CLOSE');
|
setOtp(false);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err.message);
|
console.log(err.message);
|
||||||
if (
|
if (
|
||||||
@ -47,7 +49,7 @@ export function Access() {
|
|||||||
} else {
|
} else {
|
||||||
setDisabled(false);
|
setDisabled(false);
|
||||||
}
|
}
|
||||||
console.log('DONE LOGIN');
|
setOtp(true);
|
||||||
} else {
|
} else {
|
||||||
setAlert(true);
|
setAlert(true);
|
||||||
}
|
}
|
||||||
@ -384,6 +386,32 @@ export function Access() {
|
|||||||
</Button>
|
</Button>
|
||||||
</Surface>
|
</Surface>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
<Modal
|
||||||
|
visible={otp}
|
||||||
|
onDismiss={() => setOtp(false)}
|
||||||
|
contentContainerStyle={styles.modal}>
|
||||||
|
<Surface elevation={5} mode="flat" style={styles.content}>
|
||||||
|
<Text variant="titleLarge">{state.strings.mfaTitle}</Text>
|
||||||
|
<Text variant="titleSmall">{state.strings.mfaEnter}</Text>
|
||||||
|
<InputCode onChangeText={actions.setCode} />
|
||||||
|
<View style={styles.controls}>
|
||||||
|
<Button
|
||||||
|
mode="outlined"
|
||||||
|
style={styles.submit}
|
||||||
|
onPress={() => setOtp(false)}>
|
||||||
|
{state.strings.cancel}
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
mode="contained"
|
||||||
|
style={styles.submit}
|
||||||
|
onPress={login}
|
||||||
|
loading={state.loading}
|
||||||
|
disabled={state.code.length !== 6}>
|
||||||
|
{state.strings.login}
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
</Surface>
|
||||||
|
</Modal>
|
||||||
</Surface>
|
</Surface>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user