-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add source information and reporting timeframe data in export
- Loading branch information
1 parent
b059574
commit 4da2f34
Showing
12 changed files
with
288 additions
and
25 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
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
8 changes: 8 additions & 0 deletions
8
src/views/DrefApplicationForm/EventDetail/SourceInformationInput/i18n.json
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,8 @@ | ||
{ | ||
"namespace": "drefApplicationForm", | ||
"strings": { | ||
"sourceInformationNameLabel": "Sources of information (optional) name", | ||
"sourceInformationLinkLabel": "Sources of information (optional) link", | ||
"sourceInformationDeleteButton": "Delete Source Information" | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/views/DrefApplicationForm/EventDetail/SourceInformationInput/index.tsx
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,91 @@ | ||
import { | ||
type ArrayError, | ||
useFormObject, | ||
getErrorObject, | ||
type SetValueArg, | ||
} from '@togglecorp/toggle-form'; | ||
import { DeleteBinTwoLineIcon } from '@ifrc-go/icons'; | ||
import { randomString } from '@togglecorp/fujs'; | ||
|
||
import NonFieldError from '#components/NonFieldError'; | ||
import Button from '#components/Button'; | ||
import TextArea from '#components/TextArea'; | ||
import useTranslation from '#hooks/useTranslation'; | ||
|
||
import { type PartialDref } from '../../schema'; | ||
import i18n from './i18n.json'; | ||
import styles from './styles.module.css'; | ||
|
||
type SourceInformationFormFields = NonNullable<PartialDref['source_information']>[number]; | ||
|
||
interface Props { | ||
value: SourceInformationFormFields; | ||
error: ArrayError<SourceInformationFormFields> | undefined; | ||
onChange: (value: SetValueArg<SourceInformationFormFields>, index: number) => void; | ||
onRemove: (index: number) => void; | ||
index: number; | ||
disabled?: boolean; | ||
} | ||
|
||
function SourceInformation(props: Props) { | ||
const { | ||
error: errorFromProps, | ||
onChange, | ||
value, | ||
index, | ||
onRemove, | ||
disabled, | ||
} = props; | ||
|
||
const strings = useTranslation(i18n); | ||
|
||
const onFieldChange = useFormObject( | ||
index, | ||
onChange, | ||
() => ({ | ||
client_id: randomString(), | ||
}), | ||
); | ||
|
||
const error = (value && value.client_id && errorFromProps) | ||
? getErrorObject(errorFromProps?.[value.client_id]) | ||
: undefined; | ||
|
||
return ( | ||
<div className={styles.riskSecurityInput}> | ||
<NonFieldError error={error} /> | ||
<TextArea | ||
className={styles.input} | ||
label={strings.sourceInformationNameLabel} | ||
name="source_name" | ||
value={value.source_name} | ||
error={error?.source_name} | ||
onChange={onFieldChange} | ||
disabled={disabled} | ||
withAsterisk | ||
/> | ||
<TextArea | ||
className={styles.input} | ||
label={strings.sourceInformationLinkLabel} | ||
name="source_link" | ||
value={value.source_link} | ||
error={error?.source_link} | ||
onChange={onFieldChange} | ||
disabled={disabled} | ||
withAsterisk | ||
/> | ||
<Button | ||
className={styles.removeButton} | ||
name={index} | ||
onClick={onRemove} | ||
variant="tertiary" | ||
disabled={disabled} | ||
title={strings.sourceInformationDeleteButton} | ||
> | ||
<DeleteBinTwoLineIcon /> | ||
</Button> | ||
</div> | ||
); | ||
} | ||
|
||
export default SourceInformation; |
14 changes: 14 additions & 0 deletions
14
src/views/DrefApplicationForm/EventDetail/SourceInformationInput/styles.module.css
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,14 @@ | ||
.risk-security-input { | ||
display: flex; | ||
align-items: flex-start; | ||
gap: var(--go-ui-spacing-md); | ||
|
||
.input { | ||
flex-basis: 0; | ||
flex-grow: 1; | ||
} | ||
|
||
.remove-button { | ||
flex-shrink: 0; | ||
} | ||
} |
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
Oops, something went wrong.