|
|
|
@ -115,21 +115,28 @@ export default function DialogForm() {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
const resultImage = await handleUploadImage([image], PATH_ID); |
|
|
|
|
const result = await requestAssign.addData(payload); |
|
|
|
|
if (result.status === 201) { |
|
|
|
|
store.dispatch(setRegister(true)); |
|
|
|
|
Toast.show({ |
|
|
|
|
type: 'success', |
|
|
|
|
text1: strings('register.dataSentSuccessfully'), |
|
|
|
|
}); |
|
|
|
|
navigation.navigate('App'); |
|
|
|
|
clearForm() |
|
|
|
|
} else { |
|
|
|
|
if (image && image.imageFile == null) { |
|
|
|
|
Toast.show({ |
|
|
|
|
type: 'error', |
|
|
|
|
text1: strings('presence.failedSendData'), |
|
|
|
|
text1: strings('global.imageNull'), |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
const resultImage = await handleUploadImage([image], PATH_ID); |
|
|
|
|
const result = await requestAssign.addData(payload); |
|
|
|
|
if (result.status === 201) { |
|
|
|
|
store.dispatch(setRegister(true)); |
|
|
|
|
Toast.show({ |
|
|
|
|
type: 'success', |
|
|
|
|
text1: strings('register.dataSentSuccessfully'), |
|
|
|
|
}); |
|
|
|
|
navigation.navigate('App'); |
|
|
|
|
clearForm() |
|
|
|
|
} else { |
|
|
|
|
Toast.show({ |
|
|
|
|
type: 'error', |
|
|
|
|
text1: strings('presence.failedSendData'), |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
console.error("Network error sending presence data:", error); |
|
|
|
@ -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,26 +374,38 @@ export default function DialogForm() {
|
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const renderImage = useMemo(() => ( |
|
|
|
|
<> |
|
|
|
|
<View style={styles.imageBlock}> |
|
|
|
|
<TouchableRipple onPress={() => handleOpenSheetImage(image?.imageFile)}> |
|
|
|
|
<View style={styles.imageContainer}> |
|
|
|
|
<Image |
|
|
|
|
source={{ uri: image?.imageFile }} |
|
|
|
|
style={styles.image} |
|
|
|
|
resizeMode="cover" |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
</TouchableRipple> |
|
|
|
|
</View> |
|
|
|
|
const renderImage = useMemo(() => { |
|
|
|
|
if (!image?.imageFile) { |
|
|
|
|
return null; // Don't render anything if imageFile is null or undefined
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<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> |
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
|
<View style={styles.imageBlock}> |
|
|
|
|
<TouchableRipple onPress={() => handleOpenSheetImage(image?.imageFile)}> |
|
|
|
|
<View style={styles.imageContainer}> |
|
|
|
|
<Image |
|
|
|
|
source={{ uri: image.imageFile }} |
|
|
|
|
style={styles.image} |
|
|
|
|
resizeMode="cover" |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
</TouchableRipple> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<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,21 +469,22 @@ export default function DialogForm() {
|
|
|
|
|
right={<TextInput.Icon icon="chevron-down" />} |
|
|
|
|
/> |
|
|
|
|
</TouchableRipple> |
|
|
|
|
|
|
|
|
|
<TouchableRipple rippleColor={isDarkTheme ? theme.colors.blue : theme.colors.pureWhite} onPress={handleOpenSheet}> |
|
|
|
|
<TextInput |
|
|
|
|
style={{ marginTop: 10 }} |
|
|
|
|
dense={true} |
|
|
|
|
editable={false} |
|
|
|
|
value={shift ? shift : ''} |
|
|
|
|
outlineColor={colors.amethystSmoke} |
|
|
|
|
activeOutlineColor={colors.blue} |
|
|
|
|
mode="outlined" |
|
|
|
|
label='Shift' |
|
|
|
|
placeholder='Shift' |
|
|
|
|
right={<TextInput.Icon icon="chevron-down" />} |
|
|
|
|
/> |
|
|
|
|
</TouchableRipple> |
|
|
|
|
{position !== 'spv' && |
|
|
|
|
<TouchableRipple rippleColor={isDarkTheme ? theme.colors.blue : theme.colors.pureWhite} onPress={handleOpenSheet}> |
|
|
|
|
<TextInput |
|
|
|
|
style={{ marginTop: 10 }} |
|
|
|
|
dense={true} |
|
|
|
|
editable={false} |
|
|
|
|
value={shift ? shift : ''} |
|
|
|
|
outlineColor={colors.amethystSmoke} |
|
|
|
|
activeOutlineColor={colors.blue} |
|
|
|
|
mode="outlined" |
|
|
|
|
label='Shift' |
|
|
|
|
placeholder='Shift' |
|
|
|
|
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 > |
|
|
|
|