Skip to content

Commit a8d7801

Browse files
rdonigianCarsonF
authored andcommitted
Create Reach and Org Type section for Partner
1 parent 5fd5275 commit a8d7801

File tree

5 files changed

+115
-1
lines changed

5 files changed

+115
-1
lines changed

src/scenes/Partners/Detail/PartnerDetail.graphql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,14 @@ fragment organizationDetails on Organization {
7878
canEdit
7979
value
8080
}
81+
types {
82+
canRead
83+
canEdit
84+
value
85+
}
86+
reach {
87+
canRead
88+
canEdit
89+
value
90+
}
8191
}

src/scenes/Partners/Detail/Tabs/Profile/PartnerDetailProfile.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { TabPanelContent } from '~/components/Tabs';
55
import { EditablePartnerField } from '../../../Edit';
66
import { PartnerDetailsFragment } from '../../PartnerDetail.graphql';
77
import { PartnerContactSection } from './PartnerContactSection';
8+
import { PartnerOrgReachAndTypeSection } from './PartnerOrgReachAndTypeSection';
89
import { PartnerTypesSection } from './PartnerTypesSection';
910

1011
interface Props {
@@ -35,6 +36,12 @@ export const PartnerDetailProfile = ({ partner, editPartner: edit }: Props) => (
3536
}
3637
/>
3738
</Grid>
39+
<Grid xs={12} md={6}>
40+
<PartnerOrgReachAndTypeSection
41+
partner={partner}
42+
onEdit={() => edit(['organization.types', 'organization.reach'])}
43+
/>
44+
</Grid>
3845
</Grid>
3946
</TabPanelContent>
4047
);
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import { Edit } from '@mui/icons-material';
2+
import { Stack, Tooltip } from '@mui/material';
3+
import {
4+
OrganizationReachLabels,
5+
OrganizationTypeLabels,
6+
} from '~/api/schema.graphql';
7+
import { canEditAny, labelFrom } from '~/common';
8+
import { ActionableSection } from '~/components/ActionableSection';
9+
import { IconButton } from '~/components/IconButton';
10+
import { PartnerDetailsFragment } from '../../PartnerDetail.graphql';
11+
import { DisplaySecuredList } from './PartnerTypesSection';
12+
13+
interface PartnerOrgReachAndTypeProps {
14+
partner?: PartnerDetailsFragment;
15+
onEdit: () => void;
16+
className?: string;
17+
}
18+
19+
export const PartnerOrgReachAndTypeSection = ({
20+
partner,
21+
onEdit,
22+
}: PartnerOrgReachAndTypeProps) => {
23+
const canEdit = canEditAny(
24+
partner?.organization.value,
25+
false,
26+
'types',
27+
'reach'
28+
);
29+
30+
return (
31+
<ActionableSection
32+
title="Additional Information"
33+
loading={!partner}
34+
action={
35+
<Tooltip title="Edit">
36+
<span>
37+
<IconButton
38+
disabled={!canEdit}
39+
onClick={onEdit}
40+
loading={!partner}
41+
size="small"
42+
>
43+
<Edit />
44+
</IconButton>
45+
</span>
46+
</Tooltip>
47+
}
48+
>
49+
<Stack
50+
direction="row"
51+
columnGap={4}
52+
rowGap={3}
53+
justifyContent="space-between"
54+
flexWrap="wrap"
55+
maxWidth={350}
56+
>
57+
<DisplaySecuredList
58+
title="Organizational Types"
59+
data={partner?.organization.value?.types}
60+
labelBy={labelFrom(OrganizationTypeLabels)}
61+
redacted={{ fieldDescription: `organizational types` }}
62+
/>
63+
<DisplaySecuredList
64+
title="Partner Reach"
65+
data={partner?.organization.value?.reach}
66+
labelBy={labelFrom(OrganizationReachLabels)}
67+
redacted={{
68+
fieldDescription: `partner's reach`,
69+
width: `75%`,
70+
}}
71+
/>
72+
</Stack>
73+
</ActionableSection>
74+
);
75+
};

src/scenes/Partners/Detail/Tabs/Profile/PartnerTypesSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const PartnerTypesSection = ({
7575
);
7676
};
7777

78-
const DisplaySecuredList = <T extends string>({
78+
export const DisplaySecuredList = <T extends string>({
7979
title,
8080
data,
8181
labelBy,

src/scenes/Partners/Edit/EditPartner.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
CoerceNonPrimitives,
99
FinancialReportingTypeLabels,
1010
FinancialReportingTypeList,
11+
OrganizationReachList,
12+
OrganizationTypeList,
1113
PartnerTypeList,
1214
UpdateOrganization,
1315
UpdatePartner,
@@ -108,6 +110,24 @@ const fieldMapping = {
108110
'organization.acronym': ({ props }) => (
109111
<TextField {...props} label="Acronym" />
110112
),
113+
'organization.reach': ({ props }) => (
114+
<EnumField
115+
multiple
116+
label="Reach"
117+
options={OrganizationReachList}
118+
layout="two-column"
119+
{...props}
120+
/>
121+
),
122+
'organization.types': ({ props }) => (
123+
<EnumField
124+
multiple
125+
label="Types"
126+
options={OrganizationTypeList}
127+
layout="two-column"
128+
{...props}
129+
/>
130+
),
111131
} satisfies PossibleFields;
112132

113133
const decorators: Array<Decorator<PartnerFormValues>> = [
@@ -151,6 +171,8 @@ export const EditPartner = ({
151171
id: organization.id,
152172
name: organization.name.value,
153173
acronym: organization.acronym.value,
174+
types: organization.types.value,
175+
reach: organization.reach.value,
154176
},
155177
} satisfies PartnerFormValues;
156178
}, [partner]);

0 commit comments

Comments
 (0)