|
@@ -72,6 +72,7 @@ const CreateSharedTripScreen = ({ route }: { route: any }) => {
|
|
const [photos, setPhotos] = useState<any[]>([]);
|
|
const [photos, setPhotos] = useState<any[]>([]);
|
|
const [regions, setRegions] = useState<any[]>(route.params?.regionsToSave ?? []);
|
|
const [regions, setRegions] = useState<any[]>(route.params?.regionsToSave ?? []);
|
|
const [regionsError, setRegionsError] = useState<string | null>(null);
|
|
const [regionsError, setRegionsError] = useState<string | null>(null);
|
|
|
|
+ const [photosError, setPhotosError] = useState<string | null>(null);
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
if (route.params?.regionsToSave) {
|
|
if (route.params?.regionsToSave) {
|
|
@@ -233,12 +234,17 @@ const CreateSharedTripScreen = ({ route }: { route: any }) => {
|
|
{
|
|
{
|
|
onSuccess: (res) => {
|
|
onSuccess: (res) => {
|
|
setIsSubmitting(false);
|
|
setIsSubmitting(false);
|
|
- console.log('res', res);
|
|
|
|
- navigation.goBack();
|
|
|
|
|
|
+ setModalInfo({
|
|
|
|
+ visible: true,
|
|
|
|
+ type: 'success',
|
|
|
|
+ title: 'Success',
|
|
|
|
+ buttonTitle: 'OK',
|
|
|
|
+ message: `Thank you for adding this new trip. It will undergo review soon. You'll be notified via email once it is approved.`,
|
|
|
|
+ action: () => {}
|
|
|
|
+ });
|
|
},
|
|
},
|
|
onError: (err) => {
|
|
onError: (err) => {
|
|
setIsSubmitting(false);
|
|
setIsSubmitting(false);
|
|
- console.log('err', err);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
);
|
|
);
|
|
@@ -396,6 +402,7 @@ const CreateSharedTripScreen = ({ route }: { route: any }) => {
|
|
photos,
|
|
photos,
|
|
selectPhoto: (photo: any) => {
|
|
selectPhoto: (photo: any) => {
|
|
props.setFieldValue('photo', photo);
|
|
props.setFieldValue('photo', photo);
|
|
|
|
+ setPhotosError(null);
|
|
}
|
|
}
|
|
} as any
|
|
} as any
|
|
})
|
|
})
|
|
@@ -426,6 +433,19 @@ const CreateSharedTripScreen = ({ route }: { route: any }) => {
|
|
</View>
|
|
</View>
|
|
) : null}
|
|
) : null}
|
|
|
|
|
|
|
|
+ {photosError ? (
|
|
|
|
+ <Text
|
|
|
|
+ style={{
|
|
|
|
+ color: Colors.RED,
|
|
|
|
+ fontSize: getFontSize(12),
|
|
|
|
+ fontFamily: 'redhat-600',
|
|
|
|
+ marginTop: -5
|
|
|
|
+ }}
|
|
|
|
+ >
|
|
|
|
+ {photosError}
|
|
|
|
+ </Text>
|
|
|
|
+ ) : null}
|
|
|
|
+
|
|
<View>
|
|
<View>
|
|
<Text
|
|
<Text
|
|
style={{
|
|
style={{
|
|
@@ -532,10 +552,16 @@ const CreateSharedTripScreen = ({ route }: { route: any }) => {
|
|
<Button
|
|
<Button
|
|
onPress={() => {
|
|
onPress={() => {
|
|
if (regions.length === 0) {
|
|
if (regions.length === 0) {
|
|
- setRegionsError('Please add at least one region.');
|
|
|
|
|
|
+ setRegionsError('please add at least one region');
|
|
} else {
|
|
} else {
|
|
setRegionsError(null);
|
|
setRegionsError(null);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (photos.length > 0 && !props.values.photo) {
|
|
|
|
+ setPhotosError('please select a photo');
|
|
|
|
+ } else {
|
|
|
|
+ setPhotosError(null);
|
|
|
|
+ }
|
|
props.handleSubmit();
|
|
props.handleSubmit();
|
|
}}
|
|
}}
|
|
disabled={isSubmitting}
|
|
disabled={isSubmitting}
|
|
@@ -579,6 +605,12 @@ const CreateSharedTripScreen = ({ route }: { route: any }) => {
|
|
} else {
|
|
} else {
|
|
setRegionsError(null);
|
|
setRegionsError(null);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (photos.length > 0 && !props.values.photo) {
|
|
|
|
+ setPhotosError('please select a photo');
|
|
|
|
+ } else {
|
|
|
|
+ setPhotosError(null);
|
|
|
|
+ }
|
|
props.handleSubmit();
|
|
props.handleSubmit();
|
|
}}
|
|
}}
|
|
disabled={isSubmitting}
|
|
disabled={isSubmitting}
|