mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-05-18 20:08:19 +00:00
feat: add auth and data providers with mock data hooks
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
42
src/hooks/use-follow-ups.ts
Normal file
42
src/hooks/use-follow-ups.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import type { FollowUp } from '@/types/entities';
|
||||
import { useData } from '@/providers/data-provider';
|
||||
|
||||
type UseFollowUpsResult = {
|
||||
followUps: FollowUp[];
|
||||
overdue: FollowUp[];
|
||||
upcoming: FollowUp[];
|
||||
};
|
||||
|
||||
export const useFollowUps = (): UseFollowUpsResult => {
|
||||
const { followUps } = useData();
|
||||
|
||||
const now = useMemo(() => new Date(), []);
|
||||
|
||||
const overdue = useMemo(() => {
|
||||
return followUps.filter((followUp) => {
|
||||
if (followUp.followUpStatus === 'OVERDUE') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (followUp.followUpStatus === 'PENDING' && followUp.scheduledAt !== null) {
|
||||
return new Date(followUp.scheduledAt) < now;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}, [followUps, now]);
|
||||
|
||||
const upcoming = useMemo(() => {
|
||||
return followUps.filter((followUp) => {
|
||||
return followUp.followUpStatus === 'PENDING' && followUp.scheduledAt !== null && new Date(followUp.scheduledAt) >= now;
|
||||
});
|
||||
}, [followUps, now]);
|
||||
|
||||
return {
|
||||
followUps,
|
||||
overdue,
|
||||
upcoming,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user