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 eab8eb4 commit 78f2ca8
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 35 deletions.
12 changes: 6 additions & 6 deletions src/components/Projekte/Daten/Beobzuordnung/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import { Select } from '../../../shared/Select.jsx'
import { DateField } from '../../../shared/Date.jsx'
import { SelectLoadingOptions } from '../../../shared/SelectLoadingOptions.jsx'
import { Beob } from '../Beob/index.jsx'
import query from './query.js'
import queryAeTaxonomies from './queryAeTaxonomies'
import saveNichtZuordnenToDb from './saveNichtZuordnenToDb'
import saveArtIdToDb from './saveArtIdToDb'
import saveTpopIdToDb from './saveTpopIdToDb'
import sendMail from '../../../../modules/sendMail'
import { query } from './query.js'
import { queryAeTaxonomies } from './queryAeTaxonomies.js'
import { saveNichtZuordnenToDb } from './saveNichtZuordnenToDb.js'
import { saveArtIdToDb } from './saveArtIdToDb.js'
import { saveTpopIdToDb } from './saveTpopIdToDb.js'
import { sendMail } from '../../../../modules/sendMail.js'
import { StoreContext } from '../../../../storeContext.js'
import { ErrorBoundary } from '../../../shared/ErrorBoundary.jsx'
import { Error } from '../../../shared/Error.jsx'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Projekte/Daten/Beobzuordnung/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
popStatusWerte,
} from '../../../shared/fragments.js'

export default gql`
export const query = gql`
query beobByIdQueryForZuordnung($id: UUID!, $apId: UUID!) {
apById(id: $apId) {
id
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 queryAeTaxonomies = gql`
query BeobzuordnungAeTaxonomiesQuery($filter: AeTaxonomyFilter!) {
allAeTaxonomies(first: 8, filter: $filter, orderBy: ARTNAME_ASC) {
nodes {
Expand Down
8 changes: 3 additions & 5 deletions src/components/Projekte/Daten/Beobzuordnung/saveArtIdToDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import isEqual from 'lodash/isEqual'
import { gql } from '@apollo/client'
import { getSnapshot } from 'mobx-state-tree'

import updateBeobByIdGql from './updateBeobById'
import { updateBeobById } from './updateBeobById.js'

const saveArtIdToDb = async ({ value, row, client, store, search }) => {
export const saveArtIdToDb = async ({ value, row, client, store, search }) => {
const { activeNodeArray, openNodes: openNodesRaw, setOpenNodes } = store.tree
const aNA = getSnapshot(activeNodeArray)
const openNodes = getSnapshot(openNodesRaw)
Expand All @@ -16,7 +16,7 @@ const saveArtIdToDb = async ({ value, row, client, store, search }) => {
artId: value,
}
await client.mutate({
mutation: updateBeobByIdGql,
mutation: updateBeobById,
variables,
})

Expand Down Expand Up @@ -75,5 +75,3 @@ const saveArtIdToDb = async ({ value, row, client, store, search }) => {
queryKey: [`treeBeobNichtZuzuordnen`],
})
}

export default saveArtIdToDb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import isEqual from 'lodash/isEqual'

import updateBeobByIdGql from './updateBeobById'
import { updateBeobById } from './updateBeobById.js'

const saveNichtZuordnenToDb = async ({
export const saveNichtZuordnenToDb = async ({
value,
id,
refetch: refetchPassed,
Expand All @@ -17,7 +17,7 @@ const saveNichtZuordnenToDb = async ({
// if true, empty tpopId
if (value) variables.tpopId = null
await client.mutate({
mutation: updateBeobByIdGql,
mutation: updateBeobById,
variables,
})
store.queryClient.invalidateQueries({
Expand All @@ -30,8 +30,9 @@ const saveNichtZuordnenToDb = async ({
const { activeNodeArray, openNodes, addOpenNodes } = store.tree

let newActiveNodeArray = [...activeNodeArray]
newActiveNodeArray[4] = value
? 'nicht-zuzuordnende-Beobachtungen'
newActiveNodeArray[4] =
value ?
'nicht-zuzuordnende-Beobachtungen'
: 'nicht-beurteilte-Beobachtungen'
newActiveNodeArray[5] = id
newActiveNodeArray = newActiveNodeArray.slice(0, 6)
Expand All @@ -48,5 +49,3 @@ const saveNichtZuordnenToDb = async ({
store.navigate(`/Daten/${newActiveNodeArray.join('/')}${search}`)
if (refetchPassed) refetchPassed()
}

export default saveNichtZuordnenToDb
15 changes: 10 additions & 5 deletions src/components/Projekte/Daten/Beobzuordnung/saveTpopIdToDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ import isEqual from 'lodash/isEqual'
import { gql } from '@apollo/client'
import { getSnapshot } from 'mobx-state-tree'

import updateBeobByIdGql from './updateBeobById'
import { updateBeobById } from './updateBeobById.js'

const saveTpopIdToDb = async ({ value, id, type, client, store, search }) => {
export const saveTpopIdToDb = async ({
value,
id,
type,
client,
store,
search,
}) => {
const variables = {
id,
tpopId: value,
Expand All @@ -13,7 +20,7 @@ const saveTpopIdToDb = async ({ value, id, type, client, store, search }) => {
// if value, set nichtZuordnen false
if (value) variables.nichtZuordnen = false
await client.mutate({
mutation: updateBeobByIdGql,
mutation: updateBeobById,
variables,
})

Expand Down Expand Up @@ -232,5 +239,3 @@ const saveTpopIdToDb = async ({ value, id, type, client, store, search }) => {
queryKey: [`treeBeobNichtZuzuordnen`],
})
}

export default saveTpopIdToDb
4 changes: 2 additions & 2 deletions src/components/Projekte/Daten/Beobzuordnung/updateBeobById.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
popStatusWerte,
} from '../../../shared/fragments.js'

export default gql`
export const updateBeobById = gql`
mutation updateBeobForBeobzuordnung(
$id: UUID!
$idField: String
Expand Down Expand Up @@ -47,7 +47,7 @@ export default gql`
) {
beob {
...BeobFields
aeTaxonomyByArtId {
aeTaxonomyByArtId {
...AeTaxonomiesFields
apByArtId {
id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { beobIconString } from './beobIconString.js'
import { beobIconHighlightedString } from './beobIconHighlightedString.js'
import { getNearestTpop } from '../../../../../modules/getNearestTpop.js'
import { appBaseUrl } from '../../../../../modules/appBaseUrl.js'
import updateBeobByIdGql from './updateBeobById.js'
import { updateBeobById } from './updateBeobById.js'
import { useSearchParamsState } from '../../../../../modules/useSearchParamsState.js'
import { isMobilePhone } from '../../../../../modules/isMobilePhone.js'
import Data from '../BeobData/index.jsx'
Expand Down Expand Up @@ -69,7 +69,7 @@ const BeobNichtBeurteiltMarker = ({ beob }) => {
client,
})
await client.mutate({
mutation: updateBeobByIdGql,
mutation: updateBeobById,
variables: {
id: beob.id,
tpopId: nearestTpop.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
popStatusWerte,
} from '../../../../shared/fragments.js'

export default gql`
export const updateBeobById = gql`
mutation updateBeobForKarteBeobNichtBeurteilt($id: UUID!, $tpopId: UUID) {
updateBeobById(
input: { id: $id, beobPatch: { id: $id, tpopId: $tpopId } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { beobIconString } from './beobIconString.js'
import { beobHighlightedIconString } from './beobHighlightedIconString.js'
import { getNearestTpop } from '../../../../../modules/getNearestTpop.js'
import { appBaseUrl } from '../../../../../modules/appBaseUrl.js'
import updateBeobByIdGql from './updateBeobById.js'
import { updateBeobById } from './updateBeobById.js'
import { useSearchParamsState } from '../../../../../modules/useSearchParamsState.js'
import { isMobilePhone } from '../../../../../modules/isMobilePhone.js'
import Data from '../BeobData/index.jsx'
Expand Down Expand Up @@ -84,7 +84,7 @@ const BeobZugeordnetMarker = ({ beob }) => {
]
navigate(`/Daten/${newActiveNodeArray.join('/')}${search}`)
await client.mutate({
mutation: updateBeobByIdGql,
mutation: updateBeobById,
variables: {
id: beob.id,
tpopId: nearestTpop.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
popStatusWerte,
} from '../../../../shared/fragments.js'

export default gql`
export const updateBeobById = gql`
mutation updateBeobForKarteBeobZugeordnet($id: UUID!, $tpopId: UUID) {
updateBeobById(
input: { id: $id, beobPatch: { id: $id, tpopId: $tpopId } }
Expand Down
3 changes: 1 addition & 2 deletions src/modules/sendMail.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// seems not in use
export const sendEmail = ({ to, subject, body, cc }) => {
export const sendMail = ({ to, subject, body, cc }) => {
const link = `mailto:${to}${cc ? `?cc=${cc}` : '?'}${
subject ? `&subject=${subject}` : ''
}${body ? `&body=${encodeURIComponent(body)}` : ''}`
Expand Down

0 comments on commit 78f2ca8

Please sign in to comment.