mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 03:39:29 +00:00
✨ In user registration add standard whatsapp field
This commit is contained in:
@@ -32,6 +32,7 @@ import toastError from "../../errors/toastError";
|
||||
import QueueSelect from "../QueueSelect";
|
||||
import { AuthContext } from "../../context/Auth/AuthContext";
|
||||
import { Can } from "../Can";
|
||||
import useWhatsApps from "../../hooks/useWhatsApps";
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
root: {
|
||||
@@ -79,7 +80,7 @@ const UserModal = ({ open, onClose, userId }) => {
|
||||
name: "",
|
||||
email: "",
|
||||
password: "",
|
||||
profile: "user",
|
||||
profile: "user"
|
||||
};
|
||||
|
||||
const { user: loggedInUser } = useContext(AuthContext);
|
||||
@@ -87,7 +88,8 @@ const UserModal = ({ open, onClose, userId }) => {
|
||||
const [user, setUser] = useState(initialState);
|
||||
const [selectedQueueIds, setSelectedQueueIds] = useState([]);
|
||||
const [showPassword, setShowPassword] = useState(false);
|
||||
|
||||
const [whatsappId, setWhatsappId] = useState(false);
|
||||
const {loading, whatsApps} = useWhatsApps();
|
||||
|
||||
useEffect(() => {
|
||||
const fetchUser = async () => {
|
||||
@@ -99,6 +101,7 @@ const UserModal = ({ open, onClose, userId }) => {
|
||||
});
|
||||
const userQueueIds = data.queues?.map(queue => queue.id);
|
||||
setSelectedQueueIds(userQueueIds);
|
||||
setWhatsappId(data.whatsappId ? data.whatsappId : '');
|
||||
} catch (err) {
|
||||
toastError(err);
|
||||
}
|
||||
@@ -113,7 +116,7 @@ const UserModal = ({ open, onClose, userId }) => {
|
||||
};
|
||||
|
||||
const handleSaveUser = async values => {
|
||||
const userData = { ...values, queueIds: selectedQueueIds };
|
||||
const userData = { ...values, whatsappId, queueIds: selectedQueueIds };
|
||||
try {
|
||||
if (userId) {
|
||||
await api.put(`/users/${userId}`, userData);
|
||||
@@ -242,6 +245,26 @@ const UserModal = ({ open, onClose, userId }) => {
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
<Can
|
||||
role={loggedInUser.profile}
|
||||
perform="user-modal:editQueues"
|
||||
yes={() => (
|
||||
<FormControl variant="outlined" margin="dense" className={classes.maxWidth} fullWidth>
|
||||
<InputLabel>{i18n.t("userModal.form.whatsapp")}</InputLabel>
|
||||
<Field
|
||||
as={Select}
|
||||
value={whatsappId}
|
||||
onChange={(e) => setWhatsappId(e.target.value)}
|
||||
label={i18n.t("userModal.form.whatsapp")}
|
||||
>
|
||||
<MenuItem value={''}> </MenuItem>
|
||||
{whatsApps.map((whatsapp) => (
|
||||
<MenuItem key={whatsapp.id} value={whatsapp.id}>{whatsapp.name}</MenuItem>
|
||||
))}
|
||||
</Field>
|
||||
</FormControl>
|
||||
)}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
|
||||
@@ -243,6 +243,9 @@ const Users = () => {
|
||||
<TableCell align="center">
|
||||
{i18n.t("users.table.profile")}
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
{i18n.t("users.table.whatsapp")}
|
||||
</TableCell>
|
||||
<TableCell align="center">
|
||||
{i18n.t("users.table.actions")}
|
||||
</TableCell>
|
||||
@@ -255,6 +258,7 @@ const Users = () => {
|
||||
<TableCell align="center">{user.name}</TableCell>
|
||||
<TableCell align="center">{user.email}</TableCell>
|
||||
<TableCell align="center">{user.profile}</TableCell>
|
||||
<TableCell align="center">{user.whatsapp?.name}</TableCell>
|
||||
<TableCell align="center">
|
||||
<IconButton
|
||||
size="small"
|
||||
|
||||
@@ -206,6 +206,7 @@ const messages = {
|
||||
email: "Email",
|
||||
password: "Password",
|
||||
profile: "Profile",
|
||||
whatsapp: "Default Connection",
|
||||
},
|
||||
buttons: {
|
||||
okAdd: "Add",
|
||||
@@ -340,6 +341,7 @@ const messages = {
|
||||
name: "Name",
|
||||
email: "Email",
|
||||
profile: "Profile",
|
||||
whatsapp: "Default Connection",
|
||||
actions: "Actions",
|
||||
},
|
||||
buttons: {
|
||||
|
||||
@@ -209,6 +209,7 @@ const messages = {
|
||||
email: "Correo Electrónico",
|
||||
password: "Contraseña",
|
||||
profile: "Perfil",
|
||||
whatsapp: "Conexión estándar",
|
||||
},
|
||||
buttons: {
|
||||
okAdd: "Agregar",
|
||||
@@ -345,6 +346,7 @@ const messages = {
|
||||
name: "Nombre",
|
||||
email: "Correo Electrónico",
|
||||
profile: "Perfil",
|
||||
whatsapp: "Conexión estándar",
|
||||
actions: "Acciones",
|
||||
},
|
||||
buttons: {
|
||||
|
||||
@@ -208,6 +208,7 @@ const messages = {
|
||||
email: "Email",
|
||||
password: "Senha",
|
||||
profile: "Perfil",
|
||||
whatsapp: "Conexão Padrão",
|
||||
},
|
||||
buttons: {
|
||||
okAdd: "Adicionar",
|
||||
@@ -344,6 +345,7 @@ const messages = {
|
||||
name: "Nome",
|
||||
email: "Email",
|
||||
profile: "Perfil",
|
||||
whatsapp: "Conexão Padrão",
|
||||
actions: "Ações",
|
||||
},
|
||||
buttons: {
|
||||
|
||||
Reference in New Issue
Block a user