init: Init React Application
This commit is contained in:
27
src/shared/lib/DecodeJWT/index.ts
Normal file
27
src/shared/lib/DecodeJWT/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export const decodeJWT = (token?: string): any | null => {
|
||||
if (!token) {
|
||||
console.error("No token provided");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
const base64Url = token.split(".")[1];
|
||||
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
||||
const jsonPayload = decodeURIComponent(
|
||||
atob(base64)
|
||||
.split("")
|
||||
.map((c) => `%${("00" + c.charCodeAt(0).toString(16)).slice(-2)}`)
|
||||
.join("")
|
||||
);
|
||||
|
||||
const decodedPayload: any = JSON.parse(jsonPayload);
|
||||
|
||||
if (decodedPayload.exp && Date.now() >= decodedPayload.exp * 1000) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return decodedPayload;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
2
src/shared/lib/index.ts
Normal file
2
src/shared/lib/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./mui/theme";
|
||||
export * from "./DecodeJWT";
|
||||
17
src/shared/lib/mui/theme.ts
Normal file
17
src/shared/lib/mui/theme.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { createTheme } from "@mui/material/styles";
|
||||
|
||||
export const theme = createTheme({
|
||||
// You can customize your theme here
|
||||
palette: {
|
||||
mode: "light",
|
||||
},
|
||||
components: {
|
||||
MuiDrawer: {
|
||||
styleOverrides: {
|
||||
paper: {
|
||||
backgroundColor: "#fff",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user