Skip to content

Commit

Permalink
Número do cliente trucado para Atendente
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh committed Apr 11, 2023
1 parent 920e31c commit c5a842d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 35 deletions.
9 changes: 5 additions & 4 deletions frontend/src/components/ContactDrawer/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useState, useContext } from "react";

import { makeStyles } from "@material-ui/core/styles";
import Typography from "@material-ui/core/Typography";
Expand All @@ -19,6 +19,7 @@ import MarkdownWrapper from "../MarkdownWrapper";
import { TagsContainer } from "../TagsContainer";
import ModalImageContatc from "./ModalImage";
import CopyToClipboard from "../CopyToClipboard";
import { AuthContext } from "../../context/Auth/AuthContext";

const drawerWidth = 320;

Expand Down Expand Up @@ -87,7 +88,7 @@ const useStyles = makeStyles(theme => ({

const ContactDrawer = ({ open, handleDrawerClose, contact, loading }) => {
const classes = useStyles();

const { user } = useContext(AuthContext);
const [modalOpen, setModalOpen] = useState(false);

return (
Expand Down Expand Up @@ -127,8 +128,8 @@ const ContactDrawer = ({ open, handleDrawerClose, contact, loading }) => {
<CopyToClipboard content={contact.name} color="secondary" />
</Typography>
<Typography>
<Link href={`tel:${contact.number}`}>{contact.number}</Link>
<CopyToClipboard content={contact.number} color="secondary" />
<Link href={`tel:${user.profile === "admin" ? contact.number : contact.number.slice(0,-4) + "****"}`}>{user.profile === "admin" ? contact.number : contact.number.slice(0,-4) + "****"}</Link>
<CopyToClipboard content={user.profile === "admin" ? contact.number : contact.number.slice(0,-4) + "****"} color="secondary" />
</Typography>
{contact.email && (
<Typography>
Expand Down
75 changes: 47 additions & 28 deletions frontend/src/components/ContactModal/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
import React, { useState, useEffect, useRef } from "react";
import React, {
useState,
useEffect,
useRef,
useContext
} from "react";

import * as Yup from "yup";
import { Formik, FieldArray, Form, Field } from "formik";
import { toast } from "react-toastify";
import {
Formik,
FieldArray,
Form,
Field
} from "formik";

import { makeStyles } from "@material-ui/core/styles";
import { green } from "@material-ui/core/colors";
import Button from "@material-ui/core/Button";
import TextField from "@material-ui/core/TextField";
import Dialog from "@material-ui/core/Dialog";
import DialogActions from "@material-ui/core/DialogActions";
import DialogContent from "@material-ui/core/DialogContent";
import DialogTitle from "@material-ui/core/DialogTitle";
import Typography from "@material-ui/core/Typography";
import IconButton from "@material-ui/core/IconButton";
import {
Button,
CircularProgress,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
IconButton,
makeStyles,
TextField,
Typography
} from "@material-ui/core";
import DeleteOutlineIcon from "@material-ui/icons/DeleteOutline";
import CircularProgress from "@material-ui/core/CircularProgress";

import { i18n } from "../../translate/i18n";

import api from "../../services/api";
import toastError from "../../errors/toastError";
import * as Yup from "yup";
import { toast } from "react-toastify";
import { Can } from "../Can";
import { AuthContext } from "../../context/Auth/AuthContext";

const useStyles = makeStyles(theme => ({
root: {
Expand All @@ -31,25 +44,22 @@ const useStyles = makeStyles(theme => ({
marginRight: theme.spacing(1),
flex: 1,
},

extraAttr: {
display: "flex",
justifyContent: "center",
alignItems: "center",
},

btnWrapper: {
position: "relative",
},

buttonProgress: {
color: green[500],
position: "absolute",
top: "50%",
left: "50%",
marginTop: -12,
marginLeft: -12,
},
}
}));

const ContactSchema = Yup.object().shape({
Expand All @@ -64,6 +74,7 @@ const ContactSchema = Yup.object().shape({
const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
const classes = useStyles();
const isMounted = useRef(true);
const { user } = useContext(AuthContext);

const initialState = {
name: "",
Expand Down Expand Up @@ -161,15 +172,23 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
margin="dense"
className={classes.textField}
/>
<Field
as={TextField}
label={i18n.t("contactModal.form.number")}
name="number"
error={touched.number && Boolean(errors.number)}
helperText={touched.number && errors.number}
placeholder="5513912344321"
variant="outlined"
margin="dense"
<Can
role={user.profile}
perform="drawer-admin-items:view"
yes={() => (
<>
<Field
as={TextField}
label={i18n.t("contactModal.form.number")}
name="number"
error={touched.number && Boolean(errors.number)}
helperText={touched.number && errors.number}
placeholder="5522999999999"
variant="outlined"
margin="dense"
/>
</>
)}
/>
<div>
<Field
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/pages/Contacts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ const useStyles = makeStyles((theme) => ({
const Contacts = () => {
const classes = useStyles();
const history = useHistory();

const { user } = useContext(AuthContext);

const [loading, setLoading] = useState(false);
const [pageNumber, setPageNumber] = useState(1);
const [searchParam, setSearchParam] = useState("");
Expand Down Expand Up @@ -245,6 +243,8 @@ const Contacts = () => {
}
};

console.log("USER", user.profile)

return (
<MainContainer className={classes.mainContainer}>
<NewTicketModalPageContact
Expand Down Expand Up @@ -394,7 +394,7 @@ const Contacts = () => {
{<Avatar src={contact.profilePicUrl} className={classes.avatar} />}
</TableCell>
<TableCell>{contact.name}</TableCell>
<TableCell align="center">{contact.number}</TableCell>
<TableCell align="center">{user.profile === "admin" ? contact.number : contact.number.slice(0,-4) + "****"}</TableCell>
<TableCell align="center">{contact.email}</TableCell>
<TableCell align="center">
<IconButton
Expand Down

0 comments on commit c5a842d

Please sign in to comment.