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 b5bdede commit c80eb31
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 32 deletions.
6 changes: 2 additions & 4 deletions src/components/Projekte/Daten/Ap/Ap/ApUsers/ApUser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const DelIcon = styled(IconButton)`
padding-bottom: 6px !important;
`

const ApUser = ({ user, refetch }) => {
export const ApUser = observer(({ user, refetch }) => {
const client = useApolloClient()
const { enqueNotification } = useContext(StoreContext)

Expand Down Expand Up @@ -56,6 +56,4 @@ const ApUser = ({ user, refetch }) => {
</DelIcon>
</div>
)
}

export default observer(ApUser)
})
40 changes: 19 additions & 21 deletions src/components/Projekte/Daten/Ap/Ap/ApUsers/NewUser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useQuery, useApolloClient, gql } from '@apollo/client'

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

const NewUser = ({ apId, apUsers, refetch }) => {
export const NewUser = observer(({ apId, apUsers, refetch }) => {
const client = useApolloClient()

const [error, setError] = useState(null)
Expand All @@ -13,29 +13,27 @@ const NewUser = ({ apId, apUsers, refetch }) => {
data,
loading,
error: queryError,
} = useQuery(
gql`
query benutzerForNewUser {
allUsers(
orderBy: NAME_ASC
filter: { role: { in: ["apflora_ap_writer", "apflora_ap_reader"] } }
) {
nodes {
id
name
role
}
} = useQuery(gql`
query benutzerForNewUser {
allUsers(
orderBy: NAME_ASC
filter: { role: { in: ["apflora_ap_writer", "apflora_ap_reader"] } }
) {
nodes {
id
name
role
}
}
`,
)
const userData = data ? data?.allUsers?.nodes ?? [] : []
}
`)
const userData = data ? (data?.allUsers?.nodes ?? []) : []
const apUserIds = apUsers.map((u) => u?.userByUserName?.id)
const options = userData
.filter((d) => !apUserIds.includes(d.id))
.map((d) => ({
value: d.name,
label: `${d.name} (${d.role.replace('apflora_', '')})`,
value: d.name ?? '(kein Name)',
label: `${d.name ?? '(kein Name)'} (${d.role.replace('apflora_', '')})`,
}))

const saveToDb = useCallback(
Expand Down Expand Up @@ -68,6 +66,8 @@ const NewUser = ({ apId, apUsers, refetch }) => {
if (queryError) setError(queryError.message)
}, [queryError])

console.log('NewUser', { apUsers, userData, options })

return (
<Select
key={apUsers.length}
Expand All @@ -80,6 +80,4 @@ const NewUser = ({ apId, apUsers, refetch }) => {
saveToDb={saveToDb}
/>
)
}

export default observer(NewUser)
})
10 changes: 4 additions & 6 deletions src/components/Projekte/Daten/Ap/Ap/ApUsers/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { useQuery, gql } from '@apollo/client'
import styled from '@emotion/styled'
import { useParams } from 'react-router-dom'

import ApUser from './ApUser'
import NewUser from './NewUser'
import { ApUser } from './ApUser.jsx'
import { NewUser } from './NewUser.jsx'
import { Label } from '../../../../../shared/Label.jsx'
import { Error } from '../../../../../shared/Error.jsx'

Expand Down Expand Up @@ -33,7 +33,7 @@ const InfoRow = styled.li`
margin-bottom: 0;
`

const ApUsers = () => {
export const ApUsers = observer(() => {
const { apId } = useParams()

const { data, error, loading, refetch } = useQuery(
Expand Down Expand Up @@ -120,6 +120,4 @@ const ApUsers = () => {
/>
</Container>
)
}

export default observer(ApUsers)
})
2 changes: 1 addition & 1 deletion src/components/Projekte/Daten/Ap/Ap/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { query } from './query.js'
import { queryAeTaxonomies } from './queryAeTaxonomies.js'
import { StoreContext } from '../../../../../storeContext.js'
import { ifIsNumericAsNumber } from '../../../../../modules/ifIsNumericAsNumber.js'
import ApUsers from './ApUsers/index.jsx'
import { ApUsers } from './ApUsers/index.jsx'
import { ap, aeTaxonomies } from '../../../../shared/fragments.js'
import { Spinner } from '../../../../shared/Spinner.jsx'
import { Error } from '../../../../shared/Error.jsx'
Expand Down

0 comments on commit c80eb31

Please sign in to comment.