diff --git a/src/screens/registerPage/index.js b/src/screens/registerPage/index.js
index 5ea8bbf..352baf6 100644
--- a/src/screens/registerPage/index.js
+++ b/src/screens/registerPage/index.js
@@ -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(() => (
- <>
-
- handleOpenSheetImage(image?.imageFile)}>
-
-
-
-
-
+ const renderImage = useMemo(() => {
+ if (!image?.imageFile) {
+ return null; // Don't render anything if imageFile is null or undefined
+ }
-
+ return (
+ <>
+
+ handleOpenSheetImage(image?.imageFile)}>
+
+
+
+
+
+
+
+ >
+ );
+ }, [image, handleOpenSheetImage, handleDeleteImage]);
- >
- ), [image, handleOpenSheetImage, handleDeleteImage]);
@@ -451,21 +469,22 @@ export default function DialogForm() {
right={}
/>
-
-
- }
- />
-
+ {position !== 'spv' &&
+
+ }
+ />
+
+ }
{position !== 'spv' &&
- {image !== null && renderImage}
+ {!image && image?.imageFile !== null && renderImage}