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

This commit is contained in:
2025-04-20 07:40:31 +05:00
parent ac11fee754
commit ba91d2c8d4
5 changed files with 51 additions and 18 deletions

View File

@ -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,