Skip to content
Merged
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
20 changes: 17 additions & 3 deletions src/app/hooks/useStudyGroups.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
'use client';

import { useCallback, useEffect, useMemo, useState } from 'react';
Expand Down Expand Up @@ -89,7 +87,9 @@ const STORAGE_KEYS = {
certificates: 'sl_group_certificates_v1',
};

function getCertificateStatus(certificate: Pick<ForumCertificate, 'validUntil' | 'revokedAt'>) {
function getCertificateStatus(
certificate: Pick<ForumCertificate, 'validUntil' | 'revokedAt'>,
): ForumCertificateStatus {
if (certificate.revokedAt) return 'revoked';
return new Date(certificate.validUntil).getTime() < Date.now() ? 'expired' : 'active';
}
Expand Down Expand Up @@ -265,7 +265,9 @@ export function useStudyGroups(currentUser?: { id: string; name: string }): UseS
const { addNotification } = useNotificationStore.getState();
addNotification({
type: 'success',
title: 'Group Created',
message: `Created group "${group.name}"`,
timestamp: new Date(),
meta: { groupId: group.id },
});
} catch {}
Expand Down Expand Up @@ -294,7 +296,9 @@ export function useStudyGroups(currentUser?: { id: string; name: string }): UseS
const { addNotification } = useNotificationStore.getState();
addNotification({
type: 'info',
title: 'Group Joined',
message: `You joined "${groupName || 'group'}"`,
timestamp: new Date(),
meta: { groupId },
});
} catch {}
Expand Down Expand Up @@ -322,7 +326,9 @@ export function useStudyGroups(currentUser?: { id: string; name: string }): UseS
const { addNotification } = useNotificationStore.getState();
addNotification({
type: 'warning',
title: 'Group Left',
message: `You left "${groupName || 'group'}"`,
timestamp: new Date(),
meta: { groupId },
});
} catch {}
Expand Down Expand Up @@ -354,7 +360,9 @@ export function useStudyGroups(currentUser?: { id: string; name: string }): UseS
const group = groups.find((g) => g.id === groupId);
addNotification({
type: 'info',
title: 'New Message',
message: `New message in "${group?.name || 'group'}"`,
timestamp: new Date(),
meta: { groupId, messageId: msg.id },
});
} catch {}
Expand Down Expand Up @@ -446,7 +454,9 @@ export function useStudyGroups(currentUser?: { id: string; name: string }): UseS
const group = groups.find((g) => g.id === groupId);
addNotification({
type: 'success',
title: 'Resource Added',
message: `New resource "${resource.title}" added to "${group?.name || 'group'}"`,
timestamp: new Date(),
meta: { groupId, resourceId: res.id },
});
} catch {}
Expand Down Expand Up @@ -480,7 +490,9 @@ export function useStudyGroups(currentUser?: { id: string; name: string }): UseS
const group = groups.find((g) => g.id === groupId);
addNotification({
type: 'success',
title: 'Challenge Created',
message: `New challenge "${challenge.title}" created in "${group?.name || 'group'}"`,
timestamp: new Date(),
meta: { groupId, challengeId: ch.id },
});
} catch {}
Expand Down Expand Up @@ -524,9 +536,11 @@ export function useStudyGroups(currentUser?: { id: string; name: string }): UseS
const group = groups.find((g) => g.id === groupId);
addNotification({
type: 'info',
title: 'Progress Updated',
message: `Progress updated for "${challengeTitle || 'challenge'}" in "${
group?.name || 'group'
}"`,
timestamp: new Date(),
meta: { challengeId, groupId },
});
} catch {}
Expand Down
Loading