mirror of
https://github.com/lemeow125/StudE-Frontend.git
synced 2025-05-17 03:48:06 +08:00
Added subject selection for irregular students
This commit is contained in:
parent
473291646c
commit
eb08e02a16
6 changed files with 126 additions and 39 deletions
|
@ -9,12 +9,15 @@ import {
|
|||
StudentData,
|
||||
} from "../../interfaces/Interfaces";
|
||||
|
||||
let debug = true;
|
||||
export let backendURL = "";
|
||||
if (debug) {
|
||||
export let backendURLWebsocket = "";
|
||||
let use_production = true;
|
||||
if (__DEV__ || !use_production) {
|
||||
backendURL = "http://10.0.10.8:8000";
|
||||
backendURLWebsocket = "ws://10.0.10.8:8000";
|
||||
} else {
|
||||
backendURL = "https://keannu125.pythonanywhere.com";
|
||||
backendURL = "https://stude.keannu1.duckdns.org";
|
||||
backendURLWebsocket = "ws://stude.keannu1.duckdns.org";
|
||||
}
|
||||
|
||||
const instance = axios.create({
|
||||
|
@ -220,26 +223,46 @@ export async function GetYearLevels() {
|
|||
}
|
||||
|
||||
export async function GetSubjects(
|
||||
byCourseOnly: boolean,
|
||||
course: string,
|
||||
year_level: string,
|
||||
semester: string
|
||||
year_level?: string,
|
||||
semester?: string
|
||||
) {
|
||||
const config = await GetConfig();
|
||||
return instance
|
||||
.get(
|
||||
"/api/v1/subjects/" + course + "/" + year_level + "/" + semester,
|
||||
config
|
||||
)
|
||||
.then((response) => {
|
||||
// console.log(JSON.stringify(response.data));
|
||||
return [true, response.data];
|
||||
})
|
||||
.catch((error) => {
|
||||
let error_message = "";
|
||||
if (error.response) error_message = error.response.data;
|
||||
else error_message = "Unable to reach servers";
|
||||
return [false, error_message];
|
||||
});
|
||||
console.log("by course only?", byCourseOnly);
|
||||
// If year level and semester specified,
|
||||
if (!byCourseOnly && year_level && semester) {
|
||||
return instance
|
||||
.get(
|
||||
"/api/v1/subjects/" + course + "/" + year_level + "/" + semester,
|
||||
config
|
||||
)
|
||||
.then((response) => {
|
||||
// console.log(JSON.stringify(response.data));
|
||||
return [true, response.data];
|
||||
})
|
||||
.catch((error) => {
|
||||
let error_message = "";
|
||||
if (error.response) error_message = error.response.data;
|
||||
else error_message = "Unable to reach servers";
|
||||
return [false, error_message];
|
||||
});
|
||||
}
|
||||
// If only course is specified
|
||||
else {
|
||||
return instance
|
||||
.get("/api/v1/subjects/" + course, config)
|
||||
.then((response) => {
|
||||
// console.log(JSON.stringify(response.data));
|
||||
return [true, response.data];
|
||||
})
|
||||
.catch((error) => {
|
||||
let error_message = "";
|
||||
if (error.response) error_message = error.response.data;
|
||||
else error_message = "Unable to reach servers";
|
||||
return [false, error_message];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function OnboardingUpdateStudentInfo(info: OnboardingParams) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import LogoutIcon from "../../icons/LogoutIcon/LogoutIcon";
|
|||
import { logout } from "../../features/redux/slices/StatusSlice/StatusSlice";
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import UserIcon from "../../icons/UserIcon/UserIcon";
|
||||
import SubjectIcon from "../../icons/SubjectIcon/SubjectIcon";
|
||||
|
||||
export default function CustomDrawerContent(props: {}) {
|
||||
const navigation = useNavigation<RootDrawerParamList>();
|
||||
|
@ -80,7 +81,7 @@ export default function CustomDrawerContent(props: {}) {
|
|||
navigation.navigate("Subjects");
|
||||
}}
|
||||
>
|
||||
<UserIcon size={32} />
|
||||
<SubjectIcon size={32} />
|
||||
<Text style={styles.text_white_medium}>Subjects</Text>
|
||||
</DrawerButton>
|
||||
<DrawerButton
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue