Skip to content

Commit

Permalink
Merge pull request #66 from tamotam-com/EditEventValidation
Browse files Browse the repository at this point in the history
Edit Event Input Validation
  • Loading branch information
danieldanielecki authored Mar 24, 2024
2 parents 1e23d4f + 3fc980d commit 2ec1915
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 27 deletions.
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android.useAndroidX=true

# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

android.disableAutomaticComponentCreation=true
# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.125.0

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"react-native-map-clustering": "^3.4.2",
"react-native-maps": "^1.7.1",
"react-native-paper": "^5.4.0",
"react-native-reanimated": "3.0.2",
"react-native-reanimated": "^3.8.1",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "~3.20.0",
"react-native-vector-icons": "^9.2.0",
Expand Down
29 changes: 28 additions & 1 deletion screens/EditEventScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export default function EditEventScreen({ navigation, route }: any) {
const [selectedLocation, setSelectedLocation] = useState<Coordinate>();
const [showDatepicker, setShowDatepicker] = useState<boolean>(false);
const [titleValue, setTitleValue] = useState<string>("");
const [titleError, setTitleError] = useState<string>("");
const [locationError, setLocationError] = useState<string>("");
const [dateTimeError, setDateTimeError] = useState<string>("");
let markerCoordinates: Coordinate = {
latitude: selectedEvent.latitude ? selectedEvent.latitude : 0,
longitude: selectedEvent.longitude ? selectedEvent.longitude : 0,
Expand Down Expand Up @@ -225,6 +228,8 @@ export default function EditEventScreen({ navigation, route }: any) {
});
setSelectedDate(selectedValueDate);
setShowDatepicker(false);
// Edit Date & Time Error Blank
setDateTimeError("")
};

const onLocationChange: (e: {
Expand All @@ -239,6 +244,8 @@ export default function EditEventScreen({ navigation, route }: any) {
latitude: e.nativeEvent.coordinate.latitude,
longitude: e.nativeEvent.coordinate.longitude,
});
//Edit location error blank
setLocationError("")
};

const onShowDatePicker: () => void = () => {
Expand All @@ -262,6 +269,8 @@ export default function EditEventScreen({ navigation, route }: any) {
description: "--- Analytics: screens -> EditEventScreen -> onTitleChange, text: " + text,
});
setTitleValue(text);
//Edit Title error blank
setTitleError("")
};

const showDateTimeMode: (currentMode: string) => void = (currentMode: string) => {
Expand All @@ -273,6 +282,16 @@ export default function EditEventScreen({ navigation, route }: any) {
};

const onSaveHandler: () => void = async () => {
if (!titleValue.trim()) {
setTitleError("* Please enter a title.");
}
if (markerCoordinates.latitude === 0 || markerCoordinates.longitude === 0) {
setLocationError("* Please select a location.");
}
if (!selectedDate) {
setDateTimeError("* Please select a date and time.");
}
else{
analytics().logEvent("custom_log", {
description: "--- Analytics: screens -> EditEventScreen -> onSaveHandler",
});
Expand Down Expand Up @@ -345,6 +364,7 @@ export default function EditEventScreen({ navigation, route }: any) {
}

navigation.goBack();
}
};

const Map: () => JSX.Element = () => (
Expand Down Expand Up @@ -393,6 +413,7 @@ export default function EditEventScreen({ navigation, route }: any) {
</View> :
<Map />
}
{locationError && <StyledText style={[styles.error,styles.form,{marginTop:12}]}>{locationError}</StyledText>}
<View style={styles.form}>
<StyledText style={styles.label}>Title</StyledText>
<TextInput
Expand All @@ -406,6 +427,7 @@ export default function EditEventScreen({ navigation, route }: any) {
},
]}
/>
{titleError && <StyledText style={styles.error}>{titleError}</StyledText>}
<StyledText style={styles.label}>Description</StyledText>
<TextInput
defaultValue={selectedEvent ? selectedEvent.description : ""}
Expand Down Expand Up @@ -478,6 +500,7 @@ export default function EditEventScreen({ navigation, route }: any) {
minute: "2-digit",
})}</StyledText>
</View>
{dateTimeError && <StyledText style={styles.error}>{dateTimeError}</StyledText>}
<SelectImage
existingImageUrl={
selectedEvent.imageUrl && typeof selectedEvent.imageUrl === "string"
Expand Down Expand Up @@ -541,6 +564,10 @@ const styles = StyleSheet.create({
title: {
fontSize: 20,
fontWeight: "bold",
textAlign: "center",
textAlign: "center",
},
error: {
color: 'red',
marginBottom: 10,
},
});
101 changes: 77 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.21.5.tgz#345f2377d05a720a4e5ecfa39cbf4474a4daed56"
integrity sha512-0WDaIlXKOX/3KfBK/dwP1oQGiPh6rjMkT7HIRv7i5RR2VUMwrx5ZL0dwBkKx7+SW1zwNdgjHd34IMk5ZjTeHVg==

"@babel/helper-plugin-utils@^7.24.0":
version "7.24.0"
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.0.tgz#945681931a52f15ce879fd5b86ce2dae6d3d7f2a"
integrity sha512-9cUznXMG0+FxRuJfvL82QlTqIzhVW9sL0KjMPHhAOOvpQGL8QtdxnBKILjBqxlHyliz0yCa1G903ZXI/FuHy2w==

"@babel/helper-remap-async-to-generator@^7.18.9":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.18.9.tgz#997458a0e3357080e54e1d79ec347f8a8cd28519"
Expand Down Expand Up @@ -222,6 +227,13 @@
dependencies:
"@babel/types" "^7.20.0"

"@babel/helper-skip-transparent-expression-wrappers@^7.22.5":
version "7.22.5"
resolved "https://registry.yarnpkg.com/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.22.5.tgz#007f15240b5751c537c40e77abb4e89eeaaa8847"
integrity sha512-tK14r66JZKiC43p8Ki33yLBVJKlQDFoA8GYN67lWCDCqoL6EMMSuM9b+Iff2jHaM/RRFYl7K+iiru7hbRqNx8Q==
dependencies:
"@babel/types" "^7.22.5"

"@babel/helper-split-export-declaration@^7.18.6":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz#7367949bc75b20c6d5a5d4a97bba2824ae8ef075"
Expand All @@ -234,11 +246,21 @@
resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.21.5.tgz#2b3eea65443c6bdc31c22d037c65f6d323b6b2bd"
integrity sha512-5pTUx3hAJaZIdW99sJ6ZUUgWq/Y+Hja7TowEnLNMm1VivRgZQL3vpBY3qUACVsvw+yQU6+YgfBVmcbLaZtrA1w==

"@babel/helper-string-parser@^7.23.4":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.24.1.tgz#f99c36d3593db9540705d0739a1f10b5e20c696e"
integrity sha512-2ofRCjnnA9y+wk8b9IAREroeUP02KHp431N2mhKniy2yKIDKpbrHv9eXwm8cBeWQYcJmzv5qKCu65P47eCF7CQ==

"@babel/helper-validator-identifier@^7.18.6", "@babel/helper-validator-identifier@^7.19.1":
version "7.19.1"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz#7eea834cf32901ffdc1a7ee555e2f9c27e249ca2"
integrity sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==

"@babel/helper-validator-identifier@^7.22.20":
version "7.22.20"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz#c4ae002c61d2879e724581d96665583dbc1dc0e0"
integrity sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==

"@babel/helper-validator-option@^7.21.0":
version "7.21.0"
resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.21.0.tgz#8224c7e13ace4bafdc4004da2cf064ef42673180"
Expand Down Expand Up @@ -602,6 +624,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.21.5"

"@babel/plugin-transform-arrow-functions@^7.0.0-0":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.24.1.tgz#2bf263617060c9cc45bcdbf492b8cc805082bf27"
integrity sha512-ngT/3NkRhsaep9ck9uj2Xhv9+xB1zShY3tM3g6om4xxCELwCDN4g4Aq5dRn48+0hasAql7s2hdBOysCfNpr4fw==
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"

"@babel/plugin-transform-async-to-generator@^7.0.0", "@babel/plugin-transform-async-to-generator@^7.20.7":
version "7.20.7"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.20.7.tgz#dfee18623c8cb31deb796aa3ca84dda9cea94354"
Expand Down Expand Up @@ -766,12 +795,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"

"@babel/plugin-transform-object-assign@^7.16.7":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-object-assign/-/plugin-transform-object-assign-7.18.6.tgz#7830b4b6f83e1374a5afb9f6111bcfaea872cdd2"
integrity sha512-mQisZ3JfqWh2gVXvfqYCAAyRs6+7oev+myBsTwW5RnPhYXOTuCEw2oe3YgxlXMViXUS53lG8koulI7mJ+8JE+A==
"@babel/plugin-transform-nullish-coalescing-operator@^7.0.0-0":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-nullish-coalescing-operator/-/plugin-transform-nullish-coalescing-operator-7.24.1.tgz#0cd494bb97cb07d428bd651632cb9d4140513988"
integrity sha512-iQ+caew8wRrhCikO5DrUYx0mrmdhkaELgFa+7baMcVuhxIkN7oxt06CZ51D65ugIb1UWRQ8oQe+HXAVM6qHFjw==
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/plugin-syntax-nullish-coalescing-operator" "^7.8.3"

"@babel/plugin-transform-object-super@^7.0.0", "@babel/plugin-transform-object-super@^7.18.6":
version "7.18.6"
Expand All @@ -781,6 +811,15 @@
"@babel/helper-plugin-utils" "^7.18.6"
"@babel/helper-replace-supers" "^7.18.6"

"@babel/plugin-transform-optional-chaining@^7.0.0-0":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-optional-chaining/-/plugin-transform-optional-chaining-7.24.1.tgz#26e588acbedce1ab3519ac40cc748e380c5291e6"
integrity sha512-n03wmDt+987qXwAgcBlnUUivrZBPZ8z1plL0YvgQalLm+ZE5BMhGm94jhxXtA1wzv1Cu2aaOv1BM9vbVttrzSg==
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"
"@babel/helper-skip-transparent-expression-wrappers" "^7.22.5"
"@babel/plugin-syntax-optional-chaining" "^7.8.3"

"@babel/plugin-transform-parameters@^7.0.0", "@babel/plugin-transform-parameters@^7.20.7", "@babel/plugin-transform-parameters@^7.21.3":
version "7.21.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.21.3.tgz#18fc4e797cf6d6d972cb8c411dbe8a809fa157db"
Expand Down Expand Up @@ -861,6 +900,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.18.6"

"@babel/plugin-transform-shorthand-properties@^7.0.0-0":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.24.1.tgz#ba9a09144cf55d35ec6b93a32253becad8ee5b55"
integrity sha512-LyjVB1nsJ6gTTUKRjRWx9C1s9hE7dLfP/knKdrfeH9UPtAGjYGgxIbFfx7xyLIEWs7Xe1Gnf8EWiUqfjLhInZA==
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"

"@babel/plugin-transform-spread@^7.0.0", "@babel/plugin-transform-spread@^7.20.7":
version "7.20.7"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-spread/-/plugin-transform-spread-7.20.7.tgz#c2d83e0b99d3bf83e07b11995ee24bf7ca09401e"
Expand All @@ -883,6 +929,13 @@
dependencies:
"@babel/helper-plugin-utils" "^7.18.9"

"@babel/plugin-transform-template-literals@^7.0.0-0":
version "7.24.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.24.1.tgz#15e2166873a30d8617e3e2ccadb86643d327aab7"
integrity sha512-WRkhROsNzriarqECASCNu/nojeXCDTE/F2HmRgOzi7NGvyfYGq1NEjKBK3ckLfRgGc6/lPAqP0vDOSw3YtG34g==
dependencies:
"@babel/helper-plugin-utils" "^7.24.0"

"@babel/plugin-transform-typeof-symbol@^7.18.9":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.18.9.tgz#c8cea68263e45addcd6afc9091429f80925762c0"
Expand Down Expand Up @@ -1085,6 +1138,15 @@
"@babel/helper-validator-identifier" "^7.19.1"
to-fast-properties "^2.0.0"

"@babel/types@^7.22.5":
version "7.24.0"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.24.0.tgz#3b951f435a92e7333eba05b7566fd297960ea1bf"
integrity sha512-+j7a5c253RfKh8iABBhywc8NSfP5LURe7Uh4qpsh6jc+aLJguvmIUBdjSdEMQv2bENrCR5MfRdjGo7vzS/ob7w==
dependencies:
"@babel/helper-string-parser" "^7.23.4"
"@babel/helper-validator-identifier" "^7.22.20"
to-fast-properties "^2.0.0"

"@callstack/react-theme-provider@^3.0.8":
version "3.0.8"
resolved "https://registry.yarnpkg.com/@callstack/react-theme-provider/-/react-theme-provider-3.0.8.tgz#d0d7ac71e422133c5f7b78f4c4aa1bc57f156f50"
Expand Down Expand Up @@ -5240,11 +5302,6 @@ lodash.debounce@^4.0.8:
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==

lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==

lodash.throttle@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4"
Expand Down Expand Up @@ -6728,18 +6785,19 @@ react-native-paper@^5.4.0:
color "^3.1.2"
use-latest-callback "^0.1.5"

react-native-reanimated@3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-3.0.2.tgz#8f7284fab2b0cd949779429e48f32d19a966bbd6"
integrity sha512-8Et90yTI9yxchGbDP79k391XZqc/64zNbASbGy8X3Vgv4EbZ1M3IkKwcIbZmbVwpA804VJ6V9nJAGUh9fP0LrA==
react-native-reanimated@^3.8.1:
version "3.8.1"
resolved "https://registry.yarnpkg.com/react-native-reanimated/-/react-native-reanimated-3.8.1.tgz#45c13d4bedebef8df3d5a8756f25072de65960d7"
integrity sha512-EdM0vr3JEaNtqvstqESaPfOBy0gjYBkr1iEolWJ82Ax7io8y9OVUIphgsLKTB36CtR1XtmBw0RZVj7KArc7ZVA==
dependencies:
"@babel/plugin-transform-object-assign" "^7.16.7"
"@babel/plugin-transform-arrow-functions" "^7.0.0-0"
"@babel/plugin-transform-nullish-coalescing-operator" "^7.0.0-0"
"@babel/plugin-transform-optional-chaining" "^7.0.0-0"
"@babel/plugin-transform-shorthand-properties" "^7.0.0-0"
"@babel/plugin-transform-template-literals" "^7.0.0-0"
"@babel/preset-typescript" "^7.16.7"
convert-source-map "^1.7.0"
convert-source-map "^2.0.0"
invariant "^2.2.4"
lodash.isequal "^4.5.0"
setimmediate "^1.0.5"
string-hash-64 "^1.0.3"

react-native-safe-area-context@4.5.0:
version "4.5.0"
Expand Down Expand Up @@ -7535,11 +7593,6 @@ strict-uri-encode@^2.0.0:
resolved "https://registry.yarnpkg.com/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz#b9c7330c7042862f6b142dc274bbcc5866ce3546"
integrity sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==

string-hash-64@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/string-hash-64/-/string-hash-64-1.0.3.tgz#0deb56df58678640db5c479ccbbb597aaa0de322"
integrity sha512-D5OKWKvDhyVWWn2x5Y9b+37NUllks34q1dCDhk/vYcso9fmhs+Tl3KR/gE4v5UNj2UA35cnX4KdVVGkG1deKqw==

string-length@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/string-length/-/string-length-4.0.2.tgz#a8a8dc7bd5c1a82b9b3c8b87e125f66871b6e57a"
Expand Down

0 comments on commit 2ec1915

Please sign in to comment.