瀏覽代碼

added base support for sending lm svg to server

cdmoss 2 年之前
父節點
當前提交
9301113930

+ 0 - 1
src/components/Map/MainMapComponent/OutdoorMap.tsx

@@ -20,7 +20,6 @@ import Spokestack from 'react-native-spokestack';
 import { Landmark, useLandmarks } from "../../../hooks/useLandmarks";
 import { useProfile } from "../../../hooks/useProfile";
 import { AuthTabsParamList as AuthTabsParamList, AuthTabsNavigationProp } from "../../../navigation/AuthorizedNavigator";
-import { authStore } from "../../../libs/auth/AuthStore";
 import { NotifType } from "../../../types";
 import { checkVoicePermissions, colors, getMapPermissions, lmTypes } from "../../../utils/GlobalUtils";
 import Badge from "../../Badge";

+ 4 - 0
src/components/Map/MainMapComponent/useMapState.ts

@@ -15,6 +15,10 @@ export const useMapState = () => {
      * State that contains the new {@link Landmark} object which is passed down to the {@link AddLandmark} modal.
      */
     const [newLandmark, setNewLandmark] = useState<Landmark>(undefined);
+    /**
+     * State that contains image data for the location of a new indoor landmark added.
+     */
+     const [indoorLmLocImg, setIndoorLmLocImg] = useState<string>(undefined);
     /**
      * State that contains the selected {@link Landmark} object which is passed down to the {@link LandmarkDetails} modal.
      */

+ 3 - 2
src/components/Map/Panels/AddLandmarkPanel.tsx

@@ -32,6 +32,7 @@ export interface AddLandmarkProps {
      * The {@link landmark} object to be added.
      */
     newLandmark?: Landmark;
+    indoorLmLocImg?: string;
     /**
      * The state updater for the new {@link landmark} to be added.
      */
@@ -48,7 +49,7 @@ export interface AddLandmarkProps {
  * @component
  * @category Map
  */
-const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({newLandmark, setNewLandmark, setVisible, visible}) => {
+const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({newLandmark, setNewLandmark, setVisible, visible, indoorLmLocImg}) => {
     const [photos, setPhotos] = useState<LMPhoto[]>([])
     const [photoSourceMenuOpened, togglePhotoSourceMenu] = useState<boolean>(false)
 
@@ -80,7 +81,7 @@ const AddLandmarkPanel: React.FC<AddLandmarkProps> = ({newLandmark, setNewLandma
      * Calls {@link addLandmarkAsync} from {@link useLandmarks} to initate the process of adding a landmark, then closes the modal.
      */
     const submit = async () => {
-        await addLandmarkAsync({landmarkValue: newLandmark, photos: photos})
+        await addLandmarkAsync({landmarkValue: newLandmark, photos: photos, indoorLmLocImg: indoorLmLocImg});
         close()
     }
 

+ 3 - 2
src/hooks/useLandmarks.ts

@@ -255,13 +255,14 @@ export const useLandmarks = (options?: UseLandmarkOptions) => {
      * The callback responsible for adding a new {@link Landmark} to the server, used by the [react-query useMutation]{@link https://react-query.tanstack.com/reference/useMutation#_top} hook.
      * * @memberOf useLandmarks
      */
-    const createLandmark = async (data: {landmarkValue: Landmark | undefined, photos?: LMPhoto[]}): Promise<Landmark | undefined> => {
+    const createLandmark = async (data: {landmarkValue: Landmark | undefined, photos?: LMPhoto[], indoorLmLocImg?: string}): Promise<Landmark | undefined> => {
         if (data.landmarkValue) {
             const config: AxiosRequestConfig = {
                 method: 'POST',
                 data: {
                     landmark: data.landmarkValue,
-                    photos: data.photos
+                    photos: data.photos,
+                    indoorLmLocImg: data.indoorLmLocImg
                 },
                 url: API_URL + `/api/landmark/`,
                 headers: { "Authorization": "Bearer " + authStore.accessToken, }