🔧 fix(authContext.tsx): remove unused refreshAccessToken function to improve code readability and maintainability

🔧 fix(tabsContext.tsx): remove unnecessary console.error statements to improve code readability and maintainability
🔧 fix(genericModal/index.tsx): remove unnecessary console.log statement to improve code readability and maintainability
🔧 fix(ApiKeysPage/index.tsx): remove unnecessary console.log statement to improve code readability and maintainability
🔧 fix(auth.ts): remove unused refreshAccessToken function type to improve code readability and maintainability
This commit is contained in:
Cristhian Zanforlin Lousa 2023-08-28 17:56:24 -03:00
commit 0a2ced4e60
5 changed files with 0 additions and 31 deletions

View file

@ -13,7 +13,6 @@ const initialValue: AuthContextType = {
refreshToken: null,
login: () => {},
logout: () => {},
refreshAccessToken: () => Promise.resolve(),
userData: null,
setUserData: () => {},
getAuthentication: () => false,
@ -98,29 +97,6 @@ export function AuthProvider({ children }): React.ReactElement {
setIsAuthenticated(false);
}
async function refreshAccessToken(refreshToken: string) {
try {
const response = await fetch("/api/refresh-token", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ refreshToken }),
});
if (response.ok) {
const data = await response.json();
login(data.accessToken, refreshToken);
getLoggedUser().then((user) => {
console.log("oi");
});
} else {
logout();
}
} catch (error) {
logout();
}
}
return (
// !! to convert string to boolean
@ -133,7 +109,6 @@ export function AuthProvider({ children }): React.ReactElement {
refreshToken,
login,
logout,
refreshAccessToken,
setUserData,
userData,
getAuthentication,

View file

@ -122,7 +122,6 @@ export function TabsProvider({ children }: { children: ReactNode }) {
processDBData(DbData);
updateStateWithDbData(DbData);
} catch (e) {
console.error(e);
}
}
});
@ -152,7 +151,6 @@ export function TabsProvider({ children }: { children: ReactNode }) {
processFlowEdges(flow);
processFlowNodes(flow);
} catch (e) {
console.error(e);
}
});
}
@ -486,7 +484,6 @@ export function TabsProvider({ children }: { children: ReactNode }) {
return id;
} catch (error) {
// Handle the error if needed
console.error("Error while adding flow:", error);
throw error; // Re-throw the error so the caller can handle it if needed
}
} else {

View file

@ -147,7 +147,6 @@ export default function GenericModal({
}
})
.catch((error) => {
console.log(error);
setIsEdit(true);
return setErrorData({
title: "There is something wrong with this prompt, please review it",

View file

@ -199,7 +199,6 @@ export default function ApiKeysPage() {
data={api_keys.id}
index={index}
onConfirm={(index, keys) => {
console.log(keys);
handleDeleteKey(keys);
}}
>

View file

@ -8,7 +8,6 @@ export type AuthContextType = {
refreshToken: string | null;
login: (accessToken: string, refreshToken: string) => void;
logout: () => void;
refreshAccessToken: (refreshToken: string) => Promise<void>;
userData: Users | null;
setUserData: (userData: Users | null) => void;
getAuthentication: () => boolean;