Skip to content

Commit

Permalink
add different fields for people in household data update
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Szewczyk committed Nov 14, 2024
1 parent 747b8ba commit cefbada
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 101 deletions.
38 changes: 1 addition & 37 deletions src/frontend/data/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ type BankAccountInfoNode implements Node {
bankAccountNumber: String!
bankBranchName: String!
accountHolderName: String!
isMigrationHandled: Boolean!
copiedFrom: BankAccountInfoNode
copiedTo(offset: Int, before: String, after: String, first: Int, last: Int): BankAccountInfoNodeConnection!
type: String
Expand Down Expand Up @@ -953,30 +952,12 @@ type DeliveredQuantityNode {
currency: String
}

enum DeliveryMechanismDataDeliveryMechanismChoice {
CARDLESS_CASH_WITHDRAWAL
CASH
CASH_BY_FSP
CHEQUE
DEPOSIT_TO_CARD
MOBILE_MONEY
PRE_PAID_CARD
REFERRAL
TRANSFER
TRANSFER_TO_ACCOUNT
VOUCHER
ATM_CARD
CASH_OVER_THE_COUNTER
TRANSFER_TO_DIGITAL_WALLET
}

type DeliveryMechanismDataNode implements Node {
id: ID!
rdiMergeStatus: DeliveryMechanismDataRdiMergeStatus!
createdAt: DateTime!
updatedAt: DateTime!
individual: IndividualNode!
deliveryMechanismChoice: DeliveryMechanismDataDeliveryMechanismChoice
deliveryMechanism: DeliveryMechanismNode!
data: JSONString!
isValid: Boolean
Expand Down Expand Up @@ -1047,23 +1028,6 @@ type DeliveryMechanismNodeEdge {
cursor: String!
}

enum DeliveryMechanismPerPaymentPlanDeliveryMechanismChoice {
CARDLESS_CASH_WITHDRAWAL
CASH
CASH_BY_FSP
CHEQUE
DEPOSIT_TO_CARD
MOBILE_MONEY
PRE_PAID_CARD
REFERRAL
TRANSFER
TRANSFER_TO_ACCOUNT
VOUCHER
ATM_CARD
CASH_OVER_THE_COUNTER
TRANSFER_TO_DIGITAL_WALLET
}

type DeliveryMechanismPerPaymentPlanNode implements Node {
id: ID!
createdAt: DateTime!
Expand All @@ -1074,7 +1038,6 @@ type DeliveryMechanismPerPaymentPlanNode implements Node {
sentDate: DateTime!
sentBy: UserNode
status: String!
deliveryMechanismChoice: DeliveryMechanismPerPaymentPlanDeliveryMechanismChoice
deliveryMechanism: DeliveryMechanismNode
deliveryMechanismOrder: Int!
sentToPaymentGateway: Boolean!
Expand Down Expand Up @@ -3942,6 +3905,7 @@ type Query {
chartGrievances(businessAreaSlug: String!, year: Int!, administrativeArea: String): ChartGrievanceTicketsNode
allAddIndividualsFieldsAttributes: [FieldAttributeNode]
allEditHouseholdFieldsAttributes: [FieldAttributeNode]
allEditPeopleFieldsAttributes: [FieldAttributeNode]
grievanceTicketStatusChoices: [ChoiceObject]
grievanceTicketCategoryChoices: [ChoiceObject]
grievanceTicketManualCategoryChoices: [ChoiceObject]
Expand Down
108 changes: 66 additions & 42 deletions src/frontend/src/__generated__/graphql.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { gql } from '@apollo/client';

export const AllEditPeopleFieldsAttributes = gql`
query AllEditPeopleFields {
allEditPeopleFieldsAttributes {
id
type
name
required
labels {
language
label
}
labelEn
hint
choices {
labels {
label
language
}
labelEn
value
admin
listName
}
isFlexField
}
}
`;
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { Grid } from '@mui/material';
import { useTranslation } from 'react-i18next';
import { AllEditHouseholdFieldsQuery } from '@generated/graphql';
import {
AllEditHouseholdFieldsQuery,
AllEditPeopleFieldsQuery,
} from '@generated/graphql';
import { LabelizedField } from '@core/LabelizedField';
import { GrievanceFlexFieldPhotoModalNewHousehold } from '../GrievancesPhotoModals/GrievanceFlexFieldPhotoModalNewHousehold';
import { ReactElement } from 'react';

export interface CurrentValueProps {
field: AllEditHouseholdFieldsQuery['allEditHouseholdFieldsAttributes'][number];
field:
| AllEditHouseholdFieldsQuery['allEditHouseholdFieldsAttributes'][number]
| AllEditPeopleFieldsQuery['allEditPeopleFieldsAttributes'][number];
value;
values;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { useTranslation } from 'react-i18next';
import {
AllHouseholdsQuery,
useAllEditHouseholdFieldsQuery,
useAllEditPeopleFieldsQuery,
useHouseholdLazyQuery,
} from '@generated/graphql';
import { LoadingComponent } from '@core/LoadingComponent';
import { Title } from '@core/Title';
import { EditHouseholdDataChangeFieldRow } from './EditHouseholdDataChangeFieldRow';
import { useProgramContext } from 'src/programContext';

export interface EditHouseholdDataChangeProps {
values;
Expand All @@ -23,6 +25,7 @@ export function EditHouseholdDataChange({
}: EditHouseholdDataChangeProps): ReactElement {
const { t } = useTranslation();
const location = useLocation();
const { isSocialDctType } = useProgramContext();
const isEditTicket = location.pathname.includes('edit-ticket');
const household: AllHouseholdsQuery['allHouseholds']['edges'][number]['node'] =
values.selectedHousehold;
Expand All @@ -47,10 +50,22 @@ export function EditHouseholdDataChange({
}, []);
const { data: householdFieldsData, loading: householdFieldsLoading } =
useAllEditHouseholdFieldsQuery();
const { data: allEditPeopleFieldsData, loading: allEditPeopleFieldsLoading } =
useAllEditPeopleFieldsQuery();

const fieldsByDctType = isSocialDctType
? allEditPeopleFieldsData?.allEditPeopleFieldsAttributes
: householdFieldsData?.allEditHouseholdFieldsAttributes;

if (!household) {
return <div>{t('You have to select a household earlier')}</div>;
}
if (fullHouseholdLoading || householdFieldsLoading || !fullHousehold) {
if (
fullHouseholdLoading ||
householdFieldsLoading ||
allEditPeopleFieldsLoading ||
!fullHousehold
) {
return <LoadingComponent />;
}
const notAvailableItems = (values.householdDataUpdateFields || []).map(
Expand All @@ -74,9 +89,7 @@ export function EditHouseholdDataChange({
itemValue={item}
index={index}
household={fullHousehold.household}
fields={
householdFieldsData.allEditHouseholdFieldsAttributes
}
fields={fieldsByDctType}
notAvailableFields={notAvailableItems}
onDelete={() => arrayHelpers.remove(index)}
values={values}
Expand Down
Loading

0 comments on commit cefbada

Please sign in to comment.