diff --git a/frontend/src/pages/Connections/index.js b/frontend/src/pages/Connections/index.js index 323d2be..98c47f4 100644 --- a/frontend/src/pages/Connections/index.js +++ b/frontend/src/pages/Connections/index.js @@ -45,7 +45,7 @@ import toastError from "../../errors/toastError"; import { AuthContext } from "../../context/Auth/AuthContext"; import { Can } from "../../components/Can"; - + const useStyles = makeStyles(theme => ({ mainPaper: { flex: 1, @@ -98,20 +98,20 @@ const CustomToolTip = ({ title, content, children }) => { }; const Connections = () => { - + //-------- - const { user } = useContext(AuthContext); - - + const { user } = useContext(AuthContext); + + const classes = useStyles(); const { whatsApps, loading } = useContext(WhatsAppsContext); const [whatsAppModalOpen, setWhatsAppModalOpen] = useState(false); const [qrModalOpen, setQrModalOpen] = useState(false); const [selectedWhatsApp, setSelectedWhatsApp] = useState(null); - const [confirmModalOpen, setConfirmModalOpen] = useState(false); + const [confirmModalOpen, setConfirmModalOpen] = useState(false); + - const confirmationModalInitialState = { action: "", title: "", @@ -124,7 +124,7 @@ const Connections = () => { ); const handleStartWhatsAppSession = async whatsAppId => { - try { + try { await api.post(`/whatsappsession/${whatsAppId}`); } catch (err) { toastError(err); @@ -207,69 +207,69 @@ const Connections = () => { }; const renderActionButtons = whatsApp => { - return ( + return ( ( - <> - {whatsApp.status === "qrcode" && ( - - )} - {whatsApp.status === "DISCONNECTED" && ( + <> + {whatsApp.status === "qrcode" && ( + + )} + {whatsApp.status === "DISCONNECTED" && ( - <> - {" "} - + <> + {" "} + + + )} + {(whatsApp.status === "CONNECTED" || + whatsApp.status === "PAIRING" || + whatsApp.status === "TIMEOUT") && ( + + )} + {whatsApp.status === "OPENING" && ( + + )} + )} - {(whatsApp.status === "CONNECTED" || - whatsApp.status === "PAIRING" || - whatsApp.status === "TIMEOUT") && ( - - )} - {whatsApp.status === "OPENING" && ( - - )} - - - )} - /> - + /> + ); }; @@ -312,160 +312,166 @@ const Connections = () => { ); }; - return ( + return ( ( - - - {confirmModalInfo.message} - - - - - {i18n.t("connections.title")} - - - - ( - - )} - /> - - - - - - - - - - - {i18n.t("connections.table.name")} - - - {i18n.t("connections.table.status")} - + role={user.profile} + perform="connections-view:show" + yes={() => ( + + + {confirmModalInfo.message} + + + + + {i18n.t("connections.title")} + ( - - {i18n.t("connections.table.session")} - - )} + role={user.profile} + perform="btn-add-whatsapp" + yes={() => ( + + )} /> - - - - {i18n.t("connections.table.lastUpdate")} - - - {i18n.t("connections.table.default")} - - - {i18n.t("connections.table.actions")} - - - - - {loading ? ( - - ) : ( - <> - {whatsApps?.length > 0 && - whatsApps.map(whatsApp => ( - - {whatsApp.name} + + + + + +
+ + + + {i18n.t("connections.table.name")} + + + {i18n.t("connections.table.status")} + + + + ( - {renderStatusToolTips(whatsApp)} + {i18n.t("connections.table.session")} - - ( - - {renderActionButtons(whatsApp)} - - )} - /> - - - - - {format(parseISO(whatsApp.updatedAt), "dd/MM/yy HH:mm")} - - - {whatsApp.isDefault && ( -
- -
- )} -
- - handleEditWhatsApp(whatsApp)} - > - - + )} + /> - + {i18n.t("connections.table.lastUpdate")} + + + {i18n.t("connections.table.default")} + + + {i18n.t("connections.table.actions")} + +
+
+ + {loading ? ( + + ) : ( + <> + {whatsApps?.length > 0 && + whatsApps.map(whatsApp => ( + + {whatsApp.name} + + {renderStatusToolTips(whatsApp)} + + + ( - { - handleOpenConfirmationModal("delete", whatsApp.id); - }} - > - - + + {renderActionButtons(whatsApp)} + )} - /> - - - - ))} - - )} - -
-
-
- )} - /> - + /> + + + + + {format(parseISO(whatsApp.updatedAt), "dd/MM/yy HH:mm")} + + + {whatsApp.isDefault && ( +
+ +
+ )} +
+ + + ( + handleEditWhatsApp(whatsApp)} + > + + + )} + /> + + + ( + { + handleOpenConfirmationModal("delete", whatsApp.id); + }} + > + + + )} + /> + + + + ))} + + )} + + + + + )} + /> + ); }; diff --git a/frontend/src/pages/Queues/index.js b/frontend/src/pages/Queues/index.js index 25c39e3..4df3e78 100644 --- a/frontend/src/pages/Queues/index.js +++ b/frontend/src/pages/Queues/index.js @@ -91,7 +91,7 @@ const reducer = (state, action) => { const Queues = () => { const classes = useStyles(); - const { user } = useContext(AuthContext); + const { user } = useContext(AuthContext); const [queues, dispatch] = useReducer(reducer, []); const [loading, setLoading] = useState(false); @@ -163,17 +163,16 @@ const Queues = () => { setSelectedQueue(null); }; - return ( + return ( ( - + role={user.profile} + perform="queues-view:show" + yes={() => ( + { /> {i18n.t("queues.title")} - - - + + + ( + + + + )} + /> + + @@ -245,23 +254,42 @@ const Queues = () => { + + + - handleEditQueue(queue)} - > - - - - { - setSelectedQueue(queue); - setConfirmModalOpen(true); - }} - > - - + + + ( + handleEditQueue(queue)} + > + + + )} + /> + + + ( + { + setSelectedQueue(queue); + setConfirmModalOpen(true); + }} + > + + + )} + /> + ))} @@ -271,8 +299,8 @@ const Queues = () => {
- )} - /> + )} + /> ); }; diff --git a/frontend/src/rules.js b/frontend/src/rules.js index 29767af..ee543ed 100644 --- a/frontend/src/rules.js +++ b/frontend/src/rules.js @@ -5,6 +5,8 @@ const rules = { admin: { static: [ + "show-icon-edit-whatsapp", + "drawer-admin-items:view", "tickets-manager:showall", "user-modal:editProfile", @@ -22,6 +24,13 @@ const rules = { master: { static: [ + + "show-icon-edit-whatsapp", + "show-icon-add-queue", + "show-icon-edit-queue", + "show-icon-delete-queue", + + "drawer-admin-items:view", "tickets-manager:showall", "user-modal:editProfile",