Skip to content

Commit

Permalink
use named export
Browse files Browse the repository at this point in the history
  • Loading branch information
barbalex committed Oct 27, 2024
1 parent 78f2ca8 commit 899e00a
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 61 deletions.
4 changes: 1 addition & 3 deletions src/components/Projekte/Daten/CurrentIssue/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const query = gql`
${currentIssueFragment}
`

const CurrentIssue = () => {
export const Component = () => {
const { issueId } = useParams()

const { data, loading, error } = useQuery(query, {
Expand Down Expand Up @@ -75,5 +75,3 @@ const CurrentIssue = () => {
</ErrorBoundary>
)
}

export const Component = CurrentIssue
79 changes: 38 additions & 41 deletions src/components/Projekte/Daten/Ekfrequenz/KontrolljahrField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,41 @@ const StyledInput = styled(Input)`
}
`

const KontrolljahrField = ({
saveToDb,
name = 'kontrolljahre',
index,
kontrolljahre,
refetch,
}) => {
const [value, setValue] = useState(kontrolljahre[index])
useEffect(() => {
setValue(kontrolljahre[index])
}, [index, kontrolljahre])

const onChange = useCallback((event) => {
setValue(ifIsNumericAsNumber(event.target.value))
}, [])

const onBlur = useCallback(async () => {
const newVal = [...kontrolljahre]
if (value || value === 0) {
newVal[index] = value
} else {
newVal.splice(index, 1)
}
await saveToDb({ target: { name, value: newVal } })
refetch()
}, [kontrolljahre, value, saveToDb, name, refetch, index])

const onKeyDown = useCallback((e) => e.key === 'Enter' && onBlur(), [onBlur])

return (
<StyledInput
value={value}
type="number"
onChange={onChange}
onBlur={onBlur}
onKeyDown={onKeyDown}
/>
)
}

export default observer(KontrolljahrField)
export const KontrolljahrField = observer(
({ saveToDb, name = 'kontrolljahre', index, kontrolljahre, refetch }) => {
const [value, setValue] = useState(kontrolljahre[index])
useEffect(() => {
setValue(kontrolljahre[index])
}, [index, kontrolljahre])

const onChange = useCallback((event) => {
setValue(ifIsNumericAsNumber(event.target.value))
}, [])

const onBlur = useCallback(async () => {
const newVal = [...kontrolljahre]
if (value || value === 0) {
newVal[index] = value
} else {
newVal.splice(index, 1)
}
await saveToDb({ target: { name, value: newVal } })
refetch()
}, [kontrolljahre, value, saveToDb, name, refetch, index])

const onKeyDown = useCallback(
(e) => e.key === 'Enter' && onBlur(),
[onBlur],
)

return (
<StyledInput
value={value}
type="number"
onChange={onChange}
onBlur={onBlur}
onKeyDown={onKeyDown}
/>
)
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const StyledInput = styled(Input)`
}
`

const KontrolljahrFieldEmpty = ({
export const KontrolljahrFieldEmpty = ({
saveToDb,
name = 'kontrolljahre',
kontrolljahre,
Expand Down Expand Up @@ -45,5 +45,3 @@ const KontrolljahrFieldEmpty = ({
/>
)
}

export default KontrolljahrFieldEmpty
8 changes: 3 additions & 5 deletions src/components/Projekte/Daten/Ekfrequenz/Kontrolljahre.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { FaTimes } from 'react-icons/fa'
import IconButton from '@mui/material/IconButton'
import styled from '@emotion/styled'

import KontrolljahrField from './KontrolljahrField'
import KontrolljahrFieldEmpty from './KontrolljahrFieldEmpty'
import { KontrolljahrField } from './KontrolljahrField.jsx'
import { KontrolljahrFieldEmpty } from './KontrolljahrFieldEmpty.jsx'

const DelIcon = styled(IconButton)`
font-size: 1rem !important;
padding-top: 0 !important;
padding-bottom: 0 !important;
`

const Kontrolljahre = ({ kontrolljahre = [], saveToDb, refetch }) => {
export const Kontrolljahre = ({ kontrolljahre = [], saveToDb, refetch }) => {
const kontrolljahreSorted = [...kontrolljahre].sort(
(a, b) => (a ?? 999999) - b,
)
Expand Down Expand Up @@ -50,5 +50,3 @@ const Kontrolljahre = ({ kontrolljahre = [], saveToDb, refetch }) => {
/>,
]
}

export default Kontrolljahre
6 changes: 3 additions & 3 deletions src/components/Projekte/Daten/Ekfrequenz/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { useQueryClient } from '@tanstack/react-query'

import { TextField } from '../../../shared/TextField.jsx'
import { RadioButtonGroup } from '../../../shared/RadioButtonGroup.jsx'
import Kontrolljahre from './Kontrolljahre'
import { Kontrolljahre } from './Kontrolljahre.jsx'
import { FormTitle } from '../../../shared/FormTitle/index.jsx'
import query from './query.js'
import queryEkAbrechnungstypWertes from './queryEkAbrechnungstypWertes'
import { query } from './query.js'
import { queryEkAbrechnungstypWertes } from './queryEkAbrechnungstypWertes.js'
import { StoreContext } from '../../../../storeContext.js'
import { ifIsNumericAsNumber } from '../../../../modules/ifIsNumericAsNumber.js'
import { ekfrequenz } from '../../../shared/fragments.js'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Projekte/Daten/Ekfrequenz/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { gql } from '@apollo/client'

import { ekfrequenz } from '../../../shared/fragments.js'

export default gql`
export const query = gql`
query ekfrequenzByIdQuery($id: UUID!) {
ekfrequenzById(id: $id) {
...EkfrequenzFields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client'

export default gql`
export const queryEkAbrechnungstypWertes = gql`
query EkAbrechnungstypWertesQueryForEkfrequenz {
allEkAbrechnungstypWertes(
orderBy: SORT_ASC
Expand Down
4 changes: 2 additions & 2 deletions src/components/Projekte/Daten/Ekzaehleinheit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import { TextField } from '../../../shared/TextField.jsx'
import { Select } from '../../../shared/Select.jsx'
import { Checkbox2States } from '../../../shared/Checkbox2States.jsx'
import { FormTitle } from '../../../shared/FormTitle/index.jsx'
import query from './query.js'
import queryLists from './queryLists'
import { query } from './query.js'
import { queryLists } from './queryLists.js'
import { StoreContext } from '../../../../storeContext.js'
import { ifIsNumericAsNumber } from '../../../../modules/ifIsNumericAsNumber.js'
import { ErrorBoundary } from '../../../shared/ErrorBoundary.jsx'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Projekte/Daten/Ekzaehleinheit/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
tpopkontrzaehlEinheitWerte,
} from '../../../shared/fragments.js'

export default gql`
export const query = gql`
query ekzaehleinheitByIdQuery($id: UUID!) {
ekzaehleinheitById(id: $id) {
...EkzaehleinheitFields
Expand Down
2 changes: 1 addition & 1 deletion src/components/Projekte/Daten/Ekzaehleinheit/queryLists.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client'

export default gql`
export const queryLists = gql`
query EkzaehleinheitDataListQuery(
$filter: TpopkontrzaehlEinheitWerteFilter!
) {
Expand Down

0 comments on commit 899e00a

Please sign in to comment.