Pārlūkot izejas kodu

hide 5th floor, fix indoor landmark adding issue

Aidan Gironella 1 gadu atpakaļ
vecāks
revīzija
7ad4149e92

+ 4 - 2
src/components/Map/MainMapComponent/IndoorMap.tsx

@@ -57,6 +57,7 @@ const IndoorMap: React.FC<IndoorMapProps> = ({ landmarks, promptAddLandmark, foc
 
   function addLandmark(evt: GestureResponderEvent) {
     if (evt != null) {
+      evt.persist()
       Alert.alert("Are you sure you want to add a landmark here?", undefined,
         [{ text: "Cancel" }
           ,
@@ -66,6 +67,7 @@ const IndoorMap: React.FC<IndoorMapProps> = ({ landmarks, promptAddLandmark, foc
               await promptAddLandmark((evt.nativeEvent.locationX - imageDim / 2) / SVGdim[0], (evt.nativeEvent.locationY - imageDim / 2) / SVGdim[1], floor)
             }
             catch (err) {
+              console.error(err)
               Toast.show("Please ensure finger is not moving when holding down on screen.", { duration: Toast.durations.LONG, })
 
               // Alert.alert("An error has occured." , "Please ensure thumb is not moving when holding down on screen.")
@@ -129,14 +131,14 @@ const IndoorMap: React.FC<IndoorMapProps> = ({ landmarks, promptAddLandmark, foc
               { label: 'Second Floor', value: 2 },
               { label: 'Third Floor', value: 3 },
               { label: 'Fourth Floor', value: 4 },
-              { label: 'Fifth Floor', value: 5 },
+              // { label: 'Fifth Floor', value: 5 },
             ]}
           />
         </View>
 
 
         {/* {floor == 5 ? arrowBut(0, "") : arrowBut(1, "chevron-right")} */}
-        {floor == 5 ? <ArrowButton num={0} fontAweIcon={""} /> : <ArrowButton num={1} fontAweIcon={"chevron-right"} propEvent={() => changer(1)} />}
+        {floor == 4 ? <ArrowButton num={0} fontAweIcon={""} /> : <ArrowButton num={1} fontAweIcon={"chevron-right"} propEvent={() => changer(1)} />}
 
 
       </View>

+ 10 - 1
src/components/Map/Panels/LandmarkDetailsPanel/DetailsHeader.tsx

@@ -10,7 +10,7 @@ import React, { useState } from "react";
 import { Button, Alert, StyleSheet, Text, TextInput, TouchableOpacity, View, Dimensions, Platform, Pressable } from "react-native";
 import { QueryStatus } from "react-query";
 import { useAuth } from "../../../../data/Auth/AuthContext";
-import { Landmark } from "../../../../data/landmarks";
+import { Landmark, useReportLandmark } from "../../../../data/landmarks";
 import { UserProfile } from "../../../../data/profiles";
 import { MainTabsNavigationProp } from "../../../../navigation/MainTabsNavigator";
 import { Report } from "./Report";
@@ -48,6 +48,14 @@ export const DetailsHeader: React.FC<DetailsHeaderProps> = (props) => {
             props.deletePhotoStatus == "loading"
     }
 
+    // const reportLandmarkMutation = useReportLandmark()
+    // /**
+    //  * Calls the {@linkcode rateLandmarkAsunc} mutation from the {@link useLandmarks} hook. If 1, the landmark will be upvoted. If -1, it will be downvoted
+    //  */
+    //  const reportLandmark = async () => {
+    //     await reportLandmarkMutation.mutateAsync();
+    // }
+
     const HeaderContent: React.FC = () => {
         // landmark is owned by user
         if (landmarkOwnedByUser(props.landmark) || (props.profile?.places == props.place)) {
@@ -139,6 +147,7 @@ export const DetailsHeader: React.FC<DetailsHeaderProps> = (props) => {
                         </TouchableOpacity>}
                     <View style={{ flexDirection: 'row' }}>
                         <Report isLandmark = {true} landmark = {props.landmark} />
+                        {/* <Report isLandmark = {true} landmark = {props.landmark} reportLandmark = {reportLandmark}/> */}
                             <TouchOpaq
                                 func={() => props.removeLandmark()}
                                 size={25}

+ 3 - 1
src/components/Map/Panels/LandmarkDetailsPanel/Report.tsx

@@ -18,7 +18,8 @@ import { Landmark } from "../../../../data/landmarks"
 interface ReportProps {
     landmark?: Landmark,
     comment?: LMComment
-    isLandmark: boolean
+    isLandmark: boolean,
+    // reportLandmark: (string) => void
 }
 
 export const Report: React.FC<ReportProps> = (props) => {
@@ -59,6 +60,7 @@ export const Report: React.FC<ReportProps> = (props) => {
         }
         text ? report += "Extra comments: " + text : null
         console.log(report)
+        // props.reportLandmark(report)
         Alert.alert('Report submitted', 'Thank you for making The Atlas a safer place!')
         setModalVisible(!modalVisible)
         // console.log((landmarkOwnedByUser(props.landmark)))

+ 26 - 0
src/data/landmarks.ts

@@ -227,6 +227,32 @@ export const useRateLandmark = () => {
     })    
 }
 
+export const useReportLandmark = () => {
+    const {sendApiRequestAsync} = useAuth()
+    const queryClient = useQueryClient();
+
+    const reportLandmark =  async (content: string) => {
+        if (content) {
+            const response = await sendApiRequestAsync({
+                axiosConfig:{
+                    method: 'POST',
+                    data: content,
+                    url: `/api/landmark/report/`,
+                },
+                authorized: true,
+                errorMessage: 'Something went wrong when reporting a landmark',
+                loggingCategory: 'LANDMARKS'
+            });   
+            return response?.data;
+        }
+    }
+
+    return useMutation(reportLandmark, {
+        onSuccess: () => queryClient.invalidateQueries(queryKeys.getLandmark),  
+        onError: () => queryClient.invalidateQueries(queryKeys.getLandmark),  
+    })    
+}
+
 export const useDeleteLandmark = () => {
     const {sendApiRequestAsync, accessToken, anonUserId} = useAuth()
     const queryClient = useQueryClient();

+ 1 - 1
src/utils/RequestUtils.ts

@@ -15,7 +15,7 @@
 // export const API_URL = 'http://192.168.1.106:8000' // Nathan
 //export const API_URL = 'http://192.168.1.64:8000'   // Chase
 //export const API_URL = 'http://192.168.0.22:8000'       // Eric
-export const API_URL = 'http://192.168.1.130:8000'  // Aidan surface
+export const API_URL = 'http://192.168.1.131:8000'  // Aidan surface
 // export const API_URL = 'http://'  // Aidan home
 
 // export const API_URL = Config.API_URL