mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-07-03 00:38:23 +00:00
feat: add getProfile function and integrate user profile retrieval in payment and layout components
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m47s
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 1m47s
This commit is contained in:
@ -9,7 +9,7 @@ import type {
|
||||
} from "@/lib/backend-types";
|
||||
import type { User } from "@/lib/types/user";
|
||||
import { checkSession } from "@/utils/session";
|
||||
import { tryCatch } from "@/utils/tryCatch";
|
||||
import { handleApiResponse, tryCatch } from "@/utils/tryCatch";
|
||||
import { getServerSession } from "next-auth";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { redirect } from "next/navigation";
|
||||
@ -201,6 +201,22 @@ type VerifyPaymentType = {
|
||||
type?: "TRANSFER" | "WALLET";
|
||||
};
|
||||
|
||||
export async function getProfile() {
|
||||
const session = await getServerSession(authOptions);
|
||||
const response = await fetch(
|
||||
`${process.env.SARLINK_API_BASE_URL}/api/auth/profile/`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Authorization: `Token ${session?.apiToken}`,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return handleApiResponse<User>(response, "getProfile");
|
||||
}
|
||||
|
||||
export async function processWalletPayment({
|
||||
payment,
|
||||
amount,
|
||||
|
Reference in New Issue
Block a user