-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57b4805
commit fcda48c
Showing
5 changed files
with
131 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
import { Box } from '@mui/material'; | ||
import { Box, TextField } from '@mui/material'; | ||
import { | ||
ProgressReportMediaCategoryLabels, | ||
ProgressReportMediaCategoryList, | ||
} from '~/api/schema/enumLists'; | ||
import { labelFrom } from '~/common'; | ||
import { Form, SelectField, TextField } from '~/components/form'; | ||
import { Form, SelectField } from '~/components/form'; | ||
import { minLength, required } from '~/components/form/validators'; | ||
Check warning on line 8 in src/scenes/ProgressReports/EditForm/Steps/Media/MediaInfoForm.tsx GitHub Actions / run
|
||
import { useCallback, useState } from 'react'; | ||
import { ProgressReportMediaCategory } from '~/api/schema.graphql'; | ||
|
||
// TODO type submitForm | ||
// @ts-ignore | ||
Check failure on line 13 in src/scenes/ProgressReports/EditForm/Steps/Media/MediaInfoForm.tsx GitHub Actions / run
|
||
export const MediaInfoForm = ({ | ||
submitForm, | ||
disabled, | ||
initialValues, | ||
}: { | ||
submitForm: any; | ||
disabled: boolean; | ||
initialValues: { | ||
category: ProgressReportMediaCategory | null; | ||
caption: string | null; | ||
}; | ||
}) => { | ||
const [category, setCategory] = useState(initialValues.category); | ||
const [caption, setCaption] = useState(initialValues.caption); | ||
Check warning on line 27 in src/scenes/ProgressReports/EditForm/Steps/Media/MediaInfoForm.tsx GitHub Actions / run
|
||
const updateMedia = useCallback(() => { | ||
submitForm({ variables: {} }); | ||
}, []); | ||
Check warning on line 30 in src/scenes/ProgressReports/EditForm/Steps/Media/MediaInfoForm.tsx GitHub Actions / run
|
||
return ( | ||
<Form onSubmit={submitForm}> | ||
<Box sx={{ p: 1, m: 1, flexGrow: 2 }}> | ||
|
@@ -26,7 +38,9 @@ export const MediaInfoForm = ({ | |
options={ProgressReportMediaCategoryList} | ||
variant="outlined" | ||
getOptionLabel={labelFrom(ProgressReportMediaCategoryLabels)} | ||
defaultValue={disabled ? null : ProgressReportMediaCategoryList[0]} | ||
defaultValue={ | ||
disabled ? null : category || ProgressReportMediaCategoryList[0] | ||
} | ||
/> | ||
<TextField | ||
variant="outlined" | ||
|
@@ -35,8 +49,8 @@ export const MediaInfoForm = ({ | |
disabled={disabled} | ||
placeholder="Enter Photo Caption" | ||
minRows={4} | ||
validate={[required, minLength()]} | ||
margin="none" | ||
defaultValue={initialValues?.caption} | ||
/> | ||
</Box> | ||
</Form> | ||
|
31 changes: 31 additions & 0 deletions
31
src/scenes/ProgressReports/EditForm/Steps/Media/MediaStep.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
mutation CreateMedia($input: UploadProgressReportMedia!) { | ||
uploadProgressReportMedia(input: $input) { | ||
id | ||
media { | ||
items { | ||
id | ||
variant { | ||
key | ||
label | ||
responsibleRole | ||
} | ||
category | ||
} | ||
} | ||
} | ||
} | ||
|
||
mutation UpdateMedia($input: UpdateProgressReportMedia!) { | ||
updateProgressReportMedia(input: $input) { | ||
id | ||
media { | ||
altText | ||
caption | ||
id | ||
mimeType | ||
url | ||
} | ||
} | ||
} | ||
# placeholder for delete | ||
# placeholder for download |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters