Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
barbalex committed Oct 28, 2024
1 parent 51db7b1 commit ef6a261
Show file tree
Hide file tree
Showing 25 changed files with 74 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { observer } from 'mobx-react-lite'
import { useApolloClient } from '@apollo/client'
import { useQueryClient } from '@tanstack/react-query'

import { Select } from '../../../../shared/Select.jsx'
import { StoreContext } from '../../../../../storeContext.js'
import { Select } from '../../../../../shared/Select.jsx'
import { StoreContext } from '../../../../../../storeContext.js'
import updateTpopkontrzaehlByIdGql from './updateTpopkontrzaehlById.js'
import { ifIsNumericAsNumber } from '../../../../../modules/ifIsNumericAsNumber.js'
import { ifIsNumericAsNumber } from '../../../../../../modules/ifIsNumericAsNumber.js'

const EinheitVal = styled.div`
grid-area: einheitVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { observer } from 'mobx-react-lite'
import { useApolloClient } from '@apollo/client'
import { useQueryClient } from '@tanstack/react-query'

import { TextField } from '../../../../shared/TextField.jsx'
import { StoreContext } from '../../../../../storeContext.js'
import { TextField } from '../../../../../shared/TextField.jsx'
import { StoreContext } from '../../../../../../storeContext.js'
import updateTpopkontrzaehlByIdGql from './updateTpopkontrzaehlById.js'
import { ifIsNumericAsNumber } from '../../../../../modules/ifIsNumericAsNumber.js'
import { ifIsNumericAsNumber } from '../../../../../../modules/ifIsNumericAsNumber.js'

const Geschaetzt = ({ row, refetch }) => {
const store = useContext(StoreContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { observer } from 'mobx-react-lite'
import { useApolloClient } from '@apollo/client'
import { useQueryClient } from '@tanstack/react-query'

import { TextField } from '../../../../shared/TextField.jsx'
import { StoreContext } from '../../../../../storeContext.js'
import { TextField } from '../../../../../shared/TextField.jsx'
import { StoreContext } from '../../../../../../storeContext.js'
import updateTpopkontrzaehlByIdGql from './updateTpopkontrzaehlById.js'
import { ifIsNumericAsNumber } from '../../../../../modules/ifIsNumericAsNumber.js'
import { ifIsNumericAsNumber } from '../../../../../../modules/ifIsNumericAsNumber.js'

const Gezaehlt = ({ row, refetch }) => {
const store = useContext(StoreContext)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { gql } from '@apollo/client'

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

export default gql`
mutation createTpopkontrzaehlForCount($tpopkontrId: UUID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import Gezaehlt from './Gezaehlt.jsx'
import Geschaetzt from './Geschaetzt.jsx'
import query from './query.js'
import createTpopkontrzaehl from './createTpopkontrzaehl.js'
import { StoreContext } from '../../../../../storeContext.js'
import { Error } from '../../../../shared/Error.jsx'
import { Spinner } from '../../../../shared/Spinner.jsx'
import { StoreContext } from '../../../../../../storeContext.js'
import { Error } from '../../../../../shared/Error.jsx'
import { Spinner } from '../../../../../shared/Spinner.jsx'

const AddIcon = styled(MdAddCircleOutline)`
font-size: 1.5rem;
Expand All @@ -31,28 +31,28 @@ const Container = styled.div`
display: grid;
grid-template-columns: repeat(8, 1fr);
grid-template-areas: ${(props) =>
props.showempty
? `'einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel'
props.showempty ?
`'einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel'
'gezaehltLabel gezaehltLabel gezaehltLabel gezaehltLabel geschaetztLabel geschaetztLabel geschaetztLabel geschaetztLabel'
'gezaehltVal gezaehltVal gezaehltVal gezaehltVal geschaetztVal geschaetztVal geschaetztVal geschaetztVal'`
: props.shownew
? `'einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel'
: props.shownew ?
`'einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel'
'showNew showNew showNew showNew showNew showNew showNew showNew'`
: `'einheitLabel einheitLabel einheitLabel einheitVal einheitVal einheitVal einheitVal einheitVal'
: `'einheitLabel einheitLabel einheitLabel einheitVal einheitVal einheitVal einheitVal einheitVal'
'gezaehltLabel gezaehltLabel gezaehltLabel gezaehltLabel geschaetztLabel geschaetztLabel geschaetztLabel geschaetztLabel'
'gezaehltVal gezaehltVal gezaehltVal gezaehltVal geschaetztVal geschaetztVal geschaetztVal geschaetztVal'`};
grid-column-gap: 10px;
break-inside: avoid;
@media print {
grid-template-areas: ${(props) =>
props.showempty
? `'einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel'
props.showempty ?
`'einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel'
'gezaehltLabel gezaehltLabel gezaehltLabel gezaehltLabel geschaetztLabel geschaetztLabel geschaetztLabel geschaetztLabel'
'gezaehltVal gezaehltVal gezaehltVal gezaehltVal geschaetztVal geschaetztVal geschaetztVal geschaetztVal'`
: props.shownew
? `'einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel'
: props.shownew ?
`'einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel einheitLabel'
'showNew showNew showNew showNew showNew showNew showNew showNew'`
: `'einheitLabel einheitLabel einheitLabel einheitVal einheitVal einheitVal einheitVal einheitVal'
: `'einheitLabel einheitLabel einheitLabel einheitVal einheitVal einheitVal einheitVal einheitVal'
'gezaehltLabel gezaehltLabel gezaehltLabel gezaehltLabel geschaetztLabel geschaetztLabel geschaetztLabel geschaetztLabel'
'gezaehltVal gezaehltVal gezaehltVal gezaehltVal geschaetztVal geschaetztVal geschaetztVal geschaetztVal'`};
}
Expand All @@ -66,11 +66,11 @@ const StyledForm = styled.div`
display: grid;
grid-template-columns: repeat(8, 1fr);
grid-template-areas: ${(props) =>
props.showdelete === 'true'
? `'einheitLabel einheitLabel einheitLabel einheitVal einheitVal einheitVal einheitVal einheitVal'
props.showdelete === 'true' ?
`'einheitLabel einheitLabel einheitLabel einheitVal einheitVal einheitVal einheitVal einheitVal'
'gezaehltLabel gezaehltLabel gezaehltLabel gezaehltLabel geschaetztLabel geschaetztLabel geschaetztLabel .'
'gezaehltVal gezaehltVal gezaehltVal gezaehltVal geschaetztVal geschaetztVal geschaetztVal delete'`
: `'einheitLabel einheitLabel einheitLabel einheitVal einheitVal einheitVal einheitVal einheitVal'
: `'einheitLabel einheitLabel einheitLabel einheitVal einheitVal einheitVal einheitVal einheitVal'
'gezaehltLabel gezaehltLabel gezaehltLabel gezaehltLabel geschaetztLabel geschaetztLabel geschaetztLabel geschaetztLabel'
'gezaehltVal gezaehltVal gezaehltVal gezaehltVal geschaetztVal geschaetztVal geschaetztVal geschaetztVal'`};
grid-column-gap: 10px;
Expand Down Expand Up @@ -257,10 +257,16 @@ const Count = ({

if (showNew) {
return (
<Container nr={nr} shownew={showNew}>
<Container
nr={nr}
shownew={showNew}
>
<EinheitLabel>{`Zähleinheit ${nr}`}</EinheitLabel>
<ShowNew>
<Button color="primary" onClick={createNew}>
<Button
color="primary"
onClick={createNew}
>
<StyledAddIcon /> Neu
</Button>
</ShowNew>
Expand All @@ -269,7 +275,10 @@ const Count = ({
}
if (showEmpty) {
return (
<Container nr={nr} showempty={showEmpty}>
<Container
nr={nr}
showempty={showEmpty}
>
<EinheitLabel>{`Zähleinheit ${nr}`}</EinheitLabel>
</Container>
)
Expand All @@ -293,10 +302,16 @@ const Count = ({
<GezaehltLabel>gezählt</GezaehltLabel>
<GeschaetztLabel>geschätzt</GeschaetztLabel>
<GezaehltVal>
<Gezaehlt row={row} refetch={refetchMe} />
<Gezaehlt
row={row}
refetch={refetchMe}
/>
</GezaehltVal>
<GeschaetztVal>
<Geschaetzt row={row} refetch={refetchMe} />
<Geschaetzt
row={row}
refetch={refetchMe}
/>
</GeschaetztVal>
{showDelete && (
<Delete>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { gql } from '@apollo/client'
import {
tpopkontrzaehl,
tpopkontrzaehlEinheitWerte,
} from '../../../../shared/fragments.js'
} from '../../../../../shared/fragments.js'

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

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

export default gql`
mutation updateAnzahlForCount(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import styled from '@emotion/styled'
import { observer } from 'mobx-react-lite'

import { TextField2 } from '../../../shared/TextField2.jsx'
import { TextField2 } from '../../../../shared/TextField2.jsx'
import anteilImg from './anteil.png'

const Area = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import styled from '@emotion/styled'
import { observer } from 'mobx-react-lite'

import { TextField2 } from '../../../shared/TextField2.jsx'
import { TextField2 } from '../../../../shared/TextField2.jsx'

const Container = styled.div`
border: 1px solid rgba(0, 0, 0, 0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import styled from '@emotion/styled'
import { observer } from 'mobx-react-lite'

import { DateField as DateFieldComponent } from '../../../shared/Date.jsx'
import { DateField as DateFieldComponent } from '../../../../shared/Date.jsx'

const Area = styled.div`
border: 1px solid rgba(0, 0, 0, 0.5);
Expand Down Expand Up @@ -51,4 +51,3 @@ export const DateField = observer(({ saveToDb, row, errors }) => (
</DateVal>
</Container>
))

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import styled from '@emotion/styled'
import { observer } from 'mobx-react-lite'

import { TextField2 } from '../../../shared/TextField2.jsx'
import { TextField2 } from '../../../../shared/TextField2.jsx'

const Container = styled.div`
border: 1px solid rgba(0, 0, 0, 0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import styled from '@emotion/styled'
import { observer } from 'mobx-react-lite'

import { Files } from '../../../shared/Files/index.jsx'
import { Files } from '../../../../shared/Files/index.jsx'

const Container = styled.div`
border: 1px solid rgba(0, 0, 0, 0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import styled from '@emotion/styled'
import { observer } from 'mobx-react-lite'
import { useQuery, useApolloClient, gql } from '@apollo/client'

import { Select } from '../../../../shared/Select.jsx'
import { StoreContext } from '../../../../../storeContext.js'
import { Select } from '../../../../../shared/Select.jsx'
import { StoreContext } from '../../../../../../storeContext.js'
import queryAdresses from './queryAdresses.js'
import {
adresse as adresseFragment,
pop as popFragment,
tpop as tpopFragment,
tpopfreiwkontr as tpopfreiwkontrFragment,
tpopkontrzaehlEinheitWerte as tpopkontrzaehlEinheitWerteFragment,
} from '../../../../shared/fragments.js'
import { Error } from '../../../../shared/Error.jsx'
} from '../../../../../shared/fragments.js'
import { Error } from '../../../../../shared/Error.jsx'

const Area = styled.div`
border: 1px solid rgba(0, 0, 0, 0.5);
Expand Down Expand Up @@ -165,9 +165,8 @@ const Headdata = ({ pop, tpop, row }) => {
const userCount = row?.adresseByBearbeiter?.usersByAdresseId?.totalCount ?? 0

const statusValue = tpop?.status ?? ''
const status = [200, 201, 202].includes(statusValue)
? 'angesiedelt'
: 'natürlich'
const status =
[200, 201, 202].includes(statusValue) ? 'angesiedelt' : 'natürlich'

if (error) return <Error error={error} />
return (
Expand All @@ -191,9 +190,9 @@ const Headdata = ({ pop, tpop, row }) => {
loading={loading}
saveToDb={saveToDb}
error={
row.bearbeiter && !userCount && !isPrint
? 'Es ist kein Benutzer mit dieser Adresse verbunden. Damit dieser Benutzer Kontrollen erfassen kann, muss er ein Benutzerkonto haben, dem diese Adresse zugeordnet wurde.'
: errors
row.bearbeiter && !userCount && !isPrint ?
'Es ist kein Benutzer mit dieser Adresse verbunden. Damit dieser Benutzer Kontrollen erfassen kann, muss er ein Benutzerkonto haben, dem diese Adresse zugeordnet wurde.'
: errors
}
/>
</BearbVal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useCallback, useContext } from 'react'
import styled from '@emotion/styled'
import { observer } from 'mobx-react-lite'

import { RadioButton } from '../../../shared/RadioButton.jsx'
import { StoreContext } from '../../../../storeContext.js'
import { RadioButton } from '../../../../shared/RadioButton.jsx'
import { StoreContext } from '../../../../../storeContext.js'

const Area = styled.div`
border: 1px solid rgba(0, 0, 0, 0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react'
import styled from '@emotion/styled'
import { observer } from 'mobx-react-lite'

import { TextField2 } from '../../../shared/TextField2.jsx'
import { RadioButton } from '../../../shared/RadioButton.jsx'
import { TextField2 } from '../../../../shared/TextField2.jsx'
import { RadioButton } from '../../../../shared/RadioButton.jsx'
import veghoeheImg from './veghoehe.png'

const Area = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import styled from '@emotion/styled'
import { observer } from 'mobx-react-lite'

import { TextField2 } from '../../../shared/TextField2.jsx'
import { TextField2 } from '../../../../shared/TextField2.jsx'

const Container = styled.div`
border: 1px solid rgba(0, 0, 0, 0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React from 'react'
import styled from '@emotion/styled'
import { observer } from 'mobx-react-lite'

import { RadioButton } from '../../../shared/RadioButton.jsx'
import { TextField2 } from '../../../shared/TextField2.jsx'
import { RadioButton } from '../../../../shared/RadioButton.jsx'
import { TextField2 } from '../../../../shared/TextField2.jsx'

const Area = styled.div`
border: 1px solid rgba(0, 0, 0, 0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useApolloClient, gql } from '@apollo/client'
import { jwtDecode } from 'jwt-decode'
import { useQueryClient } from '@tanstack/react-query'

import { StringToCopyOnlyButton } from '../../../shared/StringToCopyOnlyButton.jsx'
import { StringToCopyOnlyButton } from '../../../../shared/StringToCopyOnlyButton.jsx'
import Title from './Title.jsx'
import Headdata from './Headdata/index.jsx'
import Besttime from './Besttime.jsx'
Expand All @@ -21,15 +21,15 @@ import Files from './Files.jsx'
import Count from './Count/index.jsx'
import Verification from './Verification.jsx'
import Image from './Image.jsx'
import { StoreContext } from '../../../../storeContext.js'
import { ifIsNumericAsNumber } from '../../../../modules/ifIsNumericAsNumber.js'
import { StoreContext } from '../../../../../storeContext.js'
import { ifIsNumericAsNumber } from '../../../../../modules/ifIsNumericAsNumber.js'
import {
adresse as adresseFragment,
pop as popFragment,
tpop as tpopFragment,
tpopfreiwkontr as tpopfreiwkontrFragment,
tpopkontrzaehlEinheitWerte as tpopkontrzaehlEinheitWerteFragment,
} from '../../../shared/fragments.js'
} from '../../../../shared/fragments.js'

const FormContainer = styled.div`
padding: 10px;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Projekte/Daten/Tpopfreiwkontr/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { FormTitle } from '../../../shared/FormTitle/index.jsx'
import { StoreContext } from '../../../../storeContext.js'
import { Error } from '../../../shared/Error.jsx'
import { Spinner } from '../../../shared/Spinner.jsx'
import { Form } from './Form.jsx'
import { Form } from './Form/index.jsx'

const Container = styled.div`
flex-grow: 0;
Expand Down

0 comments on commit ef6a261

Please sign in to comment.