Skip to content

Commit

Permalink
Ordenação dos Tickets
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh committed Mar 27, 2023
1 parent 833cdeb commit 2c64899
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 10 deletions.
19 changes: 15 additions & 4 deletions backend/src/services/TicketServices/ListTicketsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Message from "../../models/Message";
import Queue from "../../models/Queue";
import Whatsapp from "../../models/Whatsapp";
import ShowUserService from "../UserServices/ShowUserService";
import ListSettingsServiceOne from "../SettingServices/ListSettingsServiceOne";

interface Request {
searchParam?: string;
Expand Down Expand Up @@ -45,8 +46,8 @@ const ListTicketsService = async ({
{
model: Contact,
as: "contact",
attributes: ["id", "name", "number", "profilePicUrl"],
include: ["extraInfo", "contactTags", "tags"]
attributes: ["id", "name", "number", "profilePicUrl"]
// include: ["extraInfo", "contactTags", "tags"]
},
{
model: Queue,
Expand Down Expand Up @@ -133,16 +134,26 @@ const ListTicketsService = async ({
};
}

const limit = 999;
const limit = 100;
const offset = limit * (+pageNumber - 1);

const listSettingsService = await ListSettingsServiceOne({ key: "ASC" });
let settingASC = listSettingsService?.value;

settingASC = settingASC === "enabled" ? "ASC" : "DESC";

const listSettingsService2 = await ListSettingsServiceOne({ key: "created" });
let settingCreated = listSettingsService2?.value;

settingCreated = settingCreated === "enabled" ? "createdAt" : "updatedAt";

const { count, rows: tickets } = await Ticket.findAndCountAll({
where: whereCondition,
include: includeCondition,
distinct: true,
limit,
offset,
order: [["updatedAt", "DESC"]]
order: [[settingCreated, settingASC]]
});

const hasMore = count > offset + tickets.length;
Expand Down
44 changes: 38 additions & 6 deletions frontend/src/pages/Settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const Settings = () => {

return (
<div className={classes.root}>
<Container className={classes.container} maxWidth="sm">
<Container className={classes.container} maxWidth="xs">
<Typography variant="body2" gutterBottom>
{i18n.t("settings.title")}
</Typography>
Expand All @@ -186,7 +186,7 @@ const Settings = () => {
</Paper>

<Typography variant="body2" gutterBottom></Typography>

<Paper className={classes.paper}>
<Tooltip title={i18n.t("settings.settings.allTicket.note")}>
<FormControlLabel
Expand Down Expand Up @@ -243,6 +243,10 @@ const Settings = () => {
</Tooltip>
</Paper>


</Container>
<Container className={classes.container} maxWidth="xs">

<Typography variant="body2" gutterBottom></Typography>
<Paper className={classes.paper}>
<Tooltip title={i18n.t("settings.settings.closeTicketApi.note")}>
Expand Down Expand Up @@ -272,8 +276,36 @@ const Settings = () => {
</Paper>

<Typography variant="body2" gutterBottom></Typography>
<Tooltip title={i18n.t("settings.settings.timeCreateNewTicket.note")}>
<Paper className={classes.paper} elevation={3}>
<Paper className={classes.paper}>
<Tooltip title={i18n.t("settings.settings.ASC.note")}>
<FormControlLabel
control={
<IOSSwitch
checked={settings && settings.length > 0 && getSettingValue("ASC") === "enabled"}
onChange={handleChangeBooleanSetting} name="ASC"
/>}
label={i18n.t("settings.settings.ASC.name")}
/>
</Tooltip>
</Paper>

<Typography variant="body2" gutterBottom></Typography>
<Paper className={classes.paper}>
<Tooltip title={i18n.t("settings.settings.created.note")}>
<FormControlLabel
control={
<IOSSwitch
checked={settings && settings.length > 0 && getSettingValue("created") === "enabled"}
onChange={handleChangeBooleanSetting} name="created"
/>}
label={i18n.t("settings.settings.created.name")}
/>
</Tooltip>
</Paper>

<Typography variant="body2" gutterBottom></Typography>
<Tooltip title={i18n.t("settings.settings.timeCreateNewTicket.note")}>
<Paper className={classes.paper} elevation={3}>
<Typography variant="body1">
{i18n.t("settings.settings.timeCreateNewTicket.name")}
</Typography>
Expand Down Expand Up @@ -329,8 +361,8 @@ const Settings = () => {
{i18n.t("settings.settings.timeCreateNewTicket.options.2592000")}
</option>
</Select>
</Paper>
</Tooltip>
</Paper>
</Tooltip>
</Container>
</div>
);
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/translate/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,22 @@ const messages = {
disabled: "Disabled",
},
},
ASC: {
name: "Order of Tickets",
note: "When enabled, it will sort ascending (ASC), disabling it will sort descending (DESC)",
options: {
enabled: "Enabled",
disabled: "Disabled",
},
},
created: {
name: "Order of Tickets (createdAt or updateAt)",
note: "When activated, it will order by creation date (createdAt), deactivating will order by update date (updateAt)",
options: {
enabled: "Enabled",
disabled: "Disabled",
},
},
timeCreateNewTicket: {
name: "Create new ticket after",
note: "Select the time it will take to openlaugh a new ticket, in case the customer gets in touch again",
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/translate/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,22 @@ const messages = {
disabled: "Deshabilitado",
},
},
ASC: {
name: "Pedido de Entradas",
note: "Cuando está habilitado, se ordenará de forma ascendente (ASC), al deshabilitarlo se ordenará de forma descendente (DESC)",
options: {
enabled: "Habilitado",
disabled: "Deshabilitado",
},
},
created: {
name: "Orden de entradas (createdAt or updateAt)",
note: "Cuando se activa, se ordenará por fecha de creación (createdAt), al desactivar se ordenará por fecha de actualización (updateAt)",
options: {
enabled: "Habilitado",
disabled: "Deshabilitado",
},
},
timeCreateNewTicket: {
name: "Crear nuevo ticket después",
note: "Seleccione el tiempo que tardará en abrir un nuevo ticket si el cliente lo contacta nuevamente",
Expand Down
16 changes: 16 additions & 0 deletions frontend/src/translate/languages/pt.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,22 @@ const messages = {
disabled: "Desativado",
},
},
ASC: {
name: "Ordenação dos Tickets (ASC ou DESC)",
note: "Ao ativar irá ordenar ascendente (ASC), desativando ordenará decrescente (DESC)",
options: {
enabled: "Ativado",
disabled: "Desativado",
},
},
created: {
name: "Ordenação dos Tickets (createdAt ou updateAt)",
note: "Ao ativar irá ordenar pela data de criação (createdAt), desativando ordenará pela data de atualização (updateAt)",
options: {
enabled: "Ativado",
disabled: "Desativado",
},
},
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 2c64899

Please sign in to comment.