Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"namespace": "eapFullForm",
"strings": {
"eapFullFormActivationSourceInformationNameLabel": "Name",
"eapFullFormActivationSourceInformationLinkLabel": "Link",
"eapFullFormActivationSourceInformationDeleteButton": "Delete Source Information"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import { useCallback } from 'react';
import { DeleteBinTwoLineIcon } from '@ifrc-go/icons';
import {
Button,
TextInput,
} from '@ifrc-go/ui';
import { useTranslation } from '@ifrc-go/ui/hooks';
import {
isNotDefined,
randomString,
} from '@togglecorp/fujs';
import {
type ArrayError,
getErrorObject,
type SetValueArg,
useFormObject,
} from '@togglecorp/toggle-form';

import NonFieldError from '#components/NonFieldError';

import { type PartialEapFullFormType } from '../../schema';

import i18n from './i18n.json';

type SourceInformationFormFields = NonNullable<PartialEapFullFormType['activation_process_source_of_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;
readOnly?: boolean;
}

function ActivationSourceInformationInput(props: Props) {
const {
error: errorFromProps,
onChange,
value,
index,
onRemove,
disabled,
readOnly,
} = 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;

const handleSourceFieldChange = useCallback(
(newValue: string | undefined) => {
if (
isNotDefined(newValue)
|| newValue.startsWith('http://')
|| newValue.startsWith('https://')
|| newValue === 'h'
|| newValue === 'ht'
|| newValue === 'htt'
|| newValue === 'http'
|| newValue === 'http:'
|| newValue === 'http:/'
|| newValue === 'https'
|| newValue === 'https:'
|| newValue === 'https:/'
) {
onFieldChange(newValue, 'source_link');
return;
}

onFieldChange(`https://${newValue}`, 'source_link');
},
[onFieldChange],
);

return (
<>
<NonFieldError error={error} />
<TextInput
label={strings.eapFullFormActivationSourceInformationNameLabel}
name="source_name"
value={value.source_name}
error={error?.source_name}
onChange={onFieldChange}
readOnly={readOnly}
disabled={disabled}
/>
<TextInput
label={strings.eapFullFormActivationSourceInformationLinkLabel}
name="source_link"
value={value.source_link}
error={error?.source_link}
onChange={handleSourceFieldChange}
readOnly={readOnly}
disabled={disabled}
/>
<Button
name={index}
onClick={onRemove}
styleVariant="action"
disabled={disabled || readOnly}
title={strings.eapFullFormActivationSourceInformationDeleteButton}
>
<DeleteBinTwoLineIcon />
</Button>
</>
);
}

export default ActivationSourceInformationInput;
29 changes: 29 additions & 0 deletions app/src/views/EapFullForm/EapActivationProcess/i18n.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"namespace": "eapFullForm",
"strings": {
"eapFullFormImplementationProcessTitle": "Early action implementation process",
"eapFullFormImplementationProcessDescription1": "Include a matrix/flowchart for a quick overview of the early action implementation process.",
"eapFullFormImplementationProcessDescription2": "Early Describe the step-by-step process from Day 1 to Day X for the implementation of the selected early actions. Indicate the day when the Stop Mechanism would occur. Include all critical and support tasks that are necessary for each of the steps. Each task should indicate the position of the person responsible (including when cash-based actions are planned liaison with the financial service provider)... implementation process",
"eapFullFormImplementationProcessDescriptionLabel": "Description",
"eapFullFormImplementationProcessUploadLabel": "Upload",
"eapFullFormImplementationTriggerActivationTitle": "Trigger activation system",
"eapFullFormImplementationTriggerActivationDescription1": "Describe the automatic system used to monitor the forecasts, generate the intervention map and send the alert message when the trigger is reached.",
"eapFullFormImplementationTriggerActivationDescription2": "If this automatic system does not yet exist, explain how forecasts will be monitored, intervention maps generated and how the relevant actors will be informed that the trigger has been reached.",
"eapFullFormImplementationTriggerActivationDescription3": "Indicate who gives the signal to start the activation.",
"eapFullFormImplementationPeopleTargetedTitle": "People Targeted",
"eapFullFormImplementationPeopleTargetedDescription": "Add the number of people targeted for the event.",
"eapFullFormImplementationSelectionPopulationTitle": "Selection of target population",
"eapFullFormImplementationSelectionDescription1": "Provide a short summary of the target population, (the number, location etc.)",
"eapFullFormImplementationSelectionDescription2": "Describe how the target population will be selected, with a special focus on feasibility in the short period of time between forecast and event",
"eapFullFormImplementationSelectionDescription3": "If the EAP is intending to use Social Protection systems or other government beneficiary databases, indicate how the potential number of targeted households be selected",
"eapFullFormImplementationStopMechanismTitle": "Stop Mechanism",
"eapFullFormImplementationStopMechanismDescription1": "Indicate on which day of activation the stop mechanism is foreseen, and who is responsible to give the signal to stop.",
"eapFullFormImplementationStopMechanismDescription2": "Describe when the stop mechanism begins and whether in-kind/cash distribution would be stopped or not. For cash actions cancelled, how would this be coordinated with the financial service provider? For in-kind distribution, what would happen with the perishable items?",
"eapFullFormImplementationStopMechanismDescription3": "Explain how it would be communicated to communities and stakeholders that the activities are being stopped.",
"eapFullFormImplementationAttachFilesTitle": "Attach Relevant Files",
"eapFullFormImplementationAttachFilesDescription": "Attach any additional maps, documentation, files, images, etc.",
"eapFullFormImplementationSourceOfInformationTitle": "Sources of Information",
"eapFullFormImplementationSourceOfInformationAddNewLabel": "Add New Source of Information",
"eapFullFormImplementationSourceOfInformationDescription": "Add the description of the sources one at a time. If the source has a link, add in the second field."
}
}
Loading
Loading