Remoção da validação de email
parent
82cbe60a25
commit
755584a881
|
@ -28,20 +28,31 @@ const CreateUserService = async ({
|
||||||
}: Request): Promise<Response> => {
|
}: Request): Promise<Response> => {
|
||||||
const schema = Yup.object().shape({
|
const schema = Yup.object().shape({
|
||||||
name: Yup.string().required().min(2),
|
name: Yup.string().required().min(2),
|
||||||
email: Yup.string()
|
|
||||||
.email()
|
email: Yup.string().required().test(
|
||||||
.required()
|
"Check-email",
|
||||||
.test(
|
"An user with this email already exists.",
|
||||||
"Check-email",
|
async value => {
|
||||||
"An user with this email already exists.",
|
if (!value) return false;
|
||||||
async value => {
|
const emailExists = await User.findOne({
|
||||||
if (!value) return false;
|
where: { email: value }
|
||||||
const emailExists = await User.findOne({
|
});
|
||||||
where: { email: value }
|
return !emailExists;
|
||||||
});
|
}
|
||||||
return !emailExists;
|
),
|
||||||
}
|
|
||||||
),
|
// email: Yup.string().email().required().test(
|
||||||
|
// "Check-email",
|
||||||
|
// "An user with this email already exists.",
|
||||||
|
// async value => {
|
||||||
|
// if (!value) return false;
|
||||||
|
// const emailExists = await User.findOne({
|
||||||
|
// where: { email: value }
|
||||||
|
// });
|
||||||
|
// return !emailExists;
|
||||||
|
// }
|
||||||
|
// ),
|
||||||
|
|
||||||
password: Yup.string().required().min(5)
|
password: Yup.string().required().min(5)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,11 @@ const UpdateUserService = async ({
|
||||||
|
|
||||||
const schema = Yup.object().shape({
|
const schema = Yup.object().shape({
|
||||||
name: Yup.string().min(2),
|
name: Yup.string().min(2),
|
||||||
email: Yup.string().email(),
|
|
||||||
|
email: Yup.string().min(2),
|
||||||
|
|
||||||
|
// email: Yup.string().email(),
|
||||||
|
|
||||||
profile: Yup.string(),
|
profile: Yup.string(),
|
||||||
password: Yup.string()
|
password: Yup.string()
|
||||||
});
|
});
|
||||||
|
|
|
@ -58,7 +58,11 @@ const ContactSchema = Yup.object().shape({
|
||||||
.max(50, "Too Long!")
|
.max(50, "Too Long!")
|
||||||
.required("Required"),
|
.required("Required"),
|
||||||
number: Yup.string().min(8, "Too Short!").max(50, "Too Long!"),
|
number: Yup.string().min(8, "Too Short!").max(50, "Too Long!"),
|
||||||
email: Yup.string().email("Invalid email"),
|
|
||||||
|
email: Yup.string().min(2, "Too Short!")
|
||||||
|
.max(50, "Too Long!"),
|
||||||
|
|
||||||
|
// email: Yup.string().email("Invalid email"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
|
const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
|
||||||
|
|
|
@ -57,10 +57,13 @@ const NotificationsPopOver = () => {
|
||||||
const [play] = useSound(alertSound);
|
const [play] = useSound(alertSound);
|
||||||
const soundAlertRef = useRef();
|
const soundAlertRef = useRef();
|
||||||
|
|
||||||
const historyRef = useRef(history);
|
const historyRef = useRef(history);
|
||||||
|
|
||||||
|
|
||||||
const { handleLogout } = useContext(AuthContext);
|
const { handleLogout } = useContext(AuthContext);
|
||||||
|
|
||||||
|
const [lastRef] = useState(+history.location.pathname.split("/")[2])
|
||||||
|
|
||||||
|
console.log('ticketIdRef: ',ticketIdRef, ' | lastRef: ',lastRef)
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -78,7 +81,10 @@ const NotificationsPopOver = () => {
|
||||||
}, [tickets]);
|
}, [tickets]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ticketIdRef.current = ticketIdUrl;
|
|
||||||
|
console.log('888888888888888888888888888888888888888888888888888888888888888888')
|
||||||
|
|
||||||
|
ticketIdRef.current = ticketIdUrl;
|
||||||
}, [ticketIdUrl]);
|
}, [ticketIdUrl]);
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,6 +141,9 @@ const NotificationsPopOver = () => {
|
||||||
|
|
||||||
socket.on("ticket", data => {
|
socket.on("ticket", data => {
|
||||||
if (data.action === "updateUnread" || data.action === "delete") {
|
if (data.action === "updateUnread" || data.action === "delete") {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setNotifications(prevState => {
|
setNotifications(prevState => {
|
||||||
const ticketIndex = prevState.findIndex(t => t.id === data.ticketId);
|
const ticketIndex = prevState.findIndex(t => t.id === data.ticketId);
|
||||||
if (ticketIndex !== -1) {
|
if (ticketIndex !== -1) {
|
||||||
|
@ -165,27 +174,35 @@ const NotificationsPopOver = () => {
|
||||||
(data.ticket.userId === user?.id || !data.ticket.userId)
|
(data.ticket.userId === user?.id || !data.ticket.userId)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
// console.log(`data.ticket.userId: ${data.ticket.userId }\n
|
|
||||||
// data.ticket.status: ${data.ticket.status}\n
|
|
||||||
// data.ticket.userId: ${data.ticket.userId }`)
|
|
||||||
|
|
||||||
setNotifications(prevState => {
|
setNotifications(prevState => {
|
||||||
|
|
||||||
|
// console.log('prevState: ', prevState)
|
||||||
|
|
||||||
|
// prevState.forEach((e)=>{
|
||||||
|
// console.log(`>>> e.id: ${e.id} | data.ticket.Id: ${data.ticket.id}`)
|
||||||
|
// })
|
||||||
|
|
||||||
const ticketIndex = prevState.findIndex(t => t.id === data.ticket.id);
|
const ticketIndex = prevState.findIndex(t => t.id === data.ticket.id);
|
||||||
if (ticketIndex !== -1) {
|
if (ticketIndex !== -1) {
|
||||||
|
// console.log(` data.ticket 1 `)
|
||||||
prevState[ticketIndex] = data.ticket;
|
prevState[ticketIndex] = data.ticket;
|
||||||
return [...prevState];
|
return [...prevState];
|
||||||
}
|
}
|
||||||
|
// console.log(` data.ticket 2 `)
|
||||||
return [data.ticket, ...prevState];
|
return [data.ticket, ...prevState];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const shouldNotNotificate =
|
const shouldNotNotificate = (data.message.ticketId === ticketIdRef.current && document.visibilityState === "visible") ||
|
||||||
(data.message.ticketId === ticketIdRef.current &&
|
|
||||||
document.visibilityState === "visible") ||
|
|
||||||
(data.ticket.userId && data.ticket.userId !== user?.id) ||
|
(data.ticket.userId && data.ticket.userId !== user?.id) ||
|
||||||
data.ticket.isGroup || !data.ticket.userId;
|
data.ticket.isGroup || !data.ticket.userId;
|
||||||
|
|
||||||
if (shouldNotNotificate) return;
|
if (shouldNotNotificate) return;
|
||||||
|
|
||||||
|
//console.log('PASSOU!!!!!!!')
|
||||||
|
|
||||||
|
|
||||||
handleNotifications(data);
|
handleNotifications(data);
|
||||||
}
|
}
|
||||||
|
@ -198,7 +215,7 @@ const NotificationsPopOver = () => {
|
||||||
|
|
||||||
const handleNotifications = data => {
|
const handleNotifications = data => {
|
||||||
const { message, contact, ticket } = data;
|
const { message, contact, ticket } = data;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
body: `${message.body} - ${format(new Date(), "HH:mm")}`,
|
body: `${message.body} - ${format(new Date(), "HH:mm")}`,
|
||||||
icon: contact.profilePicUrl,
|
icon: contact.profilePicUrl,
|
||||||
|
@ -276,14 +293,17 @@ const NotificationsPopOver = () => {
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemText>{i18n.t("notifications.noTickets")}</ListItemText>
|
<ListItemText>{i18n.t("notifications.noTickets")}</ListItemText>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
) : (
|
) : (
|
||||||
notifications.map(ticket => (
|
|
||||||
|
notifications.map(ticket => (
|
||||||
<NotificationTicket key={ticket.id}>
|
<NotificationTicket key={ticket.id}>
|
||||||
<TicketListItem ticket={ticket} />
|
<TicketListItem ticket={ticket} />
|
||||||
</NotificationTicket>
|
</NotificationTicket>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
</List>
|
</List>
|
||||||
|
|
||||||
|
|
||||||
</Popover>
|
</Popover>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
@ -75,6 +75,7 @@ const reducer = (state, action) => {
|
||||||
if (action.type === "LOAD_TICKETS") {
|
if (action.type === "LOAD_TICKETS") {
|
||||||
const newTickets = action.payload;
|
const newTickets = action.payload;
|
||||||
|
|
||||||
|
|
||||||
newTickets.forEach(ticket => {
|
newTickets.forEach(ticket => {
|
||||||
const ticketIndex = state.findIndex(t => t.id === ticket.id);
|
const ticketIndex = state.findIndex(t => t.id === ticket.id);
|
||||||
if (ticketIndex !== -1) {
|
if (ticketIndex !== -1) {
|
||||||
|
@ -152,9 +153,9 @@ const reducer = (state, action) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const TicketsList = (props) => {
|
const TicketsList = (props) => {
|
||||||
const { status, searchParam, showAll, selectedQueueIds, updateCount, style } =
|
const { status, searchParam, showAll, selectedQueueIds, updateCount, style } =
|
||||||
props;
|
props;
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const [pageNumber, setPageNumber] = useState(1);
|
const [pageNumber, setPageNumber] = useState(1);
|
||||||
const [ticketsList, dispatch] = useReducer(reducer, []);
|
const [ticketsList, dispatch] = useReducer(reducer, []);
|
||||||
|
@ -196,7 +197,7 @@ const reducer = (state, action) => {
|
||||||
socket.emit("joinTickets", status);
|
socket.emit("joinTickets", status);
|
||||||
} else {
|
} else {
|
||||||
socket.emit("joinNotification");
|
socket.emit("joinNotification");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -248,11 +249,14 @@ const reducer = (state, action) => {
|
||||||
}, [status, showAll, user, selectedQueueIds]);
|
}, [status, showAll, user, selectedQueueIds]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof updateCount === "function") {
|
|
||||||
updateCount(ticketsList.length);
|
|
||||||
}
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
if (typeof updateCount === "function") {
|
||||||
}, [ticketsList]);
|
updateCount(ticketsList.length);
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [ticketsList]);
|
||||||
|
|
||||||
const loadMore = () => {
|
const loadMore = () => {
|
||||||
setPageNumber(prevState => prevState + 1);
|
setPageNumber(prevState => prevState + 1);
|
||||||
|
@ -269,7 +273,7 @@ const reducer = (state, action) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper className={classes.ticketsListWrapper} style={style}>
|
<Paper className={classes.ticketsListWrapper} style={style}>
|
||||||
<Paper
|
<Paper
|
||||||
square
|
square
|
||||||
name="closed"
|
name="closed"
|
||||||
|
@ -297,7 +301,7 @@ const reducer = (state, action) => {
|
||||||
{loading && <TicketsListSkeleton />}
|
{loading && <TicketsListSkeleton />}
|
||||||
</List>
|
</List>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,12 @@ const UserSchema = Yup.object().shape({
|
||||||
.max(50, "Too Long!")
|
.max(50, "Too Long!")
|
||||||
.required("Required"),
|
.required("Required"),
|
||||||
password: Yup.string().min(5, "Too Short!").max(50, "Too Long!"),
|
password: Yup.string().min(5, "Too Short!").max(50, "Too Long!"),
|
||||||
email: Yup.string().email("Invalid email").required("Required"),
|
|
||||||
|
email: Yup.string().min(2, "Too Short!")
|
||||||
|
.max(50, "Too Long!")
|
||||||
|
.required("Required"),
|
||||||
|
|
||||||
|
// email: Yup.string().email("Invalid email").required("Required"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const UserModal = ({ open, onClose, userId }) => {
|
const UserModal = ({ open, onClose, userId }) => {
|
||||||
|
|
|
@ -68,7 +68,12 @@ const UserSchema = Yup.object().shape({
|
||||||
.max(50, "Too Long!")
|
.max(50, "Too Long!")
|
||||||
.required("Required"),
|
.required("Required"),
|
||||||
password: Yup.string().min(5, "Too Short!").max(50, "Too Long!"),
|
password: Yup.string().min(5, "Too Short!").max(50, "Too Long!"),
|
||||||
email: Yup.string().email("Invalid email").required("Required"),
|
|
||||||
|
email: Yup.string().min(2, "Too Short!")
|
||||||
|
.max(50, "Too Long!")
|
||||||
|
.required("Required"),
|
||||||
|
|
||||||
|
// email: Yup.string().email("Invalid email").required("Required"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const SignUp = () => {
|
const SignUp = () => {
|
||||||
|
|
Loading…
Reference in New Issue