-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdashboard.ts
More file actions
23 lines (22 loc) · 843 Bytes
/
dashboard.ts
File metadata and controls
23 lines (22 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { BannerData } from "@/types/user";
import { getNotifications } from "./notifications";
import { getClaimInProgress } from "./company";
import { GetClaimInProgressForCompanyResponse } from "@/types/company";
export const getDashboardBannerData = async (): Promise<BannerData> => {
const disasterNotifications = await getNotifications({
type: "web",
page: 1,
limit: 1,
status: "unread",
});
if (disasterNotifications.length > 0) {
const disaster = disasterNotifications[0].femaDisaster;
const claim: GetClaimInProgressForCompanyResponse = await getClaimInProgress();
if (claim) {
return { status: "has-claim", disaster, claim };
} else {
return { status: "no-claim", disaster };
}
}
return { status: "no-disaster" };
};