Browse Source

update register page

master
farhantock 5 months ago
parent
commit
7d4250654e
  1. 37
      src/screens/registerPage/index.js

37
src/screens/registerPage/index.js

@ -115,6 +115,12 @@ export default function DialogForm() {
};
try {
if (image && image.imageFile == null) {
Toast.show({
type: 'error',
text1: strings('global.imageNull'),
});
} else {
const resultImage = await handleUploadImage([image], PATH_ID);
const result = await requestAssign.addData(payload);
if (result.status === 201) {
@ -131,6 +137,7 @@ export default function DialogForm() {
text1: strings('presence.failedSendData'),
});
}
}
} catch (error) {
console.error("Network error sending presence data:", error);
Toast.show({
@ -346,7 +353,6 @@ export default function DialogForm() {
// const tempPath = `file://${RNFS.TemporaryDirectoryPath}/prsensi/${moment().format('YYYYMMDDHHmmss')}.jpg`;
// await RNFS.copyFile(markedImage, tempPath);
console.log("markedImage", markedImage);
const newImageData = {
id: 0,
attachment_number: existingAttachmentNumber,
@ -368,13 +374,18 @@ export default function DialogForm() {
});
};
const renderImage = useMemo(() => (
const renderImage = useMemo(() => {
if (!image?.imageFile) {
return null; // Don't render anything if imageFile is null or undefined
}
return (
<>
<View style={styles.imageBlock}>
<TouchableRipple onPress={() => handleOpenSheetImage(image?.imageFile)}>
<View style={styles.imageContainer}>
<Image
source={{ uri: image?.imageFile }}
source={{ uri: image.imageFile }}
style={styles.image}
resizeMode="cover"
/>
@ -382,12 +393,19 @@ export default function DialogForm() {
</TouchableRipple>
</View>
<Button icon="delete" style={{ borderRadius: 10, backgroundColor: colors.semiRed, marginHorizontal: 5, marginBottom: 10 }} textColor={colors.beanRed} mode="contained-tonal" onPress={handleDeleteImage}>
<Button
icon="delete"
style={{ borderRadius: 10, backgroundColor: colors.semiRed, marginHorizontal: 5, marginBottom: 10 }}
textColor={colors.beanRed}
mode="contained-tonal"
onPress={handleDeleteImage}
>
{strings('global.delete')}
</Button>
</>
), [image, handleOpenSheetImage, handleDeleteImage]);
);
}, [image, handleOpenSheetImage, handleDeleteImage]);
@ -451,7 +469,7 @@ export default function DialogForm() {
right={<TextInput.Icon icon="chevron-down" />}
/>
</TouchableRipple>
{position !== 'spv' &&
<TouchableRipple rippleColor={isDarkTheme ? theme.colors.blue : theme.colors.pureWhite} onPress={handleOpenSheet}>
<TextInput
style={{ marginTop: 10 }}
@ -466,6 +484,7 @@ export default function DialogForm() {
right={<TextInput.Icon icon="chevron-down" />}
/>
</TouchableRipple>
}
{position !== 'spv' &&
<TouchableRipple rippleColor={isDarkTheme ? theme.colors.blue : theme.colors.pureWhite} onPress={handleOpenSheetArea}>
<TextInput
@ -511,11 +530,11 @@ export default function DialogForm() {
placeholder='Masa Berlaku KTA'
/>
</TouchableRipple>
{image !== null && renderImage}
{!image && image?.imageFile !== null && renderImage}
</ScrollView>
<View style={{ width: '100%', marginTop: 10, marginBottom: 5 }}>
<Button icon="camera-plus" style={{ borderRadius: 10, backgroundColor: colors.semiBlue, paddingVertical: 5, marginHorizontal: 5, }} textColor={colors.blue} mode="contained-tonal" onPress={handleTakePicture}>
{strings('global.addImage')}
{strings('global.addImage')} KTA
</Button>
</View>
</View >

Loading…
Cancel
Save