fix: design in view profile and account overview
feat : page add for e mandate otp
This commit is contained in:
40
src/app/eMandate/authUtils.ts
Normal file
40
src/app/eMandate/authUtils.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
import { notifications } from "@mantine/notifications";
|
||||
|
||||
export const fetchUserDetails = async () => {
|
||||
try {
|
||||
const token = localStorage.getItem("mandate_token");
|
||||
|
||||
const response = await fetch("/api/customer", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"X-Login-Type": "eMandate",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error("Failed");
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (Array.isArray(data) && data.length > 0) {
|
||||
const name = data[0].custname;
|
||||
const mobile = data[0].mobileno;
|
||||
|
||||
localStorage.setItem("user_name", name);
|
||||
localStorage.setItem("userMobNo", mobile);
|
||||
|
||||
return { name, mobile };
|
||||
}
|
||||
} catch {
|
||||
notifications.show({
|
||||
title: "Please try again later",
|
||||
message: "Unable to fetch user details",
|
||||
color: "red",
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user