Compare commits

..

No commits in common. "7425b566d53793a37581da6361816075f9814e30" and "e151e51eb05fe835e9c6f3ab512357a38a3fe9ff" have entirely different histories.

2 changed files with 11 additions and 26 deletions

View File

@ -2,7 +2,6 @@ import React from "react";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import { import {
Portal, Portal,
Text,
} from "react-native-paper"; } from "react-native-paper";
import { createStackNavigator } from "@react-navigation/stack"; import { createStackNavigator } from "@react-navigation/stack";
@ -13,17 +12,6 @@ const Stack = createStackNavigator();
export default function Timetable({ addTimetableEntry, removeTimetableEntry, timetable, subjects }) { export default function Timetable({ addTimetableEntry, removeTimetableEntry, timetable, subjects }) {
const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
if (subjects.length === 0) {
return (
<Text
style={{
textAlign: "center",
marginTop: 12,
}}
>
No Subjects added. Add Subjects first.
</Text>);
}
return ( return (
<Portal.Host><Stack.Navigator headerMode="none"> <Portal.Host><Stack.Navigator headerMode="none">
<Stack.Screen name="Timetable"> <Stack.Screen name="Timetable">

View File

@ -47,22 +47,19 @@ function AddEntry({addTimetableEntry, days, day, subjects, navigation }) {
} }
function submit() { function submit() {
let message = ""; if (subject.id === null) {
if (subject.id === null) setSnackbar({ visible: true, message: "Missing subject." });
message = "Missing Subject"; return;
else if (start === null) } else if (start === null) {
message = "Missing start time."; setSnackbar({ visible: true, message: "Missing start time." });
else if (end === null) return;
message = "Missing end time."; } else if (end === null) {
else if (count === 0) setSnackbar({ visible: true, message: "Missing end time." });
message = "Missing count."; return;
} else if (count === 0) {
if (message !== "") { setSnackbar({ visible: true, message: "Missing count." });
setSnackbar({visible: true, message: message});
setTimeout(() => setSnackbar({ visible: false, message: null }), 2000);
return; return;
} }
addTimetableEntry(day, { addTimetableEntry(day, {
sub_id: subject.id, sub_id: subject.id,
count, count,