Skip to content

Commit

Permalink
frontend: Revert to 0.1.3 state
Browse files Browse the repository at this point in the history
  • Loading branch information
allgood committed May 19, 2024
1 parent bd35e20 commit d003688
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 49 deletions.
26 changes: 7 additions & 19 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,13 @@ const App = () => {
}, [mode]);

useEffect(() => {
getPublicSetting("primaryColorLight")
.then((color) => { color && setPrimaryColorLight(color) })
.catch((error) => { console.log("Error reading setting", error); });
getPublicSetting("primaryColorDark")
.then((color) => { color && setPrimaryColorDark(color) })
.catch((error) => { console.log("Error reading setting", error); });
getPublicSetting("appLogoLight")
.then((file) => { file && setAppLogoLight(file) }, (_) => { })
.catch((error) => { console.log("Error reading setting", error); });
getPublicSetting("appLogoDark")
.then((file) => { file && setAppLogoDark(file) })
.catch((error) => { console.log("Error reading setting", error); });
getPublicSetting("appLogoFavicon")
.then((file) => { file && setAppLogoFavicon(file) })
.catch((error) => { console.log("Error reading setting", error); });
getPublicSetting("appName").then((name) => { setAppName(name || "ticketz") })
.catch((error) => { console.log("Error reading setting", error); setAppName("whitelabel chat") });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
getPublicSetting("primaryColorLight").then((color) => { color && setPrimaryColorLight(color) });
getPublicSetting("primaryColorDark").then((color) => { color && setPrimaryColorDark(color) });
getPublicSetting("appLogoLight").then((file) => { file && setAppLogoLight(file)});
getPublicSetting("appLogoDark").then((file) => { file && setAppLogoDark(file)});
getPublicSetting("appLogoFavicon").then((file) => { file && setAppLogoFavicon(file)});
getPublicSetting("appName").then((name) => { setAppName(name || "ticketz")});
}, [getPublicSetting]);

return (
<>
Expand Down
9 changes: 2 additions & 7 deletions frontend/src/context/Socket/SocketContext.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createContext } from "react";
import openSocket from "socket.io-client";
import { getBackendURL } from "../../services/config";
import { isExpired } from "react-jwt";
import { isExpired, decodeToken } from "react-jwt";

class ManagedSocket {
constructor(socketManager) {
Expand Down Expand Up @@ -106,13 +106,8 @@ const socketManager = {
}

if ( isExpired(token) ) {
console.warn("Expired token, waiting for refresh");
console.warn("Expired token, reload after refresh");
setTimeout(() => {
const currentToken = JSON.parse(localStorage.getItem("token"));
if (isExpired(currentToken)) {
localStorage.removeItem("token");
localStorage.removeItem("companyId");
}
window.location.reload();
},1000);
return new DummySocket();
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/hooks/useAuth.js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const useAuth = () => {
setIsAuth(true);
setUser(data.user);
} catch (err) {
toastError(err?.message);
toastError(err);
}
}
setLoading(false);
Expand Down Expand Up @@ -152,7 +152,7 @@ Entre em contato com o Suporte para mais informações! `);

//quebra linha
} catch (err) {
toastError(err?.message);
toastError(err);
setLoading(false);
}
};
Expand All @@ -172,7 +172,7 @@ Entre em contato com o Suporte para mais informações! `);
setLoading(false);
history.push("/login");
} catch (err) {
toastError(err?.message);
toastError(err);
setLoading(false);
}
};
Expand All @@ -182,7 +182,7 @@ Entre em contato com o Suporte para mais informações! `);
const { data } = await api.get("/auth/me");
return data;
} catch (err) {
toastError(err?.message);
toastError(err);
}
};

Expand Down
35 changes: 19 additions & 16 deletions frontend/src/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import Brightness4Icon from '@material-ui/icons/Brightness4';
import Brightness7Icon from '@material-ui/icons/Brightness7';
import LanguageIcon from '@material-ui/icons/Language';
import { getBackendURL } from "../services/config";
import NestedMenuItem from "material-ui-nested-menu-item";

const drawerWidth = 240;

Expand Down Expand Up @@ -301,6 +300,11 @@ const LoggedInLayout = ({ children, themeToggle }) => {
setMenuOpen(true);
};

const handleLanguageMenu = (event) => {
setAnchorEl(event.currentTarget);
setLanguageOpen(true);
};

const handleCloseProfileMenu = () => {
setAnchorEl(null);
setMenuOpen(false);
Expand Down Expand Up @@ -423,6 +427,10 @@ const LoggedInLayout = ({ children, themeToggle }) => {
)}
</Typography>

<IconButton edge="start" onClick={toggleColorMode}>
{theme.mode === 'dark' ? <Brightness7Icon style={{ color: "white" }} /> : <Brightness4Icon style={{ color: "white" }} />}
</IconButton>

<NotificationsVolume
setVolume={setVolume}
volume={volume}
Expand All @@ -435,6 +443,16 @@ const LoggedInLayout = ({ children, themeToggle }) => {
<ChatPopover />

<div>
<IconButton
aria-label="current language"
aria-controls="menu-language"
aria-haspopup="true"
onClick={handleLanguageMenu}
variant="contained"
style={{ color: "white" }}
>
<LanguageIcon />
</IconButton>
<Menu
id="language-appbar"
anchorEl={anchorEl}
Expand Down Expand Up @@ -490,21 +508,6 @@ const LoggedInLayout = ({ children, themeToggle }) => {
<MenuItem onClick={handleOpenUserModal}>
{i18n.t("mainDrawer.appBar.user.profile")}
</MenuItem>
<MenuItem onClick={toggleColorMode}>
{theme.mode === 'dark' ? i18n.t("mainDrawer.appBar.user.lightmode") : i18n.t("mainDrawer.appBar.user.darkmode")}
</MenuItem>
<NestedMenuItem
label={i18n.t("mainDrawer.appBar.user.language")}
parentMenuOpen={menuOpen}
>
{
Object.keys(messages).map((m) => (
<MenuItem onClick={() => handleChooseLanguage(m)}>
{messages[m].translations.mainDrawer.appBar.i18n.language}
</MenuItem>
))
}
</NestedMenuItem>
<MenuItem onClick={handleOpenAboutModal}>
{i18n.t("about.aboutthe")} {currentUser?.super ? "ticketz" : theme.appName}
</MenuItem>
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/pages/Login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ const Login = () => {
(data) => {
setAllowSignup(data === "enabled");
}
).catch((error) => {
console.log("Error reading setting",error);
});
)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down

0 comments on commit d003688

Please sign in to comment.