Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated check for token #42

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/headerV2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All changes to this project will be documented in this file.

## [0.1.15] - 11-11-2024

- Updated token expiration check

## [0.1.14] - 07-07-2024

- Replace Howler with audio
Expand Down
2 changes: 1 addition & 1 deletion src/headerV2/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@buerokratt-ria/header",
"version": "0.1.14",
"version": "0.1.15",
"description": "Generic Header component that would be injected as dependency.",
"main": "index.ts",
"scripts": {},
Expand Down
113 changes: 61 additions & 52 deletions src/headerV2/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,17 @@ const Header: FC<PropsWithChildren<UserStoreStateProps>> = ({ user, toastContext
) {
const expirationDate = new Date(parseInt(expirationTimeStamp) ?? "");
const currentDate = new Date(Date.now());
if (expirationDate < currentDate) {
if (expirationDate < currentDate && !useStore.getState().chatCsaActive && useStore.getState().csaStatus !== 'online') {
localStorage.removeItem("exp");
window.location.href =
import.meta.env.REACT_APP_CUSTOMER_SERVICE_LOGIN;
logoutMutation.mutate();
}
} else {
localStorage.removeItem("exp");
logoutMutation.mutate();
}
}, 2000);
}, 10000);
return () => clearInterval(interval);
}, [userInfo]);
}, []);

useEffect(() => {
getMessages();
Expand Down Expand Up @@ -196,7 +198,10 @@ const Header: FC<PropsWithChildren<UserStoreStateProps>> = ({ user, toastContext
});

const logoutMutation = useMutation({
mutationFn: () => apiDev.get("accounts/logout"),
mutationFn: () => {
apiDev.get("accounts/logout")
console.log('triggered logout')
},
onSuccess(_: any) {
window.location.href = import.meta.env.REACT_APP_CUSTOMER_SERVICE_LOGIN;
},
Expand All @@ -219,6 +224,8 @@ const Header: FC<PropsWithChildren<UserStoreStateProps>> = ({ user, toastContext
customerSupportId: customerSupportActivity.idCode,
customerSupportStatus: "idle",
});

extendUserSessionMutation.mutate();
};

const onActive = () => {
Expand All @@ -233,6 +240,8 @@ const Header: FC<PropsWithChildren<UserStoreStateProps>> = ({ user, toastContext
customerSupportId: customerSupportActivity.idCode,
customerSupportStatus: "online",
});

extendUserSessionMutation.mutate();
};

useIdleTimer({
Expand Down Expand Up @@ -437,54 +446,54 @@ const Header: FC<PropsWithChildren<UserStoreStateProps>> = ({ user, toastContext
].some((auth) => userInfo.authorities.includes(auth)) && (
<>
{
isHiddenFeaturesEnabled && (
<Section>
<Track gap={8} direction="vertical" align="left">
<p className="h6">{t("settings.users.autoCorrector")}</p>
<SwitchBox
name="useAutocorrect"
label={t("settings.users.useAutocorrect")}
checked={userProfileSettings.useAutocorrect}
onCheckedChange={(checked) =>
handleUserProfileSettingsChange("useAutocorrect", checked)
}
/>
</Track>
</Section>
)
isHiddenFeaturesEnabled && (
<Section>
<Track gap={8} direction="vertical" align="left">
<p className="h6">{t("settings.users.autoCorrector")}</p>
<SwitchBox
name="useAutocorrect"
label={t("settings.users.useAutocorrect")}
checked={userProfileSettings.useAutocorrect}
onCheckedChange={(checked) =>
handleUserProfileSettingsChange("useAutocorrect", checked)
}
/>
</Track>
</Section>
)
}
{
isHiddenFeaturesEnabled && (
<Section>
<Track gap={8} direction="vertical" align="left">
<p className="h6">{t("settings.users.emailNotifications")}</p>
<SwitchBox
name="forwardedChatEmailNotifications"
label={t("settings.users.newForwardedChat")}
checked={
userProfileSettings.forwardedChatEmailNotifications
}
onCheckedChange={(checked) =>
handleUserProfileSettingsChange(
"forwardedChatEmailNotifications",
checked
)
}
/>
<SwitchBox
name="newChatEmailNotifications"
label={t("settings.users.newUnansweredChat")}
checked={userProfileSettings.newChatEmailNotifications}
onCheckedChange={(checked) =>
handleUserProfileSettingsChange(
"newChatEmailNotifications",
checked
)
}
/>
</Track>
</Section>
)
isHiddenFeaturesEnabled && (
<Section>
<Track gap={8} direction="vertical" align="left">
<p className="h6">{t("settings.users.emailNotifications")}</p>
<SwitchBox
name="forwardedChatEmailNotifications"
label={t("settings.users.newForwardedChat")}
checked={
userProfileSettings.forwardedChatEmailNotifications
}
onCheckedChange={(checked) =>
handleUserProfileSettingsChange(
"forwardedChatEmailNotifications",
checked
)
}
/>
<SwitchBox
name="newChatEmailNotifications"
label={t("settings.users.newUnansweredChat")}
checked={userProfileSettings.newChatEmailNotifications}
onCheckedChange={(checked) =>
handleUserProfileSettingsChange(
"newChatEmailNotifications",
checked
)
}
/>
</Track>
</Section>
)
}
<Section>
<Track gap={8} direction="vertical" align="left">
Expand Down