• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IQSS / dataverse-frontend / 8365224760

20 Mar 2024 08:08PM UTC coverage: 97.413% (-0.06%) from 97.473%
8365224760

push

github

GermanSaracca
feat(DynamicFormFieldsRender): Initial setup with mocked data

563 of 588 branches covered (95.75%)

Branch coverage included in aggregate %.

21 of 22 new or added lines in 2 files covered. (95.45%)

1659 of 1693 relevant lines covered (97.99%)

3589.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.3
/src/sections/create-dataset/useDefineDatasetMetadataFormFields.tsx
1
import { useEffect, useRef, useState } from 'react'
2
import { getMetadataBlockInfoByCollectionId } from '../../metadata-block-info/domain/useCases/getMetadataBlockInfoByCollectionId'
3
import { MetadataBlockInfoRepository } from '../../metadata-block-info/domain/repositories/MetadataBlockInfoRepository'
4

5
/*
6
  ** Notes:
7
  - We will check which blocks to display on the create dataset form. (citation, geospatial, etc...)
8
  - We will use the getDatasetMetadataBlockFields use case to get the fields to render according to the Collection Id / Dataverse Id.
9
*/
10

11
export const useDefineDatasetMetadataFormFields = (
10✔
12
  metadataBlockInfoRepository: MetadataBlockInfoRepository
13
) => {
537✔
14
  const ref = useRef(false)
537✔
15
  const [fieldsToRender, setFieldsToRender] = useState<string[]>([])
537✔
16
  const [isLoading, setIsLoading] = useState<boolean>(true)
537✔
17
  const [error, setError] = useState<string | null>(null)
537✔
18

19
  useEffect(() => {
537✔
20
    const handleGetDatasetMetadataBlockFields = async () => {
54✔
21
      setIsLoading(true)
54✔
22
      try {
54✔
23
        const metadataBlocksInfo = await getMetadataBlockInfoByCollectionId(
54✔
24
          metadataBlockInfoRepository,
25
          'someCitation',
26
          true
27
        )
NEW
28
        console.log(metadataBlocksInfo)
×
29
        // setFieldsToRender(fields)
30
        // const { data } = await axios.get<{ status: string; data: MetadataBlockInfo2 }>(
31
        //   `http://localhost:8000/api/v1/metadatablocks/${MetadataBlockName.CITATION}`
32
        // )
33
        //const metadataBlockInfo = data.data
34
      } catch (err) {
35
        console.error(err)
54✔
36
        const errorMessage =
37
          err instanceof Error && err.message
54!
38
            ? err.message
39
            : 'Something went wrong getting the datasets'
40
        setError(errorMessage)
54✔
41
      } finally {
42
        setIsLoading(false)
54✔
43
      }
44
    }
45
    // if (!ref.current) {
46
    void handleGetDatasetMetadataBlockFields()
54✔
47
    // ref.current = true
48
    // }
49
  }, [])
50

51
  return {
537✔
52
    fieldsToRender,
53
    error,
54
    isLoading
55
  }
56
}
10✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc