'some' changes

This commit is contained in:
Chris Sanden
2026-05-03 23:05:22 +02:00
parent 08a14b3ab2
commit 907fa18841
21 changed files with 2253 additions and 220 deletions

View File

@@ -20,8 +20,9 @@ import {
export default function UpsertSubject() {
const { sId } = useLocalSearchParams<{ sId?: string }>();
const { sId, flow } = useLocalSearchParams<{ sId?: string; flow?: string }>();
const isEditMode = Boolean(sId);
const isSetupFlow = flow === 'setup';
const [title, setTitle] = useState('');
const [description, setDescription] = useState('');
@@ -88,7 +89,7 @@ export default function UpsertSubject() {
const result = isEditMode && sId
? await supabase.from('subjects').update(payload).eq('sId', sId)
: await supabase.from('subjects').insert(payload);
: await supabase.from('subjects').insert(payload).select().single();
setIsSaving(false);
@@ -101,6 +102,17 @@ export default function UpsertSubject() {
return;
}
if (!isEditMode && isSetupFlow && result.data?.sId) {
router.replace({
pathname: '/assignment/upsertAssignment',
params: {
sId: result.data.sId,
flow: 'setup',
},
});
return;
}
Alert.alert(
isEditMode ? 'Subject updated successfully!' : 'Subject created successfully!'
);
@@ -154,7 +166,7 @@ export default function UpsertSubject() {
</Text>
<Text className="mt-2 text-base leading-6 text-text-secondary">
{isEditMode? ' Update this subject and keep your study structure organized.'
: 'Add a subject to organize your assignments and studyt tasks.'}
: 'Add a subject to organize your assignments and study tasks.'}
</Text>
</View>
@@ -162,7 +174,7 @@ export default function UpsertSubject() {
<View className="mb-5">
<Text className={labelClassName}>Title</Text>
<TextInput className={inputClassName}
placeholder="Enter subject title"
placeholder={isSetupFlow ? 'e.g. Algorithms' : 'Enter subject title'}
placeholderTextColor="#9CA3AF"
value={title}
onChangeText={setTitle}
@@ -174,7 +186,7 @@ export default function UpsertSubject() {
<Text className={labelClassName}>Description</Text>
<TextInput
className={`${inputClassName} min-h-28`}
placeholder="Add a short description"
placeholder={isSetupFlow ? 'e.g. Lectures, problem sets, and exam prep' : 'Add a short description'}
placeholderTextColor="#9CA3AF"
value={description}
onChangeText={setDescription}
@@ -349,4 +361,4 @@ export default function UpsertSubject() {
</KeyboardAvoidingView>
</>
);
}
}

View File

@@ -288,7 +288,7 @@ export default function ViewDetailsSubject() {
<View className="mt-5">
<View className="mb-2 flex-row items-center justify-between">
<Text className="text-sm font-semibold text-text-secondary">
Assignment Progress
Assignments completed
</Text>
<Text className="text-sm font-bold text-text-main">
@@ -313,6 +313,10 @@ export default function ViewDetailsSubject() {
remainingAssignments === 1 ? '' : 's'
} remaining`}
</Text>
<Text className="mt-1 text-xs text-text-muted">
Based only on completed assignments in this subject.
</Text>
</View>
<Text className="mt-4 text-sm text-text-muted">
@@ -451,7 +455,9 @@ export default function ViewDetailsSubject() {
{section.emptyMessage}
</Text>
<Text className="mt-1 text-center text-sm text-text-muted">
Assignments for this subject will show up here.
{assignments.length === 0
? 'Create the first assignment to give this subject a real study path.'
: 'Assignments for this subject will show up here.'}
</Text>
</View>
) : (