Skip to content

Commit

Permalink
feat: update locales hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
g-saracca committed Nov 11, 2024
1 parent b21977b commit b8d127b
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const CollectionForm = ({
defaultCollectionFacets
}: CollectionFormProps) => {
const formContainerRef = useRef<HTMLDivElement>(null)
const { t } = useTranslation('createCollection')
const { t } = useTranslation('shared', { keyPrefix: 'collectionForm' })
const navigate = useNavigate()

const { submitForm, submitError, submissionStatus } = useSubmitCollection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const BrowseSearchFacetsSection = ({
allFacetableMetadataFields,
allMetadataBlocksInfo
}: BrowseSearchFacetsSectionProps) => {
const { t } = useTranslation('createCollection')
const { t } = useTranslation('shared', { keyPrefix: 'collectionForm' })
const { control } = useFormContext()
const useBrowseSearchFacetsFromParentCheckedValue = useWatch({
name: USE_FACETS_FROM_PARENT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const FacetsFromParentCheckbox = ({
defaultCollectionFacets,
resetAvailableItems
}: FacetsFromParentCheckboxProps) => {
const { t } = useTranslation('createCollection')
const { t } = useTranslation('shared', { keyPrefix: 'collectionForm' })
const { control, setValue } = useFormContext()
const hostCollectionFieldValue = useWatch({ name: 'hostCollection' }) as string

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface FieldsFromParentCheckboxProps {
}

export const FieldsFromParentCheckbox = ({ defaultValues }: FieldsFromParentCheckboxProps) => {
const { t } = useTranslation('createCollection')
const { t } = useTranslation('shared', { keyPrefix: 'collectionForm' })
const checkboxID = useId()
const { control, setValue } = useFormContext()
const [showResetConfirmationModal, setShowResetConfirmationModal] = useState(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface ContactsFieldProps {
}

export const ContactsField = ({ rules }: ContactsFieldProps) => {
const { t } = useTranslation('createCollection')
const { t } = useTranslation('shared', { keyPrefix: 'collectionForm' })
const { control } = useFormContext()

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Col, Form, Stack, Tooltip } from '@iqss/dataverse-design-system'
import styles from './TopFieldsSection.module.scss'

export const DescriptionField = () => {
const { t } = useTranslation('createCollection')
const { t } = useTranslation('shared', { keyPrefix: 'collectionForm' })
const { control } = useFormContext()

const HtmlWordTooltip = ({ children }: { children: ReactNode }) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface IdentifierFieldProps {
}

export const IdentifierField = ({ rules }: IdentifierFieldProps) => {
const { t } = useTranslation('createCollection')
const { t } = useTranslation('shared', { keyPrefix: 'collectionForm' })
const { control, setValue } = useFormContext()
const nameFieldValue = useWatch({ name: 'name' }) as string

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { IdentifierField } from './IdentifierField'
import { DescriptionField } from './DescriptionField'

export const TopFieldsSection = () => {
const { t } = useTranslation('createCollection')
const { t } = useTranslation('shared', { keyPrefix: 'collectionForm' })
const { control } = useFormContext()

const hostCollectionRules: UseControllerProps['rules'] = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { WriteError } from '@iqss/dataverse-client-javascript'
import {
CollectionFormData,
CollectionFormMetadataBlocks,
CollectionFormValuesOnSubmit,
FormattedCollectionInputLevels
} from '../types'
import { CollectionFormData, CollectionFormValuesOnSubmit } from '../types'
import { CollectionRepository } from '@/collection/domain/repositories/CollectionRepository'
import {
EditCreateCollectionFormMode,
Expand Down Expand Up @@ -62,17 +57,17 @@ export function useSubmitCollection(

const metadataBlockNamesDTO =
CollectionFormHelper.formatFormMetadataBlockNamesToMetadataBlockNamesDTO(
formData[METADATA_BLOCKS_NAMES_GROUPER] as CollectionFormMetadataBlocks
formData[METADATA_BLOCKS_NAMES_GROUPER]
)

const inputLevelsDTO = CollectionFormHelper.formatFormInputLevelsToInputLevelsDTO(
metadataBlockNamesDTO,
formData[INPUT_LEVELS_GROUPER] as FormattedCollectionInputLevels
formData[INPUT_LEVELS_GROUPER]
)

const facetIdsDTO = formData.facetIds.map((facet) => facet.value)

const useFieldsFromParentChecked = formData[USE_FIELDS_FROM_PARENT] as boolean
const useFieldsFromParentChecked = formData[USE_FIELDS_FROM_PARENT]

const newCollection: CollectionDTO = {
name: formData.name,
Expand Down

0 comments on commit b8d127b

Please sign in to comment.