From f84a16c967ef5249a4a6b81adacdbd5991f0dacc Mon Sep 17 00:00:00 2001 From: William Wills Date: Fri, 26 Jul 2024 11:22:48 -0400 Subject: [PATCH] fix non-translatable text --- .../blocks/forms/CoBenifetsForm.tsx | 4 +- .../blocks/forms/EstimationsForm.tsx | 8 ++- .../components/blocks/forms/IssuancesForm.tsx | 12 ++-- .../components/blocks/forms/LabelsForm.tsx | 18 +++--- .../components/blocks/forms/ProjectForm.tsx | 42 +++++++------- .../blocks/forms/ProjectLocationsForm.tsx | 10 ++-- .../components/blocks/forms/RatingsForm.tsx | 12 ++-- .../blocks/forms/RelatedProjectsForm.tsx | 8 ++- .../components/blocks/forms/SplitUnitForm.tsx | 15 +++-- .../components/blocks/forms/UnitForm.tsx | 38 +++++++------ .../blocks/forms/UnitIssuanceForm.tsx | 43 ++++++++------- .../blocks/forms/UnitLabelsForm.tsx | 18 +++--- .../components/blocks/layout/PageCounter.tsx | 5 +- .../components/blocks/modals/AuditModal.tsx | 53 +++++++++++++----- .../blocks/tables/ProjectsListTable.tsx | 5 +- .../components/blocks/widgets/OrgUidBadge.tsx | 7 ++- .../blocks/widgets/OrganizationSelector.tsx | 18 +++--- .../blocks/widgets/SyncIndicator.tsx | 20 +++++-- src/renderer/translations/tokens/en-US.json | 55 ++++++++++++++++++- 19 files changed, 261 insertions(+), 130 deletions(-) diff --git a/src/renderer/components/blocks/forms/CoBenifetsForm.tsx b/src/renderer/components/blocks/forms/CoBenifetsForm.tsx index 7388793f..4749a3b0 100644 --- a/src/renderer/components/blocks/forms/CoBenifetsForm.tsx +++ b/src/renderer/components/blocks/forms/CoBenifetsForm.tsx @@ -5,6 +5,7 @@ import * as yup from 'yup'; import { CoBenefit } from '@/schemas/CoBenefit.schema'; import { PickList } from '@/schemas/PickList.schema'; import { deepOmit, validateAndSubmitFieldArrayForm } from '@/utils/formik-utils'; +import { useIntl } from 'react-intl'; const validationSchema = yup.object({ cobenefits: yup.array().of( @@ -26,6 +27,7 @@ export interface CoBenefitsFormRef { const CoBenefitsForm = forwardRef( ({ readonly = false, data, picklistOptions }, ref) => { + const intl = useIntl(); const formikRef = useRef>(null); useImperativeHandle(ref, () => ({ @@ -58,7 +60,7 @@ const CoBenefitsForm = forwardRef(
(({ readonly = false, data }, ref) => { + const intl = useIntl(); const formikRef = useRef>(null); useImperativeHandle(ref, () => ({ @@ -65,7 +67,7 @@ const EstimationsForm = forwardRef(({
(({ /> (({ /> ( ({ readonly = false, data = defaultIssuanceData, showUnits = false, picklistOptions }, ref) => { + const intl = useIntl(); const formikRef = useRef>(null); useImperativeHandle(ref, () => ({ @@ -75,7 +77,7 @@ const IssuancesForm = forwardRef(
( /> ( /> ( /> ( /> (({ readonly = false, data, picklistOptions }, ref) => { + const intl = useIntl(); const formikRef = useRef>(null); useImperativeHandle(ref, () => ({ @@ -93,7 +95,7 @@ const LabelsForm = forwardRef(({ readonly = fals
(({ readonly = fals /> (({ readonly = fals /> (({ readonly = fals /> (({ readonly = fals /> (({ readonly = fals /> (({ readonly = fals /> (({ readonly = fals /> ): Project => { const ProjectForm: React.FC = forwardRef( ({ readonly = false, data = {}, picklistOptions }, ref) => { + const intl = useIntl(); const formikRef = React.useRef>(null); useImperativeHandle(ref, () => ({ @@ -105,7 +107,7 @@ const ProjectForm: React.FC = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef = forwardRef ( ({ readonly = false, data, picklistOptions }, ref) => { + const intl = useIntl(); const formikRef = useRef>(null); useImperativeHandle(ref, () => ({ @@ -66,7 +68,7 @@ const ProjectLocationsForm = forwardRef (({ readonly = false, data, picklistOptions }, ref) => { + const intl = useIntl(); const formikRef = useRef>(null); useImperativeHandle(ref, () => ({ @@ -68,7 +70,7 @@ const RatingsForm = forwardRef(({ readonly = f
(({ readonly = f /> (({ readonly = f /> (({ readonly = f /> (({ readonly = f /> ( ({ readonly = false, data }, ref) => { + const intl = useIntl(); const formikRef = useRef>(null); const [orgUid] = useQueryParamState('orgUid'); @@ -70,21 +72,21 @@ const RelatedProjectsForm = forwardRef (({ picklistOptions }, ref) => { + const intl = useIntl(); const formikRef = useRef>(null); useImperativeHandle(ref, () => ({ @@ -89,19 +91,24 @@ const SplitUnitForm = forwardRef(({ pickli + - diff --git a/src/renderer/components/blocks/forms/UnitForm.tsx b/src/renderer/components/blocks/forms/UnitForm.tsx index e53b0a77..72283c3e 100644 --- a/src/renderer/components/blocks/forms/UnitForm.tsx +++ b/src/renderer/components/blocks/forms/UnitForm.tsx @@ -6,6 +6,7 @@ import { Unit } from '@/schemas/Unit.schema'; import { useGetHomeOrgQuery, useGetProjectQuery } from '@/api'; import { PickList } from '@/schemas/PickList.schema'; import { useGetProjectOptionsList } from '@/hooks'; +import { useIntl } from 'react-intl'; function removeNullFields(obj) { // Check if the input is an object and not null @@ -75,6 +76,7 @@ export interface UnitFormRef { } const UnitForm = forwardRef(({ readonly = false, data: unit, picklistOptions }, ref) => { + const intl = useIntl(); const formikRef = useRef>(null); const { data: homeOrg, isLoading: isHomeOrgLoading } = useGetHomeOrgQuery(); const [error, setError] = useState(null); @@ -182,7 +184,7 @@ const UnitForm = forwardRef(({ readonly = false, dat (({ readonly = false, dat /> (({ readonly = false, dat (({ readonly = false, dat (({ readonly = false, dat (({ readonly = false, dat (({ readonly = false, dat (({ readonly = false, dat (({ readonly = false, dat (({ readonly = false, dat (({ readonly = false, dat
(({ readonly = false, dat
(({ readonly = false, dat (({ readonly = false, dat (({ readonly = false, dat (({ readonly = false, dat (({ readonly = false, dat ( ({ data: issuance, selectedWarehouseProjectId }, ref) => { + const intl = useIntl(); const [selectedIssuance, setSelectedIssuance] = useState(issuance || undefined); const [error, setError] = useState(null); - const { - data: projectData, - isLoading: isProjectLoading, - } = useGetProjectQuery( + const { data: projectData, isLoading: isProjectLoading } = useGetProjectQuery( // @ts-ignore { warehouseProjectId: selectedWarehouseProjectId }, { skip: !selectedWarehouseProjectId }, @@ -37,7 +35,7 @@ const UnitIssuanceForm = forwardRef( return; } - return [isEmpty(errors) ? null : errors, { issuance: omit(selectedIssuance, ['orgUid'])}]; + return [isEmpty(errors) ? null : errors, { issuance: omit(selectedIssuance, ['orgUid']) }]; }, })); @@ -45,23 +43,28 @@ const UnitIssuanceForm = forwardRef( if (isProjectLoading || !projectData?.issuances) { return []; } - return projectData.issuances.map((issuance): SelectOption => ({ - label: `${dayjs(issuance.startDate).format('DD/MM/YYYY')} - ${dayjs(issuance.endDate).format('DD/MM/YYYY')}`, - value: issuance.id || '', - })); + return projectData.issuances.map( + (issuance): SelectOption => ({ + label: `${dayjs(issuance.startDate).format('DD/MM/YYYY')} - ${dayjs(issuance.endDate).format('DD/MM/YYYY')}`, + value: issuance.id || '', + }), + ); }, [projectData, isProjectLoading]); - const handleSetIssuance = useCallback((value) => { - setError(null); - const selectedIssuanceId = value; - const foundIssuance = projectData?.issuances?.find(issuance => issuance.id === selectedIssuanceId); - setSelectedIssuance(foundIssuance); - }, [projectData]); + const handleSetIssuance = useCallback( + (value) => { + setError(null); + const selectedIssuanceId = value; + const foundIssuance = projectData?.issuances?.find((issuance) => issuance.id === selectedIssuanceId); + setSelectedIssuance(foundIssuance); + }, + [projectData], + ); return (