Compare commits
No commits in common. "90e9e311c3c039fb826ec3c124018f33532cfa23" and "76929c41ec4b31efb31ab1fec62ab604a87b5504" have entirely different histories.
90e9e311c3
...
76929c41ec
|
@ -20,14 +20,14 @@ export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||||
|
|
||||||
// const config = await SettingTicket.findAll();
|
// const config = await SettingTicket.findAll();
|
||||||
|
|
||||||
return res.status(200).json({ settings });
|
return res.status(200).json({ settings, });
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ticketSettings = async (
|
export const ticketSettings = async (
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response
|
||||||
): Promise<Response> => {
|
): Promise<Response> => {
|
||||||
const { number } = req.params;
|
const { number } = req.params;
|
||||||
|
|
||||||
const config = await SettingTicket.findAll({ where: { number } });
|
const config = await SettingTicket.findAll({ where: { number } });
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ export const updateTicketSettings = async (
|
||||||
): Promise<Response> => {
|
): Promise<Response> => {
|
||||||
const {
|
const {
|
||||||
number,
|
number,
|
||||||
saturdayBusinessTime,
|
|
||||||
outBusinessHours,
|
outBusinessHours,
|
||||||
ticketExpiration,
|
ticketExpiration,
|
||||||
weekend,
|
weekend,
|
||||||
|
@ -48,7 +47,7 @@ export const updateTicketSettings = async (
|
||||||
sunday,
|
sunday,
|
||||||
holiday
|
holiday
|
||||||
} = req.body;
|
} = req.body;
|
||||||
|
|
||||||
if (!number) throw new AppError("No number selected", 400);
|
if (!number) throw new AppError("No number selected", 400);
|
||||||
|
|
||||||
if (outBusinessHours && Object.keys(outBusinessHours).length > 0) {
|
if (outBusinessHours && Object.keys(outBusinessHours).length > 0) {
|
||||||
|
@ -59,14 +58,6 @@ export const updateTicketSettings = async (
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saturdayBusinessTime && Object.keys(saturdayBusinessTime).length > 0) {
|
|
||||||
await updateSettingTicket({
|
|
||||||
...saturdayBusinessTime,
|
|
||||||
key: "saturdayBusinessTime",
|
|
||||||
number
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ticketExpiration && Object.keys(ticketExpiration).length > 0) {
|
if (ticketExpiration && Object.keys(ticketExpiration).length > 0) {
|
||||||
await updateSettingTicket({
|
await updateSettingTicket({
|
||||||
...ticketExpiration,
|
...ticketExpiration,
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
import { QueryInterface } from "sequelize";
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface: QueryInterface) => {
|
|
||||||
return queryInterface.bulkInsert(
|
|
||||||
"SettingTickets",
|
|
||||||
[
|
|
||||||
{
|
|
||||||
message: "",
|
|
||||||
startTime: new Date(),
|
|
||||||
endTime: new Date(),
|
|
||||||
value: "disabled",
|
|
||||||
key: "saturdayBusinessTime",
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date()
|
|
||||||
}
|
|
||||||
],
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface: QueryInterface) => {
|
|
||||||
return queryInterface.bulkDelete("SettingTickets", {});
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -39,7 +39,7 @@ const isHoliday = async (number: string | number) => {
|
||||||
locale: ptBR
|
locale: ptBR
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (currentDate.fullDate == startTime.fullDate) {
|
if (currentDate.fullDate == startTime.fullDate) {
|
||||||
obj.set = true;
|
obj.set = true;
|
||||||
|
@ -173,80 +173,8 @@ async function isOutBusinessTime(number: string | number) {
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isOutBusinessTimeSaturday(number: string | number) {
|
export {
|
||||||
let obj = { set: false, msg: "" };
|
isWeekend,
|
||||||
|
isHoliday,
|
||||||
const outBusinessHoursSaturday = await SettingTicket.findOne({
|
isOutBusinessTime
|
||||||
where: { key: "saturdayBusinessTime", number }
|
};
|
||||||
});
|
|
||||||
|
|
||||||
let isWithinRange = false;
|
|
||||||
|
|
||||||
if (
|
|
||||||
true &&
|
|
||||||
outBusinessHoursSaturday
|
|
||||||
// outBusinessHoursSaturday &&
|
|
||||||
// outBusinessHoursSaturday.value == "enabled" &&
|
|
||||||
// outBusinessHoursSaturday?.message?.trim()?.length > 0
|
|
||||||
) {
|
|
||||||
const ticketDateTimeUpdate = splitDateTime(
|
|
||||||
new Date(
|
|
||||||
_format(new Date(), "yyyy-MM-dd HH:mm:ss", {
|
|
||||||
locale: ptBR
|
|
||||||
})
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
const startTime = splitDateTime(
|
|
||||||
new Date(
|
|
||||||
_format(
|
|
||||||
new Date(outBusinessHoursSaturday.startTime),
|
|
||||||
"yyyy-MM-dd HH:mm:ss",
|
|
||||||
{
|
|
||||||
locale: ptBR
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
const endTime = splitDateTime(
|
|
||||||
new Date(
|
|
||||||
_format(
|
|
||||||
new Date(outBusinessHoursSaturday.endTime),
|
|
||||||
"yyyy-MM-dd HH:mm:ss",
|
|
||||||
{
|
|
||||||
locale: ptBR
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
const format = "HH:mm:ss";
|
|
||||||
const parsedStartTime = parse(
|
|
||||||
ticketDateTimeUpdate.fullTime,
|
|
||||||
format,
|
|
||||||
new Date()
|
|
||||||
);
|
|
||||||
const parsedEndTime = parse(startTime.fullTime, format, new Date());
|
|
||||||
const parsedTimeToCheck = parse(endTime.fullTime, format, new Date());
|
|
||||||
const timeInterval = { start: parsedStartTime, end: parsedEndTime };
|
|
||||||
|
|
||||||
// If the time range spans across different days, handle the date part
|
|
||||||
if (parsedEndTime < parsedStartTime) {
|
|
||||||
const nextDay = new Date(parsedStartTime);
|
|
||||||
nextDay.setDate(nextDay.getDate() + 1);
|
|
||||||
timeInterval.end = nextDay;
|
|
||||||
}
|
|
||||||
|
|
||||||
isWithinRange = isWithinInterval(parsedTimeToCheck, timeInterval);
|
|
||||||
|
|
||||||
if (!isWithinRange) {
|
|
||||||
obj.set = true;
|
|
||||||
obj.msg = outBusinessHoursSaturday.message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
export { isWeekend, isHoliday, isOutBusinessTime, isOutBusinessTimeSaturday };
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import path from "path";
|
||||||
import {
|
import {
|
||||||
isHoliday,
|
isHoliday,
|
||||||
isOutBusinessTime,
|
isOutBusinessTime,
|
||||||
isOutBusinessTimeSaturday,
|
|
||||||
isWeekend
|
isWeekend
|
||||||
} from "../../helpers/TicketConfig";
|
} from "../../helpers/TicketConfig";
|
||||||
|
|
||||||
|
@ -1222,13 +1221,6 @@ const outOfService = async (number: string) => {
|
||||||
objs.push({ type: "holiday", msg: holiday.msg });
|
objs.push({ type: "holiday", msg: holiday.msg });
|
||||||
}
|
}
|
||||||
|
|
||||||
// MESSAGE TO SATURDAY BUSINESS TIME
|
|
||||||
const businessTimeSaturday = await isOutBusinessTimeSaturday(number);
|
|
||||||
|
|
||||||
if (businessTimeSaturday && businessTimeSaturday.set) {
|
|
||||||
objs.push({ type: "saturdayBusinessTime", msg: businessTimeSaturday.msg });
|
|
||||||
}
|
|
||||||
|
|
||||||
// MESSAGES TO SATURDAY OR SUNDAY
|
// MESSAGES TO SATURDAY OR SUNDAY
|
||||||
const weekend: any = await isWeekend(number);
|
const weekend: any = await isWeekend(number);
|
||||||
|
|
||||||
|
|
|
@ -77,16 +77,8 @@ const ConfigModal = ({ open, onClose, change }) => {
|
||||||
const initialState = {
|
const initialState = {
|
||||||
startTimeBus: new Date(),
|
startTimeBus: new Date(),
|
||||||
endTimeBus: new Date(),
|
endTimeBus: new Date(),
|
||||||
|
|
||||||
startTimeBusSaturday: new Date(),
|
|
||||||
endTimeBusSaturday: new Date(),
|
|
||||||
|
|
||||||
messageBus: '',
|
messageBus: '',
|
||||||
messageBusSaturday: '',
|
|
||||||
|
|
||||||
businessTimeEnable: false,
|
businessTimeEnable: false,
|
||||||
businessTimeEnableSaturday: false,
|
|
||||||
|
|
||||||
ticketTimeExpiration: new Date(),
|
ticketTimeExpiration: new Date(),
|
||||||
ticketExpirationMsg: '',
|
ticketExpirationMsg: '',
|
||||||
ticketExpirationEnable: false,
|
ticketExpirationEnable: false,
|
||||||
|
@ -123,16 +115,13 @@ const ConfigModal = ({ open, onClose, change }) => {
|
||||||
if (!selectedNumber) return
|
if (!selectedNumber) return
|
||||||
|
|
||||||
const { data } = await api.get(`/settings/ticket/${selectedNumber}`)
|
const { data } = await api.get(`/settings/ticket/${selectedNumber}`)
|
||||||
|
|
||||||
if (data?.config && data.config.length === 0) {
|
if (data?.config && data.config.length === 0) {
|
||||||
setConfig(initialState)
|
setConfig(initialState)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const outBusinessHours = data.config.find((c) => c.key === "outBusinessHours")
|
const outBusinessHours = data.config.find((c) => c.key === "outBusinessHours")
|
||||||
|
|
||||||
const saturdayBusinessTime = data.config.find((c) => c.key === "saturdayBusinessTime")
|
|
||||||
|
|
||||||
const ticketExpiration = data.config.find((c) => c.key === "ticketExpiration")
|
const ticketExpiration = data.config.find((c) => c.key === "ticketExpiration")
|
||||||
const saturday = data.config.find((c) => c.key === "saturday")
|
const saturday = data.config.find((c) => c.key === "saturday")
|
||||||
const sunday = data.config.find((c) => c.key === "sunday")
|
const sunday = data.config.find((c) => c.key === "sunday")
|
||||||
|
@ -145,11 +134,6 @@ const ConfigModal = ({ open, onClose, change }) => {
|
||||||
messageBus: outBusinessHours.message,
|
messageBus: outBusinessHours.message,
|
||||||
businessTimeEnable: outBusinessHours.value === 'enabled' ? true : false,
|
businessTimeEnable: outBusinessHours.value === 'enabled' ? true : false,
|
||||||
|
|
||||||
startTimeBusSaturday: saturdayBusinessTime.startTime,
|
|
||||||
endTimeBusSaturday: saturdayBusinessTime.endTime,
|
|
||||||
messageBusSaturday: saturdayBusinessTime.message,
|
|
||||||
businessTimeEnableSaturday: saturdayBusinessTime.value === 'enabled' ? true : false,
|
|
||||||
|
|
||||||
ticketTimeExpiration: ticketExpiration.startTime,
|
ticketTimeExpiration: ticketExpiration.startTime,
|
||||||
ticketExpirationMsg: ticketExpiration.message,
|
ticketExpirationMsg: ticketExpiration.message,
|
||||||
ticketExpirationEnable: ticketExpiration.value === 'enabled' ? true : false,
|
ticketExpirationEnable: ticketExpiration.value === 'enabled' ? true : false,
|
||||||
|
@ -181,14 +165,6 @@ const ConfigModal = ({ open, onClose, change }) => {
|
||||||
message: values.messageBus,
|
message: values.messageBus,
|
||||||
value: values.businessTimeEnable ? 'enabled' : 'disabled'
|
value: values.businessTimeEnable ? 'enabled' : 'disabled'
|
||||||
},
|
},
|
||||||
|
|
||||||
saturdayBusinessTime: {
|
|
||||||
startTime: values.startTimeBusSaturday,
|
|
||||||
endTime: values.endTimeBusSaturday,
|
|
||||||
message: values.messageBusSaturday,
|
|
||||||
value: values.businessTimeEnableSaturday ? 'enabled' : 'disabled'
|
|
||||||
},
|
|
||||||
|
|
||||||
ticketExpiration: {
|
ticketExpiration: {
|
||||||
startTime: values.ticketTimeExpiration,
|
startTime: values.ticketTimeExpiration,
|
||||||
message: values.ticketExpirationMsg,
|
message: values.ticketExpirationMsg,
|
||||||
|
@ -229,7 +205,7 @@ const ConfigModal = ({ open, onClose, change }) => {
|
||||||
onClose()
|
onClose()
|
||||||
// setConfig(initialState)
|
// setConfig(initialState)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
<Dialog
|
<Dialog
|
||||||
|
@ -349,61 +325,6 @@ const ConfigModal = ({ open, onClose, change }) => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<br />
|
|
||||||
{/* SABADO INICIO */}
|
|
||||||
<div className={classes.multFieldLine}>
|
|
||||||
<Field
|
|
||||||
component={TimePicker}
|
|
||||||
name="startTimeBusSaturday"
|
|
||||||
label="Inicio atendimentos"
|
|
||||||
ampm={false}
|
|
||||||
openTo="hours"
|
|
||||||
views={['hours', 'minutes',]}
|
|
||||||
format="HH:mm"
|
|
||||||
/>
|
|
||||||
{' '}
|
|
||||||
<Field
|
|
||||||
component={TimePicker}
|
|
||||||
name="endTimeBusSaturday"
|
|
||||||
label="Fim atendimento"
|
|
||||||
ampm={false}
|
|
||||||
openTo="hours"
|
|
||||||
views={['hours', 'minutes',]}
|
|
||||||
format="HH:mm"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormControlLabel
|
|
||||||
control={
|
|
||||||
<Field
|
|
||||||
as={Switch}
|
|
||||||
color="primary"
|
|
||||||
name="businessTimeEnableSaturday"
|
|
||||||
checked={values.businessTimeEnableSaturday}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
label={'Ativar/Desativar'} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<Field
|
|
||||||
as={TextField}
|
|
||||||
label={'Mensagem fora do horário de atendimento sábado'}
|
|
||||||
type="messageBusSaturday"
|
|
||||||
multiline
|
|
||||||
rows={5}
|
|
||||||
fullWidth
|
|
||||||
name="messageBusSaturday"
|
|
||||||
error={
|
|
||||||
touched.messageBusSaturday && Boolean(errors.messageBusSaturday)
|
|
||||||
}
|
|
||||||
helperText={
|
|
||||||
touched.messageBusSaturday && errors.messageBusSaturday
|
|
||||||
}
|
|
||||||
variant="outlined"
|
|
||||||
margin="dense"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{/* SABADO FIM */}
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ const PieChart = ({ data = dataExample }) => {
|
||||||
return (
|
return (
|
||||||
<Box width="100%" height="100%" position="relative" display="flex">
|
<Box width="100%" height="100%" position="relative" display="flex">
|
||||||
<Box sx={{ position: "absolute" }}>
|
<Box sx={{ position: "absolute" }}>
|
||||||
<Title>Tickets encerramento</Title>
|
<Title>Tickets status de encerramento</Title>
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
component="ul"
|
component="ul"
|
||||||
|
|
|
@ -293,7 +293,7 @@ const Dashboard = () => {
|
||||||
dispatch({ type: "LOAD_QUERY", payload: data.usersProfile })
|
dispatch({ type: "LOAD_QUERY", payload: data.usersProfile })
|
||||||
|
|
||||||
const { data: ticketStatusChatEndData } = await api.get("/reports/count/statusChatEnd", {
|
const { data: ticketStatusChatEndData } = await api.get("/reports/count/statusChatEnd", {
|
||||||
params: { startDate: dateToday, endDate: dateToday },
|
params: { startDate: '2024-03-21', endDate: '2024-03-28' },
|
||||||
})
|
})
|
||||||
|
|
||||||
setTicketStatusChatEnd(ticketStatusChatEndData.reportStatusChatEnd)
|
setTicketStatusChatEnd(ticketStatusChatEndData.reportStatusChatEnd)
|
||||||
|
|
Loading…
Reference in New Issue