From 0ffb0e68978802c01c6f5620978a48fbb12af495 Mon Sep 17 00:00:00 2001 From: Anubhav Banerjee Date: Mon, 22 Jan 2024 12:39:26 +0530 Subject: [PATCH 01/18] Updated orgupdate.tsx with form controls, mutations, and queries, updated userTableItmes, and tests --- src/GraphQl/Mutations/mutations.ts | 22 +- src/GraphQl/Queries/Queries.ts | 10 +- .../LeftDrawerOrg/LeftDrawerOrg.tsx | 2 +- .../OrgListCard/OrgListCard.test.tsx | 11 +- src/components/OrgListCard/OrgListCard.tsx | 4 +- src/components/OrgUpdate/OrgUpdate.tsx | 103 +++++- .../UsersTableItem/UserTableItem.test.tsx | 308 ++++++++++++++++-- .../UsersTableItem/UsersTableItem.tsx | 8 +- src/screens/OrgList/OrgList.tsx | 41 ++- src/screens/OrgList/OrgListMocks.ts | 33 +- src/screens/OrgList/OrganizationModal.tsx | 92 +++++- src/utils/interfaces.ts | 19 +- 12 files changed, 563 insertions(+), 90 deletions(-) diff --git a/src/GraphQl/Mutations/mutations.ts b/src/GraphQl/Mutations/mutations.ts index e27f6733b8..3d3878ad22 100644 --- a/src/GraphQl/Mutations/mutations.ts +++ b/src/GraphQl/Mutations/mutations.ts @@ -45,7 +45,7 @@ export const UPDATE_ORGANIZATION_MUTATION = gql` $id: ID! $name: String $description: String - $location: String + $address: AddressInput $userRegistrationRequired: Boolean $visibleInSearch: Boolean $file: String @@ -57,7 +57,7 @@ export const UPDATE_ORGANIZATION_MUTATION = gql` description: $description userRegistrationRequired: $userRegistrationRequired visibleInSearch: $visibleInSearch - location: $location + address: $address } file: $file ) { @@ -66,6 +66,20 @@ export const UPDATE_ORGANIZATION_MUTATION = gql` } `; +// fragment for defining the Address input type. +export const ADDRESS_DETAILS_FRAGMENT = gql` + fragment AddressDetails on AddressInput { + city + countryCode + dependentLocality + line1 + line2 + postalCode + sortingCode + state + } +`; + // to update the details of the user export const UPDATE_USER_MUTATION = gql` @@ -178,7 +192,7 @@ export const RECAPTCHA_MUTATION = gql` export const CREATE_ORGANIZATION_MUTATION = gql` mutation CreateOrganization( $description: String! - $location: String! + $address: AddressInput! $name: String! $visibleInSearch: Boolean! $userRegistrationRequired: Boolean! @@ -187,7 +201,7 @@ export const CREATE_ORGANIZATION_MUTATION = gql` createOrganization( data: { description: $description - location: $location + address: $address name: $name visibleInSearch: $visibleInSearch userRegistrationRequired: $userRegistrationRequired diff --git a/src/GraphQl/Queries/Queries.ts b/src/GraphQl/Queries/Queries.ts index 1941add36a..00b14b146a 100644 --- a/src/GraphQl/Queries/Queries.ts +++ b/src/GraphQl/Queries/Queries.ts @@ -34,7 +34,7 @@ export const ORGANIZATION_LIST = gql` _id } createdAt - location + address } } `; @@ -67,7 +67,7 @@ export const ORGANIZATION_CONNECTION_LIST = gql` _id } createdAt - location + address } } `; @@ -103,7 +103,7 @@ export const USER_LIST = gql` _id name image - location + address createdAt creator { _id @@ -118,7 +118,7 @@ export const USER_LIST = gql` _id name image - location + address createdAt creator { _id @@ -252,7 +252,7 @@ export const ORGANIZATIONS_LIST = gql` } name description - location + address userRegistrationRequired visibleInSearch members { diff --git a/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx b/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx index 94f6f2be64..e77b5aaaa5 100644 --- a/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx +++ b/src/components/LeftDrawerOrg/LeftDrawerOrg.tsx @@ -124,7 +124,7 @@ const leftDrawerOrg = ({
{organization.name} - {organization.location} + {organization.address.city}
diff --git a/src/components/OrgListCard/OrgListCard.test.tsx b/src/components/OrgListCard/OrgListCard.test.tsx index ffcf92981f..5f256233be 100644 --- a/src/components/OrgListCard/OrgListCard.test.tsx +++ b/src/components/OrgListCard/OrgListCard.test.tsx @@ -32,7 +32,16 @@ const props: InterfaceOrgListCardProps = { _id: 'xyz', name: 'Dogs Care', image: 'https://api.dicebear.com/5.x/initials/svg?seed=John%20Doe', - location: 'India', + address: { + city: 'Sample City', + countryCode: 'US', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Sample Street', + line2: 'Apartment 456', + postalCode: '12345', + sortingCode: 'ABC-123', + state: 'Sample State', + }, admins: [ { _id: '123', diff --git a/src/components/OrgListCard/OrgListCard.tsx b/src/components/OrgListCard/OrgListCard.tsx index 24c8137051..3db455169b 100644 --- a/src/components/OrgListCard/OrgListCard.tsx +++ b/src/components/OrgListCard/OrgListCard.tsx @@ -15,7 +15,7 @@ export interface InterfaceOrgListCardProps { } function orgListCard(props: InterfaceOrgListCardProps): JSX.Element { - const { _id, admins, image, location, members, name } = props.data; + const { _id, admins, image, address, members, name } = props.data; const { data } = useQuery(IS_SAMPLE_ORGANIZATION_QUERY, { variables: { @@ -62,7 +62,7 @@ function orgListCard(props: InterfaceOrgListCardProps): JSX.Element {
- {location} + {address.city}
{t('admins')}: {admins.length} diff --git a/src/components/OrgUpdate/OrgUpdate.tsx b/src/components/OrgUpdate/OrgUpdate.tsx index ccbb8214b8..a6c484dc3c 100644 --- a/src/components/OrgUpdate/OrgUpdate.tsx +++ b/src/components/OrgUpdate/OrgUpdate.tsx @@ -12,8 +12,11 @@ import Loader from 'components/Loader/Loader'; import { Col, Form, Row } from 'react-bootstrap'; import convertToBase64 from 'utils/convertToBase64'; import { errorHandler } from 'utils/errorHandler'; -import type { InterfaceQueryOrganizationsListObject } from 'utils/interfaces'; import styles from './OrgUpdate.module.css'; +import type { + InterfaceQueryOrganizationsListObject, + InterfaceAddress, +} from 'utils/interfaces'; interface InterfaceOrgUpdateProps { orgId: string; @@ -25,15 +28,34 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element { const [formState, setFormState] = useState<{ orgName: string; orgDescrip: string; - location: string; + address: InterfaceAddress; orgImage: string | null; }>({ orgName: '', orgDescrip: '', - location: '', + address: { + city: '', + countryCode: '', + dependentLocality: '', + line1: '', + line2: '', + postalCode: '', + sortingCode: '', + state: '', + }, orgImage: null, }); + const handleInputChange = (fieldName: string, value: string): void => { + setFormState((prevState) => ({ + ...prevState, + address: { + ...prevState.address, + [fieldName]: value, + }, + })); + }; + const [userRegistrationRequiredChecked, setuserRegistrationRequiredChecked] = React.useState(false); const [visiblechecked, setVisibleChecked] = React.useState(false); @@ -68,7 +90,7 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element { ...formState, orgName: data.organizations[0].name, orgDescrip: data.organizations[0].description, - location: data.organizations[0].location, + address: data.organizations[0].address, }); setuserRegistrationRequiredChecked( data.organizations[0].userRegistrationRequired @@ -87,7 +109,7 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element { id: orgId, name: formState.orgName, description: formState.orgDescrip, - location: formState.location, + address: formState.address, userRegistrationRequired: userRegistrationRequiredChecked, visibleInSearch: visiblechecked, file: formState.orgImage, @@ -152,19 +174,72 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element { }); }} /> - {t('location')} + {t('address')} { - setFormState({ - ...formState, - location: e.target.value, - }); - }} + value={formState.address.city} + onChange={(e) => handleInputChange('city', e.target.value)} + /> + handleInputChange('countryCode', e.target.value)} + /> + + handleInputChange('dependentLocality', e.target.value) + } + /> + handleInputChange('line1', e.target.value)} + /> + handleInputChange('line2', e.target.value)} + /> + handleInputChange('postalCode', e.target.value)} + /> + handleInputChange('sortingCode', e.target.value)} + /> + handleInputChange('state', e.target.value)} /> diff --git a/src/components/UsersTableItem/UserTableItem.test.tsx b/src/components/UsersTableItem/UserTableItem.test.tsx index 6767f73229..fc9bc2bdd6 100644 --- a/src/components/UsersTableItem/UserTableItem.test.tsx +++ b/src/components/UsersTableItem/UserTableItem.test.tsx @@ -87,7 +87,16 @@ describe('Testing User Table Item', () => { _id: 'xyz', name: 'XYZ', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-01-29T15:39:36.355Z', creator: { _id: '123', @@ -101,7 +110,16 @@ describe('Testing User Table Item', () => { _id: 'mno', name: 'MNO', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-01-29T15:39:36.355Z', creator: { _id: '123', @@ -117,7 +135,16 @@ describe('Testing User Table Item', () => { _id: 'abc', name: 'Joined Organization 1', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-06-29T15:39:36.355Z', creator: { _id: '123', @@ -131,7 +158,16 @@ describe('Testing User Table Item', () => { _id: 'def', name: 'Joined Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-07-29T15:39:36.355Z', creator: { _id: '123', @@ -259,7 +295,16 @@ describe('Testing User Table Item', () => { _id: 'xyz', name: 'Blocked Organization 1', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -273,7 +318,16 @@ describe('Testing User Table Item', () => { _id: 'mno', name: 'Blocked Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-29T15:39:36.355Z', creator: { _id: '123', @@ -290,7 +344,16 @@ describe('Testing User Table Item', () => { name: 'Joined Organization 1', image: 'https://api.dicebear.com/5.x/initials/svg?seed=Joined%20Organization%201', - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -305,7 +368,16 @@ describe('Testing User Table Item', () => { _id: 'def', name: 'Joined Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-19T15:39:36.355Z', creator: { _id: '123', @@ -433,7 +505,16 @@ describe('Testing User Table Item', () => { name: 'Blocked Organization 1', image: 'https://api.dicebear.com/5.x/initials/svg?seed=Blocked%20Organization%201', - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -448,7 +529,16 @@ describe('Testing User Table Item', () => { _id: 'mno', name: 'Blocked Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-29T15:39:36.355Z', creator: { _id: '123', @@ -464,7 +554,16 @@ describe('Testing User Table Item', () => { _id: 'abc', name: 'Joined Organization 1', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -478,7 +577,16 @@ describe('Testing User Table Item', () => { _id: 'def', name: 'Joined Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-19T15:39:36.355Z', creator: { _id: '123', @@ -609,7 +717,16 @@ describe('Testing User Table Item', () => { name: 'Blocked Organization 1', image: 'https://api.dicebear.com/5.x/initials/svg?seed=Blocked%20Organization%201', - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -624,7 +741,16 @@ describe('Testing User Table Item', () => { _id: 'mno', name: 'Blocked Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-29T15:39:36.355Z', creator: { _id: '123', @@ -640,7 +766,16 @@ describe('Testing User Table Item', () => { _id: 'abc', name: 'Joined Organization 1', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -654,7 +789,16 @@ describe('Testing User Table Item', () => { _id: 'def', name: 'Joined Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-19T15:39:36.355Z', creator: { _id: '123', @@ -747,7 +891,16 @@ describe('Testing User Table Item', () => { name: 'Blocked Organization 1', image: 'https://api.dicebear.com/5.x/initials/svg?seed=Blocked%20Organization%201', - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -762,7 +915,16 @@ describe('Testing User Table Item', () => { _id: 'mno', name: 'Blocked Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-29T15:39:36.355Z', creator: { _id: '123', @@ -778,7 +940,16 @@ describe('Testing User Table Item', () => { _id: 'abc', name: 'Joined Organization 1', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -792,7 +963,16 @@ describe('Testing User Table Item', () => { _id: 'def', name: 'Joined Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-19T15:39:36.355Z', creator: { _id: '123', @@ -887,7 +1067,16 @@ describe('Testing User Table Item', () => { name: 'Blocked Organization 1', image: 'https://api.dicebear.com/5.x/initials/svg?seed=Blocked%20Organization%201', - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -902,7 +1091,16 @@ describe('Testing User Table Item', () => { _id: 'mno', name: 'Blocked Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-29T15:39:36.355Z', creator: { _id: '123', @@ -918,7 +1116,16 @@ describe('Testing User Table Item', () => { _id: 'abc', name: 'Joined Organization 1', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -932,7 +1139,16 @@ describe('Testing User Table Item', () => { _id: 'def', name: 'Joined Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-19T15:39:36.355Z', creator: { _id: '123', @@ -993,7 +1209,16 @@ describe('Testing User Table Item', () => { name: 'Blocked Organization 1', image: 'https://api.dicebear.com/5.x/initials/svg?seed=Blocked%20Organization%201', - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -1008,7 +1233,16 @@ describe('Testing User Table Item', () => { _id: 'mno', name: 'Blocked Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-29T15:39:36.355Z', creator: { _id: '123', @@ -1024,7 +1258,16 @@ describe('Testing User Table Item', () => { _id: 'abc', name: 'Joined Organization 1', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-08-29T15:39:36.355Z', creator: { _id: '123', @@ -1038,7 +1281,16 @@ describe('Testing User Table Item', () => { _id: 'def', name: 'Joined Organization 2', image: null, - location: 'Jamaica', + address: { + city: 'Kingston', + countryCode: 'JM', + dependentLocality: 'Sample Dependent Locality', + line1: '123 Jamaica Street', + line2: 'Apartment 456', + postalCode: 'JM12345', + sortingCode: 'ABC-123', + state: 'Kingston Parish', + }, createdAt: '2023-09-19T15:39:36.355Z', creator: { _id: '123', diff --git a/src/components/UsersTableItem/UsersTableItem.tsx b/src/components/UsersTableItem/UsersTableItem.tsx index 842329e44b..01617098e0 100644 --- a/src/components/UsersTableItem/UsersTableItem.tsx +++ b/src/components/UsersTableItem/UsersTableItem.tsx @@ -281,7 +281,7 @@ const UsersTableItem = (props: Props): JSX.Element => { Name - Location + Address Created on Created By Users Role @@ -317,7 +317,7 @@ const UsersTableItem = (props: Props): JSX.Element => { {org.name} - {org.location} + {org.address.city} {dayjs(org.createdAt).format('DD-MM-YYYY')} - {org.location} + {org.address.city} {dayjs(org.createdAt).format('DD-MM-YYYY')} diff --git a/src/components/OrgListCard/OrgListCard.tsx b/src/components/OrgListCard/OrgListCard.tsx index 0d4fc2c15e..00509a418e 100644 --- a/src/components/OrgListCard/OrgListCard.tsx +++ b/src/components/OrgListCard/OrgListCard.tsx @@ -61,10 +61,17 @@ function orgListCard(props: InterfaceOrgListCardProps): JSX.Element {

{name}

{address && address.city && ( -
- - {address.city} -
+
+
+ + {address.city}, + {address.state} +
+ + {address.postalCode}, + {address.countryCode} +
+
)}
{t('admins')}: {admins.length} diff --git a/src/components/OrgUpdate/OrgUpdate.tsx b/src/components/OrgUpdate/OrgUpdate.tsx index a6c484dc3c..acc380d7f4 100644 --- a/src/components/OrgUpdate/OrgUpdate.tsx +++ b/src/components/OrgUpdate/OrgUpdate.tsx @@ -109,7 +109,16 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element { id: orgId, name: formState.orgName, description: formState.orgDescrip, - address: formState.address, + address: { + city: formState.address.city, + countryCode: formState.address.countryCode, + dependentLocality: formState.address.dependentLocality, + line1: formState.address.line1, + line2: formState.address.line2, + postalCode: formState.address.postalCode, + sortingCode: formState.address.sortingCode, + state: formState.address.state, + }, userRegistrationRequired: userRegistrationRequiredChecked, visibleInSearch: visiblechecked, file: formState.orgImage, @@ -175,72 +184,94 @@ function orgUpdate(props: InterfaceOrgUpdateProps): JSX.Element { }} /> {t('address')} - handleInputChange('city', e.target.value)} - /> - handleInputChange('countryCode', e.target.value)} - /> - - handleInputChange('dependentLocality', e.target.value) - } - /> - handleInputChange('line1', e.target.value)} - /> - handleInputChange('line2', e.target.value)} - /> - handleInputChange('postalCode', e.target.value)} - /> - handleInputChange('sortingCode', e.target.value)} - /> - handleInputChange('state', e.target.value)} - /> + + + + handleInputChange('countryCode', e.target.value) + } + /> + + + handleInputChange('city', e.target.value)} + /> + + + + + handleInputChange('state', e.target.value)} + /> + + + + handleInputChange('dependentLocality', e.target.value) + } + /> + + + + + handleInputChange('line1', e.target.value)} + /> + + + handleInputChange('line2', e.target.value)} + /> + + + + + + handleInputChange('postalCode', e.target.value) + } + /> + + + + handleInputChange('sortingCode', e.target.value) + } + /> + + diff --git a/src/screens/OrgList/OrganizationModal.tsx b/src/screens/OrgList/OrganizationModal.tsx index bcfd600677..4918543dda 100644 --- a/src/screens/OrgList/OrganizationModal.tsx +++ b/src/screens/OrgList/OrganizationModal.tsx @@ -132,72 +132,94 @@ const OrganizationModal: React.FC = ({ }} /> {t('address')} - handleInputChange('city', e.target.value)} - /> - handleInputChange('countryCode', e.target.value)} - /> - - handleInputChange('dependentLocality', e.target.value) - } - /> - handleInputChange('line1', e.target.value)} - /> - handleInputChange('line2', e.target.value)} - /> - handleInputChange('postalCode', e.target.value)} - /> - handleInputChange('sortingCode', e.target.value)} - /> - handleInputChange('state', e.target.value)} - /> + + + + handleInputChange('countryCode', e.target.value) + } + /> + + + handleInputChange('city', e.target.value)} + /> + + + + + handleInputChange('state', e.target.value)} + /> + + + + handleInputChange('dependentLocality', e.target.value) + } + /> + + + + + handleInputChange('line1', e.target.value)} + /> + + + handleInputChange('line2', e.target.value)} + /> + + + + + + handleInputChange('postalCode', e.target.value) + } + /> + + + + handleInputChange('sortingCode', e.target.value) + } + /> + + From 79bd263884459f27486f45dc1520308e14841a0f Mon Sep 17 00:00:00 2001 From: Anubhav Banerjee Date: Tue, 23 Jan 2024 19:27:19 +0530 Subject: [PATCH 05/18] Fixed address field in queries, and added translationdata --- public/locales/fr.json | 18 ++++++++++ public/locales/hi.json | 18 ++++++++++ public/locales/sp.json | 18 ++++++++++ public/locales/zh.json | 18 ++++++++++ src/GraphQl/Queries/Queries.ts | 33 +++++++++++++++++-- .../UsersTableItem/UsersTableItem.tsx | 4 +-- 6 files changed, 104 insertions(+), 5 deletions(-) diff --git a/public/locales/fr.json b/public/locales/fr.json index 80ae5c3587..de1415f7b1 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -127,6 +127,15 @@ "createSampleOrganization": "Créer une organisation d'exemple", "description": "La description", "location": "Emplacement", + "address": "Adresse", + "city": "Ville", + "countryCode": "Code Pays", + "line1": "Ligne 1", + "line2": "Ligne 2", + "postalCode": "Code Postal", + "dependentLocality": "Localité Dépendante", + "sortingCode": "Code de Tri", + "state": "État / Province", "userRegistrationRequired": "enregistrement requis", "visibleInSearch": "Visible dans la recherche", "displayImage": "Afficher l'image", @@ -484,6 +493,15 @@ "name": "Nom", "description": "La description", "location": "emplacement", + "address": "Adresse", + "city": "Ville", + "countryCode": "Code Pays", + "line1": "Ligne 1", + "line2": "Ligne 2", + "postalCode": "Code Postal", + "dependentLocality": "Localité Dépendante", + "sortingCode": "Code de Tri", + "state": "État / Province", "displayImage": "Afficher l'image", "userRegistrationRequired": "enregistrement requis", "isVisibleInSearch": "Visible dans la recherche", diff --git a/public/locales/hi.json b/public/locales/hi.json index 9cec18077c..3d9d86398b 100644 --- a/public/locales/hi.json +++ b/public/locales/hi.json @@ -127,6 +127,15 @@ "createSampleOrganization": " सैंपल संगठन बनाएं", "description": "विवरण", "location": "स्थान", + "address": "पता", + "city": "शहर", + "countryCode": "देश कोड", + "line1": "लाइन 1", + "line2": "लाइन 2", + "postalCode": "पोस्टल कोड", + "dependentLocality": "आश्रित स्थान", + "sortingCode": "क्रमबद्ध कोड", + "state": "राज्य / प्रांत", "userRegistrationRequired": "उपयोगकर्ता पंजीकरण आवश्यक", "visibleInSearch": "खोज में दृश्यमान", "displayImage": "प्रदर्शन छवि", @@ -483,6 +492,15 @@ "name": "नाम", "description": "विवरण", "location": "जगह", + "address": "पता", + "city": "शहर", + "countryCode": "देश कोड", + "line1": "लाइन 1", + "line2": "लाइन 2", + "postalCode": "पोस्टल कोड", + "dependentLocality": "आश्रित स्थान", + "sortingCode": "क्रमबद्ध कोड", + "state": "राज्य / प्रांत", "displayImage": "प्रदर्शन छवि", "userRegistrationRequired": "उपयोगकर्ता पंजीकरण आवश्यक", "isVisibleInSearch": "खोज में दिखाए जा सकते हैं", diff --git a/public/locales/sp.json b/public/locales/sp.json index 4b090a0eb5..dc4b72fba0 100644 --- a/public/locales/sp.json +++ b/public/locales/sp.json @@ -127,6 +127,15 @@ "createSampleOrganization": "Crear organización de muestra", "description": "Descripción", "location": "Ubicación", + "address": "Dirección", + "city": "Ciudad", + "countryCode": "Código de País", + "line1": "Línea 1", + "line2": "Línea 2", + "postalCode": "Código Postal", + "dependentLocality": "Localidad Dependiente", + "sortingCode": "Código de Ordenamiento", + "state": "Estado / Provincia", "userRegistrationRequired": "Registro de usuario requerido", "visibleInSearch": "Visible en la búsqueda", "displayImage": "Mostrar imagen", @@ -483,6 +492,15 @@ "name": "Nombre", "description": "Descripción", "location": "ubicación", + "address": "Dirección", + "city": "Ciudad", + "countryCode": "Código de País", + "line1": "Línea 1", + "line2": "Línea 2", + "postalCode": "Código Postal", + "dependentLocality": "Localidad Dependiente", + "sortingCode": "Código de Ordenamiento", + "state": "Estado / Provincia", "displayImage": "Mostrar imagen", "userRegistrationRequired": "Registro de usuario requerido", "isVisibleInSearch": "Visible en la búsqueda", diff --git a/public/locales/zh.json b/public/locales/zh.json index daacd5ec93..632a18b70a 100644 --- a/public/locales/zh.json +++ b/public/locales/zh.json @@ -127,6 +127,15 @@ "createSampleOrganization": "创建示范组织", "description": "描述", "location": "地點", + "address": "地址", + "city": "城市", + "countryCode": "国家代码", + "line1": "地址行 1", + "line2": "地址行 2", + "postalCode": "邮政编码", + "dependentLocality": "从属地区", + "sortingCode": "排序代码", + "state": "省 / 直辖市", "isPubluserRegistrationRequiredic": "需要用户注册", "visibleInSearch": "在搜索中可見", "displayImage": "顯示圖像", @@ -483,6 +492,15 @@ "name": "姓名", "description": "描述", "location": "地點", + "address": "地址", + "city": "城市", + "countryCode": "国家代码", + "line1": "地址行 1", + "line2": "地址行 2", + "postalCode": "邮政编码", + "dependentLocality": "从属地区", + "sortingCode": "排序代码", + "state": "省 / 直辖市", "displayImage": "顯示圖像", "userRegistrationRequired": "需要用户注册", "isVisibleInSearch": "在搜索中可见", diff --git a/src/GraphQl/Queries/Queries.ts b/src/GraphQl/Queries/Queries.ts index fa262775a3..835ddcb169 100644 --- a/src/GraphQl/Queries/Queries.ts +++ b/src/GraphQl/Queries/Queries.ts @@ -34,7 +34,16 @@ export const ORGANIZATION_LIST = gql` _id } createdAt - address + address { + city + countryCode + dependentLocality + line1 + line2 + postalCode + sortingCode + state + } } } `; @@ -112,7 +121,16 @@ export const USER_LIST = gql` _id name image - address + address { + city + countryCode + dependentLocality + line1 + line2 + postalCode + sortingCode + state + } createdAt creator { _id @@ -127,7 +145,16 @@ export const USER_LIST = gql` _id name image - address + address { + city + countryCode + dependentLocality + line1 + line2 + postalCode + sortingCode + state + } createdAt creator { _id diff --git a/src/components/UsersTableItem/UsersTableItem.tsx b/src/components/UsersTableItem/UsersTableItem.tsx index 01617098e0..f0a2ac3007 100644 --- a/src/components/UsersTableItem/UsersTableItem.tsx +++ b/src/components/UsersTableItem/UsersTableItem.tsx @@ -317,7 +317,7 @@ const UsersTableItem = (props: Props): JSX.Element => { {org.name} - {org.address.city} + {org.address && {org.address.city}} {dayjs(org.createdAt).format('DD-MM-YYYY')} - {org.address.city} + {org.address && {org.address.city}} {dayjs(org.createdAt).format('DD-MM-YYYY')}