Skip to content

Commit

Permalink
fix: fi image selector when there is no image and org unit selectors …
Browse files Browse the repository at this point in the history
…when there are no org units
  • Loading branch information
flaminic committed Oct 16, 2024
1 parent 1795788 commit ea4d691
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 2 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-10-15T11:17:07.503Z\n"
"PO-Revision-Date: 2024-10-15T11:17:07.503Z\n"
"POT-Creation-Date: 2024-10-16T11:01:15.583Z\n"
"PO-Revision-Date: 2024-10-16T11:01:15.584Z\n"

msgid "schemas"
msgstr "schemas"
Expand Down
5 changes: 3 additions & 2 deletions src/pages/organisationUnits/form/ImageField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ export function ImageField() {
const dataEngine = useDataEngine()
const fieldName = 'image'
const { input } = useField(fieldName)
const currentFile: File | undefined = input.value || undefined
const currentFile: { name?: string; id?: string } | undefined =
input.value || undefined

const uploadFile = async (fileToUpload: File) => {
const ADD_NEW_FILE_RESOURCE_MUTATION = {
Expand Down Expand Up @@ -93,7 +94,7 @@ export function ImageField() {
/>

<FileList>
{currentFile && (
{currentFile?.id && (
<FileListItem
key={currentFile?.name}
label={currentFile?.name}
Expand Down
12 changes: 11 additions & 1 deletion src/pages/organisationUnits/form/OrganisationUnitSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import React, { useState } from 'react'
import { OrganisationUnitField } from '../../../components'
import { OrganisationUnitFormValue } from '../../../components/form/fields/OrganisationUnitField'
import classes from './OrganisationUnitSelector.module.css'
import { useCurrentUserRootOrgUnits } from '../../../lib/user/currentUserStore'

Check failure on line 7 in src/pages/organisationUnits/form/OrganisationUnitSelector.tsx

View workflow job for this annotation

GitHub Actions / lint

`../../../lib/user/currentUserStore` import should occur before import of `./OrganisationUnitSelector.module.css`
import { NoticeBox } from '@dhis2/ui'

Check failure on line 8 in src/pages/organisationUnits/form/OrganisationUnitSelector.tsx

View workflow job for this annotation

GitHub Actions / lint

`@dhis2/ui` import should occur before import of `@dhis2/ui-icons`

export function OrganisationUnitSelector() {
const [selectedOrgUnit, setSelectedOrgUnit] = useState<string | undefined>()
Expand All @@ -13,7 +15,9 @@ export function OrganisationUnitSelector() {
? setSelectedOrgUnit(orgUnits[0].displayName)
: setSelectedOrgUnit(undefined)

return (
const userRootOrgUnits = useCurrentUserRootOrgUnits()

return userRootOrgUnits.length > 0 ? (
<>
<div className={classes.selectedOrgUnitBox}>
<OrganisationUnitField
Expand All @@ -35,5 +39,11 @@ export function OrganisationUnitSelector() {
</div>
)}
</>
) : (
<NoticeBox title={i18n.t('Creating first organisation unit')}>
{i18n.t(
'This is the first organisation unit and will be created as the root of the hierarchy.'
)}
</NoticeBox>
)
}

0 comments on commit ea4d691

Please sign in to comment.