Remoção da validação de email

pull/1/head
adriano 2022-05-25 17:19:38 -03:00
parent 82cbe60a25
commit 755584a881
7 changed files with 97 additions and 44 deletions

View File

@ -28,10 +28,8 @@ const CreateUserService = async ({
}: Request): Promise<Response> => {
const schema = Yup.object().shape({
name: Yup.string().required().min(2),
email: Yup.string()
.email()
.required()
.test(
email: Yup.string().required().test(
"Check-email",
"An user with this email already exists.",
async value => {
@ -42,6 +40,19 @@ const CreateUserService = async ({
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)
});

View File

@ -31,7 +31,11 @@ const UpdateUserService = async ({
const schema = Yup.object().shape({
name: Yup.string().min(2),
email: Yup.string().email(),
email: Yup.string().min(2),
// email: Yup.string().email(),
profile: Yup.string(),
password: Yup.string()
});

View File

@ -58,7 +58,11 @@ const ContactSchema = Yup.object().shape({
.max(50, "Too Long!")
.required("Required"),
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 }) => {

View File

@ -59,9 +59,12 @@ const NotificationsPopOver = () => {
const historyRef = useRef(history);
const { handleLogout } = useContext(AuthContext);
const [lastRef] = useState(+history.location.pathname.split("/")[2])
console.log('ticketIdRef: ',ticketIdRef, ' | lastRef: ',lastRef)
useEffect(() => {
soundAlertRef.current = play;
@ -78,6 +81,9 @@ const NotificationsPopOver = () => {
}, [tickets]);
useEffect(() => {
console.log('888888888888888888888888888888888888888888888888888888888888888888')
ticketIdRef.current = ticketIdUrl;
}, [ticketIdUrl]);
@ -135,6 +141,9 @@ const NotificationsPopOver = () => {
socket.on("ticket", data => {
if (data.action === "updateUnread" || data.action === "delete") {
setNotifications(prevState => {
const ticketIndex = prevState.findIndex(t => t.id === data.ticketId);
if (ticketIndex !== -1) {
@ -165,27 +174,35 @@ const NotificationsPopOver = () => {
(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 => {
// 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);
if (ticketIndex !== -1) {
// console.log(` data.ticket 1 `)
prevState[ticketIndex] = data.ticket;
return [...prevState];
}
// console.log(` data.ticket 2 `)
return [data.ticket, ...prevState];
});
const shouldNotNotificate =
(data.message.ticketId === ticketIdRef.current &&
document.visibilityState === "visible") ||
const shouldNotNotificate = (data.message.ticketId === ticketIdRef.current && document.visibilityState === "visible") ||
(data.ticket.userId && data.ticket.userId !== user?.id) ||
data.ticket.isGroup || !data.ticket.userId;
if (shouldNotNotificate) return;
//console.log('PASSOU!!!!!!!')
handleNotifications(data);
}
@ -277,6 +294,7 @@ const NotificationsPopOver = () => {
<ListItemText>{i18n.t("notifications.noTickets")}</ListItemText>
</ListItem>
) : (
notifications.map(ticket => (
<NotificationTicket key={ticket.id}>
<TicketListItem ticket={ticket} />
@ -284,6 +302,8 @@ const NotificationsPopOver = () => {
))
)}
</List>
</Popover>
</>
);

View File

@ -75,6 +75,7 @@ const reducer = (state, action) => {
if (action.type === "LOAD_TICKETS") {
const newTickets = action.payload;
newTickets.forEach(ticket => {
const ticketIndex = state.findIndex(t => t.id === ticket.id);
if (ticketIndex !== -1) {
@ -248,6 +249,9 @@ const reducer = (state, action) => {
}, [status, showAll, user, selectedQueueIds]);
useEffect(() => {
if (typeof updateCount === "function") {
updateCount(ticketsList.length);
}

View File

@ -69,7 +69,12 @@ const UserSchema = Yup.object().shape({
.max(50, "Too Long!")
.required("Required"),
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 }) => {

View File

@ -68,7 +68,12 @@ const UserSchema = Yup.object().shape({
.max(50, "Too Long!")
.required("Required"),
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 = () => {