Merge branch 'main' into tailwind

This commit is contained in:
Teodor Salvesen
2026-05-05 14:31:02 +02:00
committed by GitHub
40 changed files with 5882 additions and 769 deletions

View File

@@ -161,6 +161,7 @@ export default function UpsertSubject() {
<View className="mb-5">
<Text className={labelClassName}>Title</Text>
<TextInput className={inputClassName}
testID = "subject-title-input"
placeholder="Enter subject title"
placeholderTextColor="#9CA3AF"
value={title}
@@ -311,6 +312,7 @@ export default function UpsertSubject() {
</Pressable>
<Pressable
testID = "upsert-subject-button"
className={`h-14 items-center justify-center rounded-2xl ${
isSaving
? 'bg-accent-disabled'

View File

@@ -23,7 +23,7 @@ export default function ViewDetailsSubject() {
const [subject, SetSubject] = useState<Subject | null>(null);
const [assignments, SetAssignments] = useState<Assignment[]>([]);
const [session, SetSession] = useState<Session | null>(null);
const [isLoading, SetIsLoading] = useState(true);
const [isLoading, SetIsLoading] = useState(false);
const assignmentSections = [
{
@@ -49,12 +49,16 @@ export default function ViewDetailsSubject() {
}, []);
const GetSubject = async (subjectId: string) => {
SetIsLoading(true);
const { data, error } = await supabase
.from('subjects')
.select('*')
.eq('sId', subjectId)
.single();
SetIsLoading(false);
if (error) {
Alert.alert('Subject could not be fetched, please try again');
return;
@@ -64,12 +68,16 @@ export default function ViewDetailsSubject() {
};
const GetAssignments = async (subjectId: string) => {
SetIsLoading(true);
const { data, error } = await supabase
.from('assignments')
.select('*')
.eq('sId', subjectId)
.order('deadline', { ascending: true });
SetIsLoading(false);
if (error) {
Alert.alert('Assignments could not be fetched, please try again');
return;
@@ -119,20 +127,6 @@ export default function ViewDetailsSubject() {
}, [session, sId])
);
useEffect(() => {
const test = async () => {
try {
const { data, error } = await supabase.from('subjects').select('*').limit(1);
console.log('test data:', data);
console.log('test error:', error);
} catch (err) {
console.log('test crashed:', err);
}
};
test();
}, []);
const DeleteSubject = async (subjectId: string) => {
Alert.alert(
'Delete Subject',
@@ -391,7 +385,7 @@ export default function ViewDetailsSubject() {
className="mr-3 flex-1 items-center justify-center rounded-2xl border border-app-border bg-app-subtle py-3"
onPress={() =>
router.push({
pathname: '/subject/upsertSubject',
pathname: '../subject/upsertSubject',
params: { sId: subject.sId },
})
}
@@ -402,6 +396,7 @@ export default function ViewDetailsSubject() {
</Pressable>
<Pressable
testID="delete-subject-button"
className="flex-1 items-center justify-center rounded-2xl border border-app-border bg-app-surface py-3"
onPress={() => DeleteSubject(subject.sId)}
>
@@ -416,7 +411,7 @@ export default function ViewDetailsSubject() {
className="mb-6 mt-5 h-14 items-center justify-center rounded-2xl bg-accent"
onPress={() =>
router.push({
pathname: '/assignment/upsertAssignment',
pathname: '../assignment/upsertAssignment',
params: { sId: subject.sId },
})
}
@@ -502,7 +497,7 @@ export default function ViewDetailsSubject() {
className="mr-3 flex-1 items-center justify-center rounded-2xl border border-app-border bg-app-subtle py-3"
onPress={() =>
router.push({
pathname: '/assignment/upsertAssignment',
pathname: '../assignment/upsertAssignment',
params: { aId: item.aId },
})
}