-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : add getTransactions helper method
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"use server"; | ||
import { getSessionToken } from "../sessions/sessionUtils"; | ||
import getBaseUrl from "@utils/getBaseUrl"; | ||
|
||
export default async function getTransactions() { | ||
const session = getSessionToken(); | ||
const serverUrl = getBaseUrl(); | ||
|
||
const headers = { | ||
Authorization: `Bearer ${session}`, | ||
}; | ||
try { | ||
const res = await fetch(`${serverUrl}/api/admin/transactions`, { | ||
headers, | ||
// cache: "no-cache", | ||
}); | ||
|
||
if (!res.ok) { | ||
console.error(`Error fetching transactions data: ${res.statusText}`); | ||
throw new Error("fetching transactions data"); | ||
} | ||
|
||
const transactionsData = await res.json(); | ||
|
||
return transactionsData; | ||
} catch (error) { | ||
console.error("An error occurred while fetching transactions data:", error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
import addAdmin from "./addAdmin"; | ||
import getAdminData from "./getAdminData"; | ||
import { getTilesData, getRecentUsersData } from "./getDashboardData"; | ||
import getTransactions from "./getTransactions"; | ||
|
||
export { addAdmin, getAdminData, getTilesData, getRecentUsersData }; | ||
export { | ||
addAdmin, | ||
getAdminData, | ||
getTilesData, | ||
getRecentUsersData, | ||
getTransactions, | ||
}; |