Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/(features)/attendance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default function AttendanceView() {

if (!selectedPeriod) {
error(t("Attendance_InvalidPeriod"))
return;
}

const manager = getManager()
Expand Down
11 changes: 9 additions & 2 deletions app/(tabs)/index/atoms/HomeHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const HomeHeader = () => {
const mutateProperty = useSettingsStore(state => state.mutateProperty);
const currentVersion = packageJson.version;
const releaseNotesUrl = `https://papillon.bzh/release-notes/${currentVersion}`;
const currentAttendancePeriod = attendancesPeriods.length > 0
? getCurrentPeriod(attendancesPeriods)
: undefined;

useEffect(() => {
const installedVersion = settingsStore.installedVersion;
Expand Down Expand Up @@ -78,11 +81,15 @@ const HomeHeader = () => {
(absencesCount > 1 ? t("Home_Attendance_Button_Description_Number", { number: absencesCount }) : t("Home_Attendance_Button_Description_Singular"))
: t("Home_Attendance_Button_Description_None"),
onPress: () => {
if (!currentAttendancePeriod) {
return;
}

router.push({
pathname: "/(features)/attendance",
params: {
periods: JSON.stringify(attendancesPeriods),
currentPeriod: JSON.stringify(getCurrentPeriod(attendancesPeriods)),
currentPeriod: JSON.stringify(currentAttendancePeriod),
attendances: JSON.stringify(attendances),
},
});
Expand All @@ -99,7 +106,7 @@ const HomeHeader = () => {
router.push("/(features)/soon");
}
}
], [availableCanteenCards, absencesCount, chats, attendancesPeriods, attendances, t]);
], [availableCanteenCards, absencesCount, chats, currentAttendancePeriod, attendancesPeriods, attendances, t]);

return (
<View style={{ paddingHorizontal: 0, width: "100%", flex: 1 }}>
Expand Down
8 changes: 7 additions & 1 deletion app/(tabs)/index/hooks/useHomeHeaderData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ export const useHomeHeaderData = () => {

const updateAttendance = async (manager: AccountManager) => {
const periods = await manager.getAttendancePeriods();
attendancesPeriodsRef.current = periods;

const currentPeriod = getCurrentPeriod(periods);
if (!currentPeriod) {
setAttendances([]);
return;
}

const fetchedAttendances = await manager.getAttendanceForPeriod(currentPeriod.name);

attendancesPeriodsRef.current = periods;
setAttendances(fetchedAttendances);
};

Expand Down
Loading