Explorar el Código

updated reporting modal

aidan hace 1 año
padre
commit
30739dbd3e

+ 0 - 13
src/components/Map/Panels/LandmarkDetailsPanel/DetailsHeader.tsx

@@ -55,14 +55,12 @@ export const DetailsHeader: React.FC<DetailsHeaderProps> = (props) => {
             if (props.editingEnabled) {
                 return (
                     <View style={{ flexDirection: 'row', justifyContent: 'space-between', alignItems: "center", width: '100%' }}>
-
                         <TouchOpaq
                             func={() => props.toggleEditing(false)}
                             size={25}
                             col={"white"}
                             name={"close"}
                         />
-
                         {props.updatedLandmark?.description && props.updatedLandmark.landmark_type ? // only display check if fields are populated
                             // <FontAwesome style={{ marginTop: 2 }} size={25} color="white" name="check" onPress={async () => props.editLandmark()} /> 
                             <TouchOpaq
@@ -78,39 +76,29 @@ export const DetailsHeader: React.FC<DetailsHeaderProps> = (props) => {
             // editing is disabled
             else {
                 return (
-
                     <View style={{ borderColor: 'blue', borderWidth: 0, flexDirection: 'row', alignItems: "center", justifyContent: 'space-between', width: '100%' }}>
                         <View style={{ borderColor: 'green', borderWidth: 0, flexDirection: 'row', alignItems: "center", justifyContent: "flex-end" }}>
-
                             <TouchOpaq
                                 func={() => props.toggleEditing(true)}
                                 size={25}
                                 col={"white"}
                                 name={"edit"}
                             />
-
                             <TouchOpaq
                                 func={() => props.removeLandmark()}
                                 size={25}
                                 col={"white"}
                                 name={"trash"}
                             />
-
                             <Text style={{ color: 'white', fontSize: 20, marginTop: 2, marginLeft: 10 }} >{props.landmark?.rating}</Text>
-                            {/* <Text>Lil Tjay rn</Text> */}
-
                             <FontAwesome style={{ marginLeft: 5, marginBottom: 2, marginRight: 10 }} color="white" size={25} name="thumbs-up" />
                         </View>
-
                         <TouchOpaq
                             func={() => props.toggleDetailsPanel(false)}
                             size={25}
                             col={"white"}
                             name={"close"}
                         />
-
-
-
                     </View>
                 )
             }
@@ -158,7 +146,6 @@ export const DetailsHeader: React.FC<DetailsHeaderProps> = (props) => {
                             name={"close"}
                         />
                     </View>
-
                 </View>
             )
         }

+ 21 - 19
src/components/Map/Panels/LandmarkDetailsPanel/Report.tsx

@@ -11,6 +11,7 @@ import { useState } from "react"
 import { Alert, Text, StyleSheet, Pressable, TextInput, TouchableOpacity, View, Keyboard } from "react-native"
 import Modal from "react-native-modal"
 import Select from "react-native-multiple-select"
+import { useAuth } from "../../../../data/Auth/AuthContext"
 import { LMComment } from "../../../../data/comments"
 import { Landmark } from "../../../../data/landmarks"
 
@@ -45,26 +46,27 @@ export const Report: React.FC<ReportProps> = (props) => {
         setModalVisible(!modalVisible)
     }
 
+    const { landmarkOwnedByUser, anonUserId, setAlert } = useAuth()
     const sendReport = () => {
-        // var report = props.isLandmark ?
-        //     "Report submitted for landmark '" + props.landmark?.title + "':\n\tID: " + props.landmark?.id
-        //     + "\n\tLandmark author: " + props.landmark?.user
-        //     + "\n\tCoordinates: " + props.landmark?.longitude + " " + props.landmark?.latitude
-        //     + "\n\tLandmark type: " + props.landmark?.landmark_type
-        //     :
-        //     "Report submitted for a comment on landmark " + props.comment?.landmark
-        //     + '\n\tComment: "' + props.comment?.content + '"'
-        // report += "\nReason(s) for report: \n\t"
-        // for (let i = 0; i < selectedReasons.length; i++) {
-        //     var tempItem = reasons.find(item => item.value === selectedReasons[i]).label
-        //     console.log(tempItem)
-        //     report += tempItem + ((i == selectedReasons.length - 1) ? "\n" : "\n\t")
-        // }
-        // text ? report += "Extra comments: " + text : null
-        // console.log(report)
-        // Alert.alert('Report submitted', 'Thank you for making the Atlas a safer place!')
-        // setModalVisible(!modalVisible)
-        console.log(lmTypes[6].label)
+        var report = props.isLandmark ?
+            "Report submitted for landmark '" + props.landmark?.title + "':\n\tID: " + props.landmark?.id
+            + "\n\tLandmark author: " + props.landmark?.user
+            + "\n\tCoordinates: " + props.landmark?.longitude + " " + props.landmark?.latitude
+            + "\n\tLandmark type: " + props.landmark?.landmark_type
+            :
+            "Report submitted for a comment on landmark " + props.comment?.landmark
+            + '\n\tComment: "' + props.comment?.content + '"'
+        report += "\nReason(s) for report: \n\t"
+        for (let i = 0; i < selectedReasons.length; i++) {
+            var tempItem = reasons.find(item => item.value === selectedReasons[i]).label
+            console.log(tempItem)
+            report += tempItem + ((i == selectedReasons.length - 1) ? "\n" : "\n\t")
+        }
+        text ? report += "Extra comments: " + text : null
+        console.log(report)
+        Alert.alert('Report submitted', 'Thank you for making the Atlas a safer place!')
+        setModalVisible(!modalVisible)
+        // console.log((landmarkOwnedByUser(props.landmark)))
     }
 
     const [modalVisible, setModalVisible] = useState(false)

+ 1 - 1
src/data/landmarks.ts

@@ -239,7 +239,7 @@ export const useDeleteLandmark = () => {
             }
 
             if (!accessToken) config.data = {...config.data, anonymous: anonUserId}
-
+            console.warn(config)
             const response = await sendApiRequestAsync({
                 axiosConfig: config,
                 authorized: true,