Skip to content

Commit

Permalink
Melhoria no sistema de tradução
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh committed Dec 14, 2024
1 parent ed9bf77 commit 871123b
Show file tree
Hide file tree
Showing 71 changed files with 3,772 additions and 2,115 deletions.
4 changes: 3 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
"react-copy-to-clipboard": "^5.1.0",
"react-csv": "^2.2.2",
"react-dom": "^16.13.1",
"react-i18next": "^10.11.0",
"react-modal-image": "^2.5.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3",
"react-tagcloud": "^2.3.3",
"react-toastify": "^6.0.9",
"react-world-flags": "^1.6.0",
"recharts": "^2.13.0",
"socket.io-client": "^3.0.5",
"use-sound": "^2.0.1",
Expand All @@ -59,4 +61,4 @@
"last 1 safari version"
]
}
}
}
14 changes: 7 additions & 7 deletions frontend/src/components/AcceptTicketWithoutQueueModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import {
} from "@material-ui/core";
import PropTypes from "prop-types";
import React, { useCallback, useContext, useState } from "react";
import { useTranslation } from "react-i18next";
import { useHistory } from "react-router-dom";
import { AuthContext } from "../../context/Auth/AuthContext";
import toastError from "../../errors/toastError";
import api from "../../services/api";
import { i18n } from "../../translate/i18n";
import ButtonWithSpinner from "../ButtonWithSpinner";

const useStyles = makeStyles((theme) => ({
Expand All @@ -40,7 +40,7 @@ const AcceptTicketWithouSelectQueue = ({ modalOpen, onClose, ticketId }) => {
const [selectedQueue, setSelectedQueue] = useState(INITIAL_QUEUE_VALUE);
const [loading, setLoading] = useState(false);
const { user } = useContext(AuthContext);

const { t } = useTranslation();
const userId = user?.id;

const handleClose = useCallback(() => {
Expand Down Expand Up @@ -74,16 +74,16 @@ const AcceptTicketWithouSelectQueue = ({ modalOpen, onClose, ticketId }) => {
aria-describedby="accept-ticket-dialog-description"
>
<DialogTitle id="accept-ticket-dialog-title">
{i18n.t("ticketsList.acceptModal.title")}
{t("ticketsList.acceptModal.title")}
</DialogTitle>
<DialogContent dividers>
<FormControl variant="outlined" className={classes.maxWidth}>
<InputLabel>{i18n.t("ticketsList.acceptModal.queue")}</InputLabel>
<InputLabel>{t("ticketsList.acceptModal.queue")}</InputLabel>
<Select
value={selectedQueue}
className={classes.autoComplete}
onChange={(e) => setSelectedQueue(e.target.value)}
label={i18n.t("ticketsList.acceptModal.queue")}
label={t("ticketsList.acceptModal.queue")}
>
<MenuItem value={''}>&nbsp;</MenuItem>
{user.queues.map((queue) => (
Expand All @@ -99,7 +99,7 @@ const AcceptTicketWithouSelectQueue = ({ modalOpen, onClose, ticketId }) => {
disabled={loading}
variant="outlined"
>
{i18n.t("ticketsList.buttons.cancel")}
{t("ticketsList.buttons.cancel")}
</Button>
<ButtonWithSpinner
variant="contained"
Expand All @@ -109,7 +109,7 @@ const AcceptTicketWithouSelectQueue = ({ modalOpen, onClose, ticketId }) => {
color="primary"
loading={loading}
>
{i18n.t("ticketsList.buttons.start")}
{t("ticketsList.buttons.start")}
</ButtonWithSpinner>
</DialogActions>
</Dialog>
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/ConfirmationModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import Typography from "@material-ui/core/Typography";
import { makeStyles } from "@material-ui/core/styles";
import { Cancel, CheckCircle } from "@material-ui/icons";
import React from "react";

import { i18n } from "../../translate/i18n";
import { useTranslation } from "react-i18next";

const useStyles = makeStyles((theme) => ({
dialogTitle: {
Expand All @@ -33,6 +32,7 @@ const useStyles = makeStyles((theme) => ({

const ConfirmationModal = ({ title, children, open, onClose, onConfirm }) => {
const classes = useStyles();
const { t } = useTranslation();

return (
<Dialog
Expand All @@ -55,7 +55,7 @@ const ConfirmationModal = ({ title, children, open, onClose, onConfirm }) => {
className={classes.cancelButton}
startIcon={<Cancel />}
>
{i18n.t("confirmationModal.buttons.cancel")}
{t("confirmationModal.buttons.cancel")}
</Button>
<Button
variant="contained"
Expand All @@ -66,7 +66,7 @@ const ConfirmationModal = ({ title, children, open, onClose, onConfirm }) => {
className={classes.confirmButton}
startIcon={<CheckCircle />}
>
{i18n.t("confirmationModal.buttons.confirm")}
{t("confirmationModal.buttons.confirm")}
</Button>
</DialogActions>
</Dialog>
Expand Down
37 changes: 16 additions & 21 deletions frontend/src/components/ContactDrawer/index.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
import React, { useState, useContext } from "react";

import Drawer from "@material-ui/core/Drawer";
import IconButton from "@material-ui/core/IconButton";
import InputLabel from "@material-ui/core/InputLabel";
import Link from "@material-ui/core/Link";
import { makeStyles } from "@material-ui/core/styles";
import Typography from "@material-ui/core/Typography";
import IconButton from "@material-ui/core/IconButton";
import CloseIcon from "@material-ui/icons/Close";
import Drawer from "@material-ui/core/Drawer";
import Link from "@material-ui/core/Link";
import InputLabel from "@material-ui/core/InputLabel";
import React, { useContext, useState } from "react";
//import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import Paper from "@material-ui/core/Paper";

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

import ContactModal from "../ContactModal";
import { useTranslation } from "react-i18next";
import { AuthContext } from "../../context/Auth/AuthContext";
import ContactDrawerSkeleton from "../ContactDrawerSkeleton";
import ContactModal from "../ContactModal";
import CopyToClipboard from "../CopyToClipboard";
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 @@ -55,14 +52,12 @@ const useStyles = makeStyles(theme => ({
overflowY: "scroll",
...theme.scrollbarStyles,
},

contactAvatar: {
margin: 15,
width: 160,
height: 160,
borderRadius: 10,
},

contactHeader: {
display: "flex",
padding: 8,
Expand All @@ -73,7 +68,6 @@ const useStyles = makeStyles(theme => ({
margin: 4,
},
},

contactDetails: {
marginTop: 8,
padding: 8,
Expand All @@ -90,6 +84,7 @@ const ContactDrawer = ({ open, handleDrawerClose, contact, loading }) => {
const classes = useStyles();
const { user } = useContext(AuthContext);
const [modalOpen, setModalOpen] = useState(false);
const { t } = useTranslation();

return (
<Drawer
Expand All @@ -114,7 +109,7 @@ const ContactDrawer = ({ open, handleDrawerClose, contact, loading }) => {
<CloseIcon />
</IconButton>
<Typography style={{ justifySelf: "center" }}>
{i18n.t("contactDrawer.header")}
{t("contactDrawer.header")}
</Typography>
</div>
{loading ? (
Expand All @@ -126,10 +121,10 @@ const ContactDrawer = ({ open, handleDrawerClose, contact, loading }) => {
<Typography>
{contact.name}
<CopyToClipboard content={contact.name} color="secondary" />
</Typography>
</Typography>
<Typography>
<Link href={`tel:${user.isTricked === "enabled" ? contact.number : contact.number.slice(0,-4) + "****"}`}>{user.isTricked === "enabled" ? contact.number : contact.number.slice(0,-4) + "****"}</Link>
<CopyToClipboard content={user.isTricked === "enabled" ? contact.number : contact.number.slice(0,-4) + "****"} color="secondary" />
<Link href={`tel:${user.isTricked === "enabled" ? contact.number : contact.number.slice(0, -4) + "****"}`}>{user.isTricked === "enabled" ? contact.number : contact.number.slice(0, -4) + "****"}</Link>
<CopyToClipboard content={user.isTricked === "enabled" ? contact.number : contact.number.slice(0, -4) + "****"} color="secondary" />
</Typography>
{contact.email && (
<Typography>
Expand All @@ -142,7 +137,7 @@ const ContactDrawer = ({ open, handleDrawerClose, contact, loading }) => {
color="primary"
onClick={() => setModalOpen(true)}
>
{i18n.t("contactDrawer.buttons.edit")}
{t("contactDrawer.buttons.edit")}
</Button>
</Paper>
<TagsContainer contact={contact} className={classes.contactTags} />
Expand All @@ -153,7 +148,7 @@ const ContactDrawer = ({ open, handleDrawerClose, contact, loading }) => {
contactId={contact.id}
></ContactModal>
<Typography variant="subtitle1">
{i18n.t("contactDrawer.extraInfo")}
{t("contactDrawer.extraInfo")}
</Typography>
{contact?.extraInfo?.map(info => (
<Paper
Expand Down
12 changes: 7 additions & 5 deletions frontend/src/components/ContactDrawerSkeleton/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from "react";
import Skeleton from "@material-ui/lab/Skeleton";
import Typography from "@material-ui/core/Typography";
import Paper from "@material-ui/core/Paper";
import { i18n } from "../../translate/i18n";
import Typography from "@material-ui/core/Typography";
import Skeleton from "@material-ui/lab/Skeleton";
import React from "react";
import { useTranslation } from "react-i18next";

const ContactDrawerSkeleton = ({ classes }) => {
const { t } = useTranslation();

return (
<div className={classes.content}>
<Paper square variant="outlined" className={classes.contactHeader}>
Expand All @@ -21,7 +23,7 @@ const ContactDrawerSkeleton = ({ classes }) => {
</Paper>
<Paper square className={classes.contactDetails}>
<Typography variant="subtitle1">
{i18n.t("contactDrawer.extraInfo")}
{t("contactDrawer.extraInfo")}
</Typography>
<Paper square variant="outlined" className={classes.contactExtraInfo}>
<Skeleton animation="wave" height={20} width={60} />
Expand Down
31 changes: 16 additions & 15 deletions frontend/src/components/ContactModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ import {
Formik,
} from "formik";
import React, { useContext, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { toast } from "react-toastify";
import * as Yup from "yup";
import { AuthContext } from "../../context/Auth/AuthContext";
import toastError from "../../errors/toastError";
import api from "../../services/api";
import { i18n } from "../../translate/i18n";

const useStyles = makeStyles((theme) => ({
root: {
Expand Down Expand Up @@ -68,6 +68,7 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
const classes = useStyles();
const { user } = useContext(AuthContext);
const [contact, setContact] = useState(initialState);
const { t } = useTranslation();

useEffect(() => {
const abortController = new AbortController();
Expand Down Expand Up @@ -108,7 +109,7 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
const { data } = await api.post("/contacts", values);
if (onSave) onSave(data);
}
toast.success(i18n.t("contactModal.success"));
toast.success(t("contactModal.success"));
handleClose();
} catch (err) {
toastError(err);
Expand All @@ -119,8 +120,8 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
<Dialog open={open} onClose={handleClose} maxWidth="lg" scroll="paper">
<DialogTitle>
{contactId
? i18n.t("contactModal.title.edit")
: i18n.t("contactModal.title.add")}
? t("contactModal.title.edit")
: t("contactModal.title.add")}
</DialogTitle>
<Formik
initialValues={contact}
Expand All @@ -135,11 +136,11 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
<Form>
<DialogContent dividers>
<Typography variant="subtitle1" gutterBottom>
{i18n.t("contactModal.form.mainInfo")}
{t("contactModal.form.mainInfo")}
</Typography>
<Field
as={TextField}
label={i18n.t("contactModal.form.name")}
label={t("contactModal.form.name")}
name="name"
autoFocus
error={touched.name && Boolean(errors.name)}
Expand All @@ -151,7 +152,7 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
{user.isTricked === "enabled" && (
<Field
as={TextField}
label={i18n.t("contactModal.form.number")}
label={t("contactModal.form.number")}
name="number"
error={touched.number && Boolean(errors.number)}
helperText={touched.number && errors.number}
Expand All @@ -162,7 +163,7 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
)}
<Field
as={TextField}
label={i18n.t("contactModal.form.email")}
label={t("contactModal.form.email")}
name="email"
error={touched.email && Boolean(errors.email)}
helperText={touched.email && errors.email}
Expand All @@ -175,7 +176,7 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
style={{ marginBottom: 8, marginTop: 12 }}
variant="subtitle1"
>
{i18n.t("contactModal.form.extraInfo")}
{t("contactModal.form.extraInfo")}
</Typography>
<FieldArray name="extraInfo">
{({ push, remove }) => (
Expand All @@ -188,15 +189,15 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
>
<Field
as={TextField}
label={i18n.t("contactModal.form.extraName")}
label={t("contactModal.form.extraName")}
name={`extraInfo[${index}].name`}
variant="outlined"
margin="dense"
className={classes.textField}
/>
<Field
as={TextField}
label={i18n.t("contactModal.form.extraValue")}
label={t("contactModal.form.extraValue")}
name={`extraInfo[${index}].value`}
variant="outlined"
margin="dense"
Expand All @@ -217,7 +218,7 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
color="primary"
onClick={() => push({ name: "", value: "" })}
>
+ {i18n.t("contactModal.buttons.addExtraInfo")}
+ {t("contactModal.buttons.addExtraInfo")}
</Button>
</div>
</>
Expand All @@ -231,7 +232,7 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
disabled={isSubmitting}
variant="outlined"
>
{i18n.t("contactModal.buttons.cancel")}
{t("contactModal.buttons.cancel")}
</Button>
<Button
type="submit"
Expand All @@ -241,8 +242,8 @@ const ContactModal = ({ open, onClose, contactId, initialValues, onSave }) => {
className={classes.btnWrapper}
>
{contactId
? i18n.t("contactModal.buttons.okEdit")
: i18n.t("contactModal.buttons.okAdd")}
? t("contactModal.buttons.okEdit")
: t("contactModal.buttons.okAdd")}
{isSubmitting && (
<CircularProgress
size={24}
Expand Down
Loading

0 comments on commit 871123b

Please sign in to comment.