Skip to content
4 changes: 2 additions & 2 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"Additional fields": "Additional fields",
"Address": "Address",
"Advanced": "Advanced",
"All your certifications were successfully removed": "All your certifications were successfully removed",
"All_female": "All",
"All_male": "All",
"Amount gross": "Tot. gross",
Expand Down Expand Up @@ -499,7 +498,6 @@
"There was an error": "There was an error",
"There was an error adding this certification.": "There was an error adding this certification.",
"There was an error removing your certification": "There was an error removing your certification",
"There was an error removing your certifications": "There was an error removing your certifications",
"There was an error validating your tax id. Please check your name, surname, gender, date of birth or place of birth": "There was an error validating your tax id. Please check your name, surname, gender, date of birth or place of birth",
"This email is already in use.": "This email is already in use.",
"This field is shared with the base section": "This field is shared with the base section",
Expand Down Expand Up @@ -787,6 +785,8 @@
"BUGFORM_UPLOAD_PROGRESS": "{{num}} uploaded",
"BUGFORM_UPLOAD_PROGRESS_plural": "{{num}} uploaded"
},
"All your certifications were successfully removed": "All your certifications were successfully removed",
"There was an error removing your certifications": "There was an error removing your certifications",
"API_ERROR_MESSAGE::Click on \"Sign up\" and try again.": "",
"API_ERROR_MESSAGE::Something went wrong": "",
"Click on \"Sign up\" and try again.": "",
Expand Down
4 changes: 2 additions & 2 deletions src/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"Additional fields": "Campos adicionales",
"Address": "Dirección",
"Advanced": "Avanzado",
"All your certifications were successfully removed": "Todas tus certificaciones fueron eliminadas con éxito",
"All_female": "Todas",
"All_male": "Todos",
"Amount gross": "Tot. Bruto",
Expand Down Expand Up @@ -499,7 +498,6 @@
"There was an error": "Hubo un error",
"There was an error adding this certification.": "Hubo un error al añadir esta certificación.",
"There was an error removing your certification": "Hubo un error al eliminar tu certificación",
"There was an error removing your certifications": "Hubo un error al eliminar tsu certificaciones",
"There was an error validating your tax id. Please check your name, surname, gender, date of birth or place of birth": "Hubo un error al validar su identificación fiscal. Por favor verifique su nombre, apellido, género, fecha de nacimiento o ciudad de nacimiento",
"This email is already in use.": "Este correo ya está vinculado a otra cuenta.",
"This field is shared with the base section": "Este campo se comparte con la sección base",
Expand Down Expand Up @@ -787,6 +785,8 @@
"BUGFORM_UPLOAD_PROGRESS": "{{num}} subido",
"BUGFORM_UPLOAD_PROGRESS_plural": "{{num}} subidos"
},
"All your certifications were successfully removed": "Todas tus certificaciones fueron eliminadas con éxito",
"There was an error removing your certifications": "Hubo un error al eliminar tsu certificaciones",
"API_ERROR_MESSAGE::Click on \"Sign up\" and try again.": "",
"API_ERROR_MESSAGE::Something went wrong": "",
"Click on \"Sign up\" and try again.": "",
Expand Down
4 changes: 2 additions & 2 deletions src/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
"Additional fields": "Campi addizionali",
"Address": "Indirizzo",
"Advanced": "Avanzate",
"All your certifications were successfully removed": "Tutte le tue certificazioni sono state rimosse con successo",
"All_female": "Tutte",
"All_male": "Tutti",
"Amount gross": "Tot. Lordo",
Expand Down Expand Up @@ -499,7 +498,6 @@
"There was an error": "Si è presentato un errore",
"There was an error adding this certification.": "Si è presentato un errore nel caricamento della certificazione",
"There was an error removing your certification": "Si è presentato un errore nella rimozione della tua certificazione",
"There was an error removing your certifications": "Si è presentato un errore nella rimozione delle tue certificazioni",
"There was an error validating your tax id. Please check your name, surname, gender, date of birth or place of birth": "C'è stato un errore durante la validazione del tuo identificativo fiscale. Per favore controlla il tuo nome, cognome, genere, data di nascita o città di nascita",
"This email is already in use.": "Questa email è già collegata a un account esistente.",
"This field is shared with the base section": "Il campo è condiviso con la sezione base",
Expand Down Expand Up @@ -787,6 +785,8 @@
"BUGFORM_UPLOAD_PROGRESS": "{{num}} caricato",
"BUGFORM_UPLOAD_PROGRESS_plural": "{{num}} caricati"
},
"All your certifications were successfully removed": "Tutte le tue certificazioni sono state rimosse con successo",
"There was an error removing your certifications": "Si è presentato un errore nella rimozione delle tue certificazioni",
"API_ERROR_MESSAGE::Click on \"Sign up\" and try again.": "",
"API_ERROR_MESSAGE::Something went wrong": "",
"Click on \"Sign up\" and try again.": "",
Expand Down
7 changes: 5 additions & 2 deletions src/pages/MyBugs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useTranslation } from "react-i18next";
import { shallowEqual, useSelector } from "react-redux";
import { useLocation } from "react-router-dom";
import { PageTemplate } from "src/features/PageTemplate";
import { useGetUsersMeBugsQuery } from "src/services/tryberApi";
import i18n from "../../i18n";
import {
fetchMyBugs,
Expand All @@ -21,9 +22,9 @@ import {
} from "../../redux/myBugs/actionCreator";
import { coloredStatus } from "../../redux/myBugs/utils";
import { useAppDispatch } from "../../redux/provider";
import { MyBugsColumns } from "./columns";
import MyBugsFilters from "./MyBugsFilters";
import MyBugsTable from "./MyBugsTable";
import { MyBugsColumns } from "./columns";

export default function MyBugs() {
const { search } = useLocation();
Expand All @@ -42,9 +43,11 @@ export default function MyBugs() {
selectedCampaign,
selectedSeverity,
selectedStatus,
isLoading,
// isLoading,
} = useSelector((state: GeneralState) => state.myBugs, shallowEqual);

const { isLoading, data } = useGetUsersMeBugsQuery({});

const { results, limit, total, start, order, orderBy } = bugsList;

const changePagination = (newPage: number) => {
Expand Down
14 changes: 5 additions & 9 deletions src/pages/Profile/HeaderProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,24 @@ import {
StarFill,
} from "react-bootstrap-icons";
import { useTranslation } from "react-i18next";
import { shallowEqual, useSelector } from "react-redux";
import { SkeletonHeader } from "src/pages/Profile/SkeletonHeader";
import siteWideMessageStore from "src/redux/siteWideMessages";
import { useGetUsersMeQuery } from "src/services/tryberApi";
import WPAPI from "src/utils/wpapi";
import styled from "styled-components";

export const HeaderProfile = () => {
const [submittingMailConfirm, setSubmittingMailConfirm] = useState(false);
const { add } = siteWideMessageStore();
const { t } = useTranslation();
const { user, loading } = useSelector(
(state: GeneralState) => ({
user: state.user.user,
loading: state.user.loading,
}),
shallowEqual
);
const { data: user, isLoading: loading } = useGetUsersMeQuery({
fields: "all",
});

const handleMailConfirm = async () => {
try {
setSubmittingMailConfirm(true);
const data = await WPAPI.sendMailConfirmation();
await WPAPI.sendMailConfirmation();
add({
message: t(
"User mail validation:::An Email has been sent to the provided address"
Expand Down
11 changes: 3 additions & 8 deletions src/pages/Profile/TabAdvanced/Certifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import {
Button,
CSSGrid,
} from "@appquality/appquality-design-system";
import React from "react";
import { useTranslation } from "react-i18next";
import { shallowEqual, useSelector } from "react-redux";
import { HalfColumnButton } from "src/features/HalfColumnButton";
import modalStore from "src/redux/modal";
import { components } from "src/utils/schema";
import { useGetUsersMeQuery } from "src/services/tryberApi";
import {
DeleteCertificationsModal,
DeleteCertificationsModalFooter,
Expand All @@ -22,12 +20,9 @@ import SingleCertification from "./SingleCertification";
const Certifications = () => {
const { t } = useTranslation();
const { open } = modalStore();
const { data } = useGetUsersMeQuery({ fields: "certifications" });

const userCertifications: components["schemas"]["Certification"][] | boolean =
useSelector(
(state: GeneralState) => state.user.user?.certifications || [],
shallowEqual
);
const userCertifications = data?.certifications || false;

return (
<>
Expand Down
18 changes: 5 additions & 13 deletions src/pages/Profile/TabAdvanced/CustomUserFields.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
import { Accordion, Skeleton } from "@appquality/appquality-design-system";
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { shallowEqual, useDispatch, useSelector } from "react-redux";
import { useDispatch } from "react-redux";
import { getCustomUserFields } from "src/redux/user/actions/getCustomUserFields";
import { operations } from "src/utils/schema";
import { useGetCustomUserFieldsQuery } from "src/services/tryberApi";
import CufField from "./CufField";

export const CustomUserFields = () => {
const { i18n } = useTranslation();
const dispatch = useDispatch();
const {
customUserFields,
}: {
customUserFields?: operations["get-customUserFields"]["responses"]["200"]["content"]["application/json"];
} = useSelector(
(state: GeneralState) => ({
customUserFields: state.user.customUserFields,
}),
shallowEqual
);
const { data: customUserFields } = useGetCustomUserFieldsQuery();

const [isLoading, setIsLoading] = useState(true);
const [groupOfFieldsWithoutGroup, setGroupOfFieldsWithoutGroup] = useState<
typeof customUserFields
Expand Down
47 changes: 23 additions & 24 deletions src/pages/Profile/TabAdvanced/DeleteCertificationsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { Button, CSSGrid, Text } from "@appquality/appquality-design-system";
import { useTranslation } from "react-i18next";
import React from "react";
import { components } from "src/utils/schema";
import modalStore from "src/redux/modal";
import { deleteCertification } from "src/redux/user/actions/deleteCertification";
import { useDispatch } from "react-redux";
import { addCertification } from "src/redux/user/actions/addCertification";
import modalStore from "src/redux/modal";
import { addMessage } from "src/redux/siteWideMessages/actionCreators";
import { useDeleteUsersMeCertificationsByCertificationIdMutation } from "src/services/tryberApi";
import { components } from "src/utils/schema";
import SingleCertification from "./SingleCertification";

export const DeleteCertificationsModal = ({
Expand Down Expand Up @@ -38,35 +37,35 @@ export const DeleteCertificationsModal = ({

export const DeleteCertificationsModalFooter = ({
certification,
onSubmit,
onClose,
}: {
certification?: components["schemas"]["Certification"];
onSubmit?: () => void;
onClose?: () => void;
}) => {
const [deleteCertification] =
useDeleteUsersMeCertificationsByCertificationIdMutation();
const { close } = modalStore();
const { t } = useTranslation();
const dispatch = useDispatch();
const handleDeleteCertification = () => {
const handleDeleteCertification = async () => {
if (certification) {
if (!certification.id) return;
dispatch(
deleteCertification(
certification.id,
t("Certification successfully removed"),
t("There was an error removing your certification")
)
);
} else {
dispatch(
addCertification(
{ certifications: false },
t("All your certifications were successfully removed"),
t("There was an error removing your certifications")
)
);
if (onSubmit) onSubmit();
try {
await deleteCertification({
certificationId: certification.id,
}).unwrap();
dispatch(
addMessage(t("Certification successfully removed"), "success")
);
} catch (e) {
dispatch(
addMessage(
t("There was an error removing your certification"),
"danger"
)
);
return;
}
}
close();
};
Expand Down
28 changes: 10 additions & 18 deletions src/pages/Profile/TabAdvanced/MapCufValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@ import { FormikValues } from "formik";
import i18n from "i18next";
import { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { shallowEqual, useSelector } from "react-redux";
import {
useGetCustomUserFieldsQuery,
useGetUsersMeQuery,
} from "src/services/tryberApi";
import * as yup from "yup";
import { AdvancedFormValues } from "./types";

export const MapCufValues = () => {
const { additional, profession, education } = useSelector(
(state: GeneralState) => ({
additional: state.user.user?.additional,
profession: state.user.user?.profession,
education: state.user.user?.education,
}),
shallowEqual
);
const customUserFields = useSelector(
(state: GeneralState) => state.user.customUserFields,
shallowEqual
);
const { data, isLoading } = useGetUsersMeQuery({ fields: "all" });
const { data: customUserFields } = useGetCustomUserFieldsQuery();
const { additional, profession, education } = data || {};
const { t } = useTranslation();
const [initialUserValues, setInitialUserValues] =
useState<AdvancedFormValues>({
Expand Down Expand Up @@ -65,7 +59,7 @@ export const MapCufValues = () => {
: [];
schema["cuf_" + field.id] = yup.object();
values["cuf_" + field.id] =
selectValue && selectValue.hasOwnProperty("value")
selectValue && "value" in selectValue
? {
...selectValue,
label: selectValue.text,
Expand All @@ -80,9 +74,7 @@ export const MapCufValues = () => {
)
: [];
values["cuf_" + field.id] =
textValue && textValue.hasOwnProperty("value")
? textValue.value
: "";
textValue && "value" in textValue ? textValue.value : "";
const formatData = field.format ? field.format.split(";") : false;
const format = formatData ? new RegExp(formatData[0]) : false;
const lang = (i18n.language as SupportedLanguages) || "it";
Expand Down Expand Up @@ -112,7 +104,7 @@ export const MapCufValues = () => {
});
setInitialUserValues({ ...initialUserValues, ...values });
setValidationSchema({ ...validationSchema, ...schema });
}, [customUserFields]);
}, [customUserFields, isLoading]);
return {
initialUserValues: initialUserValues,
validationSchema: validationSchema,
Expand Down
Loading