diff --git a/src/components/Api/Api.tsx b/src/components/Api/Api.tsx
index c3faa04..74b86d5 100644
--- a/src/components/Api/Api.tsx
+++ b/src/components/Api/Api.tsx
@@ -6,6 +6,7 @@ import {
OnboardingType,
PatchUserInfoType,
RegistrationType,
+ StudentStatusPatchType,
StudentStatusType,
} from "../../interfaces/Interfaces";
@@ -243,7 +244,7 @@ export async function GetStudentStatus() {
});
}
-export async function PatchStudentStatus(info: StudentStatusType) {
+export async function PatchStudentStatus(info: StudentStatusPatchType) {
const config = await GetConfig();
console.log(info);
return instance
diff --git a/src/components/GetDistance/GetDistanceFromUSTP.tsx b/src/components/GetDistance/GetDistanceFromUSTP.tsx
new file mode 100644
index 0000000..391df27
--- /dev/null
+++ b/src/components/GetDistance/GetDistanceFromUSTP.tsx
@@ -0,0 +1,20 @@
+import { LocationType } from "../../interfaces/Interfaces";
+import GetDistance from "./GetDistance";
+
+export default function GetDistanceFromUSTP(location: LocationType) {
+ const ustpCoords = {
+ latitude: 8.4857,
+ longitude: 124.6565,
+ latitudeDelta: 0.000235,
+ longitudeDelta: 0.000067,
+ };
+
+ let dist = GetDistance(
+ location.latitude,
+ location.longitude,
+ ustpCoords.latitude,
+ ustpCoords.longitude
+ );
+ dist = Math.round(dist);
+ return dist;
+}
diff --git a/src/components/MapRenderer/MapRendererFar.tsx b/src/components/MapRenderer/MapRendererFar.tsx
new file mode 100644
index 0000000..776df86
--- /dev/null
+++ b/src/components/MapRenderer/MapRendererFar.tsx
@@ -0,0 +1,79 @@
+import * as React from "react";
+import { View, Text } from "react-native";
+import MapView, { UrlTile, Callout, Marker } from "react-native-maps";
+import styles, { Viewport, colors } from "../../styles";
+import { urlProvider } from "../Api/Api";
+import { LocationType, RawLocationType } from "../../interfaces/Interfaces";
+import GetDistance from "../../components/GetDistance/GetDistance";
+
+type props = {
+ location: LocationType;
+ dist: any;
+};
+
+export default function MapRendererFar(props: props) {
+ return (
+
+
+ You are too far from USTP {"\n"}
+ Get closer to use Stud-E
+
+
+
+
+
+
+ You are here {"\n"}
+ X: {Math.round(props.location.longitude) + "\n"}
+ Z: {Math.round(props.location.latitude)}
+
+
+
+
+
+ {props.dist}km away from USTP {"\n"}
+
+
+ );
+}
diff --git a/src/interfaces/Interfaces.tsx b/src/interfaces/Interfaces.tsx
index ac42a41..7623b88 100644
--- a/src/interfaces/Interfaces.tsx
+++ b/src/interfaces/Interfaces.tsx
@@ -130,7 +130,13 @@ export interface LocationType {
}
export interface StudentStatusType {
- user?: string;
+ subject: string;
+ location: LocationType;
+ landmark: string | null;
+ active: boolean;
+}
+
+export interface StudentStatusPatchType {
subject?: string;
location?: LocationType;
landmark?: string | null;
diff --git a/src/routes/Home/Home.tsx b/src/routes/Home/Home.tsx
index f8bdf57..2a9cd8d 100644
--- a/src/routes/Home/Home.tsx
+++ b/src/routes/Home/Home.tsx
@@ -23,6 +23,7 @@ import {
StudentStatusListType,
subjectUserMapType,
StudentStatusFilterTypeFlattened,
+ StudentStatusPatchType,
} from "../../interfaces/Interfaces";
import { useNavigation } from "@react-navigation/native";
import {
@@ -34,14 +35,16 @@ import {
} from "../../components/Api/Api";
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
import { useToast } from "react-native-toast-notifications";
-import CustomMapCallout from "../../components/CustomMapCallout/CustomMapCallout";
import React from "react";
import ParseStudyGroupList from "../../components/ParseStudyGroupList/ParseStudyGroupList";
import ParseStudentStatusList from "../../components/ParseStudentStatusList/ParseStudentStatusList";
+import CustomMapCallout from "../../components/CustomMapCallout/CustomMapCallout";
+import MapRendererFar from "../../components/MapRenderer/MapRendererFar";
+import GetDistanceFromUSTP from "../../components/GetDistance/GetDistanceFromUSTP";
export default function Home() {
// Switch this condition to see the main map when debugging
- const map_debug = true;
+ const map_debug = false;
const navigation = useNavigation();
const [location, setLocation] = useState(null);
const [dist, setDist] = useState(null);
@@ -103,12 +106,7 @@ export default function Home() {
}, []);
async function GetDistanceRoundedOff(location: RawLocationType) {
- let dist = GetDistance(
- location.coords.latitude,
- location.coords.longitude,
- ustpCoords.latitude,
- ustpCoords.longitude
- );
+ let dist = GetDistanceFromUSTP(location.coords);
setDist(Math.round(dist));
// Deactivate student status if too far away
if (dist >= 2 && !map_debug)
@@ -154,7 +152,7 @@ export default function Home() {
});
const mutation = useMutation({
- mutationFn: async (info: StudentStatusType) => {
+ mutationFn: async (info: StudentStatusPatchType) => {
const data = await PatchStudentStatus(info);
if (data[0] != true) {
return Promise.reject(new Error());
@@ -426,70 +424,7 @@ export default function Home() {
);
} else {
- return (
-
-
- You are too far from USTP {"\n"}
- Get closer to use Stud-E
-
-
-
-
-
-
- You are here {"\n"}
- X: {Math.round(location.coords.longitude) + "\n"}
- Z: {Math.round(location.coords.latitude)}
-
-
-
-
-
- {dist}km away from USTP {"\n"}
-
-
- );
+ return ;
}
} else {
requestLocation();