Skip to content

Commit

Permalink
Iniciar com o menu lateral fechado
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh authored Apr 5, 2022
1 parent 938c341 commit 13b22af
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ module.exports = {
createdAt: new Date(),
updatedAt: new Date()
},
{
key: "sideMenu",
value: "disabled",
createdAt: new Date(),
updatedAt: new Date()
},
{
key: "timeCreateNewTicket",
value: "10",
Expand Down
19 changes: 17 additions & 2 deletions frontend/src/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { AuthContext } from "../context/Auth/AuthContext";
import BackdropLoading from "../components/BackdropLoading";
import { i18n } from "../translate/i18n";

import api from "../services/api";
import toastError from "../errors/toastError";
import logodash from "../assets/logo-dash.png";

const drawerWidth = 240;
Expand Down Expand Up @@ -122,8 +124,21 @@ const LoggedInLayout = ({ children }) => {
const { user } = useContext(AuthContext);

useEffect(() => {
if (document.body.offsetWidth < 100) {
setDrawerOpen(true);
if (document.body.offsetWidth > 600) {
const fetchDrawerState = async () => {
try {
const { data } = await api.get("/settings");

const settingIndex = data.filter(s => s.key === 'sideMenu');

setDrawerOpen(settingIndex[0].value === "disabled" ? false : true);

} catch (err) {
setDrawerOpen(true);
toastError(err);
}
};
fetchDrawerState();
}
}, []);

Expand Down
137 changes: 84 additions & 53 deletions frontend/src/pages/Settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,90 @@ const Settings = () => {
</option>
</Select>
</Paper>


<Typography variant="body2" gutterBottom></Typography>
<Tooltip title={i18n.t("settings.settings.call.note")}>
<Paper className={classes.paper}>

<Typography variant="body1">
{i18n.t("settings.settings.call.name")}
</Typography>
<Select
margin="dense"
variant="outlined"
native
id="call-setting"
name="call"
value={
settings && settings.length > 0 && getSettingValue("call")
}
className={classes.settingOption}
onChange={handleChangeSetting}
>
<option value="enabled">
{i18n.t("settings.settings.call.options.enabled")}
</option>
<option value="disabled">
{i18n.t("settings.settings.call.options.disabled")}
</option>
</Select>
</Paper>
</Tooltip>

<Typography variant="body2" gutterBottom></Typography>
<Paper className={classes.paper}>
<Typography variant="body1">
{i18n.t("settings.settings.CheckMsgIsGroup.name")}
</Typography>
<Select
margin="dense"
variant="outlined"
native
id="CheckMsgIsGroup-setting"
name="CheckMsgIsGroup"
value={
settings && settings.length > 0 && getSettingValue("CheckMsgIsGroup")
}
className={classes.settingOption}
onChange={handleChangeSetting}
>
<option value="enabled">
{i18n.t("settings.settings.CheckMsgIsGroup.options.enabled")}
</option>
<option value="disabled">
{i18n.t("settings.settings.CheckMsgIsGroup.options.disabled")}
</option>
</Select>
</Paper>

<Typography variant="body2" gutterBottom></Typography>
<Tooltip title={i18n.t("settings.settings.sideMenu.note")}>
<Paper className={classes.paper} elevation={3}>
<Typography variant="body1">
{i18n.t("settings.settings.sideMenu.name")}
</Typography>
<Select
margin="dense"
variant="outlined"
native
id="sideMenu-setting"
name="sideMenu"
value={
settings && settings.length > 0 && getSettingValue("sideMenu")
}
className={classes.settingOption}
onChange={handleChangeSetting}
>
<option value="enabled">
{i18n.t("settings.settings.sideMenu.options.enabled")}
</option>
<option value="disabled">
{i18n.t("settings.settings.sideMenu.options.disabled")}
</option>
</Select>
</Paper>
</Tooltip>

<Typography variant="body2" gutterBottom></Typography>
<Tooltip title={i18n.t("settings.settings.timeCreateNewTicket.note")}>
<Paper className={classes.paper} elevation={3}>
Expand Down Expand Up @@ -174,58 +257,6 @@ const Settings = () => {
</Paper>
</Tooltip>

<Typography variant="body2" gutterBottom></Typography>
<Paper className={classes.paper}>

<Typography variant="body1">
{i18n.t("settings.settings.call.name")}
</Typography>
<Select
margin="dense"
variant="outlined"
native
id="call-setting"
name="call"
value={
settings && settings.length > 0 && getSettingValue("call")
}
className={classes.settingOption}
onChange={handleChangeSetting}
>
<option value="enabled">
{i18n.t("settings.settings.call.options.enabled")}
</option>
<option value="disabled">
{i18n.t("settings.settings.call.options.disabled")}
</option>
</Select>
</Paper>

<Paper className={classes.paper}>
<Typography variant="body1">
{i18n.t("settings.settings.CheckMsgIsGroup.name")}
</Typography>
<Select
margin="dense"
variant="outlined"
native
id="CheckMsgIsGroup-setting"
name="CheckMsgIsGroup"
value={
settings && settings.length > 0 && getSettingValue("CheckMsgIsGroup")
}
className={classes.settingOption}
onChange={handleChangeSetting}
>
<option value="enabled">
{i18n.t("settings.settings.CheckMsgIsGroup.options.enabled")}
</option>
<option value="disabled">
{i18n.t("settings.settings.CheckMsgIsGroup.options.disabled")}
</option>
</Select>
</Paper>

</Container>
</div>
);
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/translate/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,14 @@ const messages = {
disabled: "Disabled",
},
},
sideMenu: {
name: "Home Side Menu",
note: "If enabled, the side menu will start closed",
options: {
enabled: "Open",
disabled: "Closed",
},
},
messagesList: {
header: {
assignedTo: "Assigned to:",
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/translate/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,14 @@ const messages = {
disabled: "Deshabilitado",
},
},
sideMenu: {
name: "Menú lateral de inicio",
note: "Si está habilitado, el menú lateral comenzará cerrado",
options: {
enabled: "Abrir",
disabled: "Cerrado",
},
},
timeCreateNewTicket: {
name: "Crear nuevo ticket después",
note: "Selecciona el tiempo que tardará en abrir un nuevo ticket si el cliente te vuelve a contactar",
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/translate/languages/pt.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,14 @@ const messages = {
disabled: "Desativado",
},
},
sideMenu: {
name: "Menu Lateral Inicial",
note: "Se habilitado, o menu lateral irá iniciar fechado",
options: {
enabled: "Aberto",
disabled: "Fechado",
},
},
timeCreateNewTicket: {
name: "Cria novo ticket após",
note: "Selecione o tempo que será necessário para abrir um novo ticket, caso o cliente entre em contatos novamente",
Expand Down

0 comments on commit 13b22af

Please sign in to comment.