Skip to content

Commit e809fbc

Browse files
authored
Merge pull request #954 from IFRCGo/fix/healthcare-hot-fixes
Healthcare hot fixes
2 parents f3c397a + 7f0212b commit e809fbc

File tree

12 files changed

+115
-45
lines changed

12 files changed

+115
-45
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"go-web-app": patch
3+
---
4+
5+
Integrate mapbox street view for local units map

.changeset/smart-plums-remember.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ifrc-go/ui": patch
3+
---
4+
5+
Add ellipsize prop to Heading component

app/src/components/Link/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@ function Link(props: Props) {
285285
ellipsize && styles.ellipsized,
286286
className,
287287
)}
288+
title={(ellipsize && typeof childrenFromProps === 'string')
289+
? childrenFromProps : undefined}
288290
>
289291
{children}
290292
</div>

app/src/components/Link/styles.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
width: fit-content;
88

99
&.ellipsized {
10+
width: 100%;
1011
overflow: auto;
1112
}
1213

app/src/components/domain/ActiveCountryBaseMapLayer/index.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ import {
1212
COLOR_WHITE,
1313
} from '#utils/constants';
1414

15+
const hiddenFillLayerOptions: Omit<FillLayer, 'id'> = {
16+
type: 'fill',
17+
layout: {
18+
visibility: 'none',
19+
},
20+
};
21+
1522
interface Props {
1623
activeCountryIso3: string | undefined | null;
1724
}
@@ -25,10 +32,18 @@ function ActiveCountryBaseMapLayer(props: Props) {
2532
layout: { visibility: 'visible' },
2633
paint: {
2734
'fill-color': [
28-
'match',
29-
['get', 'iso3'],
30-
activeCountryIso3,
31-
COLOR_ACTIVE_REGION,
35+
'interpolate',
36+
['linear'],
37+
['zoom'],
38+
2,
39+
[
40+
'match',
41+
['get', 'iso3'],
42+
activeCountryIso3,
43+
COLOR_ACTIVE_REGION,
44+
COLOR_LIGHT_GREY,
45+
],
46+
10,
3247
COLOR_LIGHT_GREY,
3348
],
3449
},
@@ -80,6 +95,10 @@ function ActiveCountryBaseMapLayer(props: Props) {
8095
layerKey="admin-0"
8196
layerOptions={adminZeroHighlightLayerOptions}
8297
/>
98+
<MapLayer
99+
layerKey="admin-0-highlight"
100+
layerOptions={hiddenFillLayerOptions}
101+
/>
83102
<MapLayer
84103
layerKey="admin-1-boundary"
85104
layerOptions={adminOneBoundaryLayerOptions}

app/src/components/domain/HighlightedOperations/OperationCard/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ function OperationCard(props: Props) {
119119
<Container
120120
className={_cs(styles.operationCard, className)}
121121
// heading={name}
122+
headingClassName={styles.heading}
123+
headingContainerClassName={styles.headingContainer}
122124
heading={(
123125
<Link
124126
to="emergenciesLayout"

app/src/components/domain/HighlightedOperations/OperationCard/styles.module.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
.operation-card {
22
border-radius: var(--go-ui-border-radius-lg);
33
box-shadow: var(--go-ui-box-shadow-md);
4+
width: 100%;
5+
overflow: auto;
6+
7+
.heading-container {
8+
width: 100%;
9+
overflow: auto;
10+
}
11+
12+
.heading {
13+
width: 100%;
14+
overflow: auto;
15+
}
416

517
.severity-indicator {
618
font-size: var(--go-ui-font-size-xl);

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsMap/index.tsx

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import react from 'react';
1+
import react, { useMemo } from 'react';
22
import { useOutletContext } from 'react-router-dom';
33
import {
44
LocationIcon,
@@ -34,7 +34,7 @@ import BaseMap from '#components/domain/BaseMap';
3434
import Link, { type Props as LinkProps } from '#components/Link';
3535
import MapContainerWithDisclaimer from '#components/MapContainerWithDisclaimer';
3636
import MapPopup from '#components/MapPopup';
37-
import useUserMe from '#hooks/domain/useUserMe';
37+
import usePermissions from '#hooks/domain/usePermissions';
3838
import useFilterState from '#hooks/useFilterState';
3939
import {
4040
COLOR_DARK_GREY,
@@ -49,7 +49,11 @@ import {
4949
useRequest,
5050
} from '#utils/restRequest';
5151

52-
import { VALIDATED } from '../common';
52+
import {
53+
AUTHENTICATED,
54+
PUBLIC,
55+
VALIDATED,
56+
} from '../common';
5357
import Filters, { FilterValue } from '../Filters';
5458

5559
import i18n from './i18n.json';
@@ -127,13 +131,28 @@ function LocalUnitsMap() {
127131
[limit, filter, countryResponse],
128132
);
129133

130-
const meResponse = useUserMe();
134+
const { isCountryAdmin, isSuperUser } = usePermissions();
135+
136+
const requestType = useMemo(
137+
() => {
138+
if (isSuperUser) {
139+
return 'authenticated';
140+
}
141+
142+
if (isCountryAdmin(countryResponse?.id)) {
143+
return 'authenticated';
144+
}
145+
146+
return 'public';
147+
},
148+
[countryResponse, isSuperUser, isCountryAdmin],
149+
);
131150

132151
const {
133152
response: publicLocalUnitsResponse,
134153
pending: publicLocalUnitsPending,
135154
} = useRequest({
136-
skip: isNotDefined(countryResponse?.iso3) || meResponse?.is_superuser,
155+
skip: requestType !== PUBLIC || isNotDefined(countryResponse),
137156
url: '/api/v2/public-local-units/',
138157
query: urlQuery,
139158
});
@@ -142,14 +161,13 @@ function LocalUnitsMap() {
142161
response: localUnitsResponse,
143162
pending: localUnitsPending,
144163
} = useRequest({
145-
skip: isNotDefined(countryResponse?.iso3)
146-
|| isNotDefined(meResponse)
147-
|| !meResponse.is_superuser,
164+
skip: requestType !== AUTHENTICATED || isNotDefined(countryResponse),
148165
url: '/api/v2/local-units/',
149166
query: urlQuery,
150167
});
151168

152-
const localUnits = meResponse?.is_superuser ? localUnitsResponse : publicLocalUnitsResponse;
169+
const localUnits = (isSuperUser || isCountryAdmin(countryResponse?.id))
170+
? localUnitsResponse : publicLocalUnitsResponse;
153171
const pending = publicLocalUnitsPending || localUnitsPending;
154172

155173
const strings = useTranslation(i18n);
@@ -218,7 +236,7 @@ function LocalUnitsMap() {
218236
pending: publicLocalUnitDetailPending,
219237
error: publicLocalUnitDetailError,
220238
} = useRequest({
221-
skip: isNotDefined(clickedPointProperties?.localUnitId) || meResponse?.is_superuser,
239+
skip: requestType !== PUBLIC || isNotDefined(clickedPointProperties),
222240
url: '/api/v2/public-local-units/{id}/',
223241
pathVariables: isDefined(clickedPointProperties) ? ({
224242
id: clickedPointProperties.localUnitId,
@@ -230,26 +248,24 @@ function LocalUnitsMap() {
230248
pending: superLocalUnitDetailPending,
231249
error: superLocalUnitDetailError,
232250
} = useRequest({
233-
skip: isNotDefined(clickedPointProperties?.localUnitId)
234-
|| isNotDefined(meResponse)
235-
|| !meResponse.is_superuser,
251+
skip: requestType !== AUTHENTICATED || isNotDefined(clickedPointProperties),
236252
url: '/api/v2/local-units/{id}/',
237253
pathVariables: isDefined(clickedPointProperties) ? ({
238254
id: clickedPointProperties.localUnitId,
239255
}) : undefined,
240256
});
241257

242-
const localUnitDetail = meResponse?.is_superuser
243-
? superLocalUnitDetailResponse
244-
: publicLocalUnitDetailResponse;
258+
const localUnitDetail = requestType !== AUTHENTICATED
259+
? publicLocalUnitDetailResponse
260+
: superLocalUnitDetailResponse;
245261

246-
const localUnitDetailPending = meResponse?.is_superuser
247-
? superLocalUnitDetailPending
248-
: publicLocalUnitDetailPending;
262+
const localUnitDetailPending = requestType !== AUTHENTICATED
263+
? publicLocalUnitDetailPending
264+
: superLocalUnitDetailPending;
249265

250-
const localUnitDetailError = meResponse?.is_superuser
251-
? superLocalUnitDetailError
252-
: publicLocalUnitDetailError;
266+
const localUnitDetailError = requestType !== AUTHENTICATED
267+
? publicLocalUnitDetailError
268+
: superLocalUnitDetailError;
253269

254270
const localUnitsGeoJson = react.useMemo<GeoJSON.FeatureCollection<GeoJSON.Geometry>>(
255271
() => ({
@@ -337,6 +353,7 @@ function LocalUnitsMap() {
337353
>
338354
<div className={styles.mapContainerWithContactDetails}>
339355
<BaseMap
356+
mapStyle="mapbox://styles/go-ifrc/clvvgugzh00x501pc1n00b8cz"
340357
withoutLabel
341358
baseLayers={(
342359
<ActiveCountryBaseMapLayer

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/LocalUnitTableActions/index.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function LocalUnitsTableActions(props: Props) {
3838
const alert = useAlert();
3939

4040
const hasValidatePermission = isSuperUser || isCountryAdmin(countryId);
41+
4142
const {
4243
pending: validateLocalUnitPending,
4344
trigger: validateLocalUnit,
@@ -82,24 +83,26 @@ function LocalUnitsTableActions(props: Props) {
8283
>
8384
{strings.localUnitsView}
8485
</DropdownMenuItem>
85-
{!(isValidated) && hasValidatePermission && (
86-
<DropdownMenuItem
87-
persist
88-
name={undefined}
89-
type="confirm-button"
90-
variant="tertiary"
91-
className={styles.button}
92-
confirmHeading={strings.validateLocalUnitHeading}
93-
confirmMessage={resolveToString(
94-
strings.validateLocalUnitMessage,
95-
{ localUnitName: localUnitName ?? '' },
96-
)}
97-
onConfirm={handleLocalUnitValidate}
98-
disabled={validateLocalUnitPending}
99-
>
100-
{strings.localUnitsValidate}
101-
</DropdownMenuItem>
102-
)}
86+
<DropdownMenuItem
87+
persist
88+
name={undefined}
89+
type="confirm-button"
90+
variant="tertiary"
91+
className={styles.button}
92+
confirmHeading={strings.validateLocalUnitHeading}
93+
confirmMessage={resolveToString(
94+
strings.validateLocalUnitMessage,
95+
{ localUnitName: localUnitName ?? '' },
96+
)}
97+
onConfirm={handleLocalUnitValidate}
98+
disabled={
99+
validateLocalUnitPending
100+
|| !hasValidatePermission
101+
|| isValidated
102+
}
103+
>
104+
{strings.localUnitsValidate}
105+
</DropdownMenuItem>
103106
</>
104107
)}
105108
/>

app/src/views/CountryNsOverviewContextAndStructure/NationalSocietyLocalUnits/LocalUnitsTable/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function LocalUnitsTable() {
122122
'',
123123
LocalUnitsTableActions,
124124
(_, item) => ({
125-
countryId: item.id,
125+
countryId: item.country,
126126
localUnitId: item.id,
127127
isValidated: item.validated,
128128
localUnitName: item.local_branch_name ?? item.english_branch_name,

0 commit comments

Comments
 (0)