-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
diff --git a/node_modules/@turf/bbox/package.json b/node_modules/@turf/bbox/package.json | ||
index 667487d..609ad20 100644 | ||
--- a/node_modules/@turf/bbox/package.json | ||
+++ b/node_modules/@turf/bbox/package.json | ||
@@ -29,11 +29,11 @@ | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
+ "types": "./dist/js/index.d.ts", | ||
"import": "./dist/es/index.js", | ||
"require": "./dist/js/index.js" | ||
} | ||
}, | ||
- "types": "dist/js/index.d.ts", | ||
"sideEffects": false, | ||
"files": [ | ||
"dist" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
diff --git a/node_modules/@turf/buffer/package.json b/node_modules/@turf/buffer/package.json | ||
index f350d3e..8fe4032 100644 | ||
--- a/node_modules/@turf/buffer/package.json | ||
+++ b/node_modules/@turf/buffer/package.json | ||
@@ -35,11 +35,11 @@ | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
+ "types": "./index.d.ts", | ||
"import": "./dist/es/index.js", | ||
"require": "./dist/js/index.js" | ||
} | ||
}, | ||
- "types": "index.d.ts", | ||
"sideEffects": false, | ||
"files": [ | ||
"dist", |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { | ||
useEffect, | ||
useRef, | ||
} from 'react'; | ||
|
||
type ValueOrSetterFn<T> = T | ((value: T) => T); | ||
function isSetterFn<T>(value: ValueOrSetterFn<T>): value is ((value: T) => T) { | ||
return typeof value === 'function'; | ||
} | ||
|
||
function useInputState<T>( | ||
initialValue: T, | ||
sideEffect?: (newValue: T, oldValue: T) => T, | ||
) { | ||
const [value, setValue] = React.useState<T>(initialValue); | ||
const sideEffectRef = useRef(sideEffect); | ||
|
||
useEffect( | ||
() => { | ||
sideEffectRef.current = sideEffect; | ||
}, | ||
[sideEffect], | ||
); | ||
|
||
type SetValue = React.Dispatch<React.SetStateAction<T>>; | ||
const setValueSafe: SetValue = React.useCallback((newValueOrSetter) => { | ||
setValue((oldValue) => { | ||
const newValue = isSetterFn(newValueOrSetter) | ||
? newValueOrSetter(oldValue) | ||
: newValueOrSetter; | ||
|
||
if (sideEffectRef.current) { | ||
return sideEffectRef.current(newValue, oldValue); | ||
} | ||
|
||
return newValue; | ||
}); | ||
}, []); | ||
|
||
return [value, setValueSafe] as const; | ||
} | ||
|
||
export default useInputState; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function AlertDetails() { | ||
return ( | ||
<>Alert Details</> | ||
); | ||
} | ||
|
||
export default AlertDetails; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"namespace": "countryDetails", | ||
"strings": { | ||
"countryViewDetails": "View Details" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ChevronRightLineIcon } from '@ifrc-go/icons'; | ||
import { | ||
Button, | ||
Container, | ||
} from '@ifrc-go/ui'; | ||
import { useTranslation } from '@ifrc-go/ui/hooks'; | ||
|
||
import { CountryListQuery } from '#generated/types'; | ||
Check failure on line 8 in src/views/AlertMap/CountryListItem/index.tsx GitHub Actions / Typecheck
|
||
|
||
import i18n from './i18n.json'; | ||
import styles from './styles.module.css'; | ||
|
||
type CountryType = NonNullable<NonNullable<NonNullable<CountryListQuery['public']>['countries']>['items']>[number]; | ||
|
||
export interface Props { | ||
data: CountryType; | ||
onExpandClick: (alertId: string | undefined) => void; | ||
} | ||
|
||
function CountryListItem(props: Props) { | ||
const { | ||
data, | ||
onExpandClick, | ||
} = props; | ||
|
||
const strings = useTranslation(i18n); | ||
|
||
return ( | ||
<Container | ||
className={styles.countryInfo} | ||
heading={data.name ?? '--'} | ||
headerClassName={styles.CountryListItem} | ||
headingLevel={5} | ||
key={data.name} | ||
actions={( | ||
<Button | ||
name={data.id} | ||
onClick={onExpandClick} | ||
variant="tertiary" | ||
title={strings.countryViewDetails} | ||
> | ||
<ChevronRightLineIcon className={styles.icon} /> | ||
</Button> | ||
)} | ||
/> | ||
); | ||
} | ||
|
||
export default CountryListItem; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.country-info { | ||
.country-list-item { | ||
gap: 0; | ||
|
||
.icon { | ||
align-self: flex-end; | ||
font-size: var(--go-ui-height-icon-multiplier); | ||
}:hover { | ||
.icon { | ||
animation: wiggle var(--go-ui-duration-transition-slow) ease-in-out; | ||
} | ||
} | ||
} | ||
|
||
@keyframes wiggle { | ||
0% { | ||
transform: translateX(0); | ||
} | ||
|
||
25% { | ||
transform: translateX(-0.1rem); | ||
} | ||
|
||
50% { | ||
transform: translateX(0.1rem); | ||
} | ||
|
||
100% { | ||
transform: translateX(0); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"namespace": "common", | ||
"strings": { | ||
"riskAllCountries": "All countries", | ||
"riskSelectHazardTypes": "Select Hazard types", | ||
"riskSelectMonths": "Select months", | ||
"riskNormalize": "Normalize by population", | ||
"riskCopingCapacity": "Include coping capacity" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { useCallback, useMemo } from 'react'; | ||
Check failure on line 1 in src/views/AlertMap/Filters/index.tsx GitHub Actions / Typecheck
Check warning on line 1 in src/views/AlertMap/Filters/index.tsx GitHub Actions / Lint JS
Check failure on line 1 in src/views/AlertMap/Filters/index.tsx GitHub Actions / Lint JS
|
||
import { | ||
MultiSelectInput, | ||
} from '@ifrc-go/ui'; | ||
import { gql } from '@apollo/client'; | ||
Check failure on line 5 in src/views/AlertMap/Filters/index.tsx GitHub Actions / Typecheck
|
||
import { useTranslation } from '@ifrc-go/ui/hooks'; | ||
import { | ||
stringNameSelector, | ||
} from '@ifrc-go/ui/utils'; | ||
import { listToGroupList } from '@togglecorp/fujs'; | ||
Check failure on line 10 in src/views/AlertMap/Filters/index.tsx GitHub Actions / Typecheck
|
||
import { EntriesAsList } from '@togglecorp/toggle-form'; | ||
|
||
import { CountryListQuery } from '#generated/types'; | ||
Check failure on line 13 in src/views/AlertMap/Filters/index.tsx GitHub Actions / Typecheck
|
||
|
||
import i18n from './i18n.json'; | ||
|
||
type CountryType = NonNullable<NonNullable<NonNullable<CountryListQuery['public']>['countries']>['items']>[number]; | ||
|
||
const countryKeySelector = (country: CountryType) => country?.id; | ||
|
||
export interface FilterValue { | ||
countries: string[]; | ||
regions: string[]; | ||
} | ||
|
||
interface Props { | ||
value: FilterValue; | ||
onChange: React.Dispatch<React.SetStateAction<FilterValue>>; | ||
countries?: NonNullable<CountryListQuery['public']['countries']['items']>; | ||
} | ||
|
||
function Filters(props: Props) { | ||
const { | ||
value, | ||
onChange, | ||
countries, | ||
} = props; | ||
|
||
const strings = useTranslation(i18n); | ||
|
||
const handleChange = useCallback( | ||
(...args: EntriesAsList<FilterValue>) => { | ||
const [val, key] = args; | ||
onChange((prevValue): FilterValue => ({ | ||
...prevValue, | ||
[key]: val, | ||
})); | ||
}, | ||
[onChange], | ||
); | ||
|
||
return ( | ||
<MultiSelectInput | ||
placeholder={strings.riskAllCountries} | ||
name="countries" | ||
options={countries} | ||
keySelector={countryKeySelector} | ||
labelSelector={stringNameSelector} | ||
value={value.countries} | ||
onChange={handleChange} | ||
withSelectAll | ||
/> | ||
); | ||
} | ||
|
||
export default Filters; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.filters { | ||
display: grid; | ||
grid-gap: var(--go-ui-spacing-md); | ||
grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); | ||
} |