Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit 39aecb0

Browse files
committed
Merge branch 'release/v1.0.87'
2 parents 41035e8 + 903a7c0 commit 39aecb0

9 files changed

Lines changed: 23 additions & 29 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@hisptz/react-ui",
33
"homepage": "https://hisptz.github.io/react-ui",
4-
"version": "1.0.86",
4+
"version": "1.0.87",
55
"description": "A collection of reusable complex DHIS2 react ui components.",
66
"license": "BSD-3-Clause",
77
"scripts": {

src/components/DataConfigurationArea/components/CustomAccordion/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ export default function CustomAccordion({
4141
const [expand, setExpanded] = useState(defaultExpanded);
4242
const [placeholderStyle, setPlaceholderStyle] = useState<any>({});
4343

44-
console.log(placeholderStyle);
45-
4644
const onExpand = useCallback(() => {
4745
setExpanded((prevState) => !prevState);
4846
}, []);

src/components/Map/components/MapLayer/components/GoogleEngineLayer/components/EarthEngineLegend.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ function getLegendsFromParams(params?: { min: number; max: number; palette: stri
1818
if (!params) return [];
1919

2020
const { palette, min, max } = params;
21-
console.log(params);
2221
const sanitizedPalette = Array.isArray(palette) ? palette : palette.split(",");
2322
const classes = sanitizedPalette.length;
2423
const difference = max - min;
2524
const interval = Math.round(difference / classes);
2625
const legends = [];
27-
console.log(10 / 9);
2826
for (let i = 0; i < classes; i++) {
2927
const min = i * interval;
3028
const max = min + interval;

src/components/Map/components/MapLayer/components/LegendArea/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ function Legend({ children, collapsible }: { children: React.ReactElement; colla
124124
const name = head(React.Children.toArray(children) as React.ReactElement[])?.props.name;
125125

126126
const shouldCollapse = collapsed && !inPrintMode;
127-
console.log(inPrintMode);
128127

129128
return (
130129
<div className="w-100">

src/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ export function useThematicLayers(): any {
143143
classesCount: scale,
144144
colorClass,
145145
});
146-
console.log({
147-
scale,
148-
colorClass,
149-
sortedData,
150-
});
151146
legends.push(...autoLegends);
152147
}
153148
return {

src/components/Map/components/MapProvider/components/MapLayerProvider/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ export function MapLayersProvider({ layers, children }: { layers: MapLayerConfig
4444
const sanitizedPointLayer = head(pointLayers ?? []) ? await sanitizePointLayer(head(pointLayers) as CustomPointLayer) : undefined;
4545
const sanitizedEarthEngineLayers = await sanitizeEarthEngineLayers([...(earthEngineLayers ?? [])] as unknown as CustomGoogleEngineLayer[]);
4646

47-
console.log(sanitizedThematicLayers);
48-
4947
setUpdatedLayers(
5048
compact([...(sanitizedBoundaryLayers ?? []), ...(sanitizedThematicLayers ?? []), sanitizedPointLayer, ...(sanitizedEarthEngineLayers ?? [])])
5149
);

src/components/OrgUnitSelector/components/OrgUnitTree/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ function Tree({
3737
const { searchMode, searchValue, expanded, filtering, filteredOrgUnits, handleExpand } = useFilterOrgUnits();
3838
const selectedOrgUnits = value?.orgUnits ?? [];
3939

40-
console.log(expanded);
41-
4240
const onSelect = (orgUnit: any) => {
4341
const orgUnitLevel = orgUnit.level ?? orgUnit.path.split("/").length - 1;
4442
const allowSelection = limitSelectionToLevels?.includes(orgUnitLevel) ?? true;

src/components/PeriodSelector/PeriodSelector.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ SelectedPeriods.args = {
9292
enableDateRange: true,
9393
selectedPeriods: [
9494
{
95-
id: "2022",
96-
name: "2022",
95+
id: "202209",
96+
name: "September 2022",
9797
},
9898
],
9999
excludedPeriodTypes: [],
@@ -108,8 +108,8 @@ WithAllowedFuturePeriods.args = {
108108
enableDateRange: true,
109109
selectedPeriods: [
110110
{
111-
id: "2022",
112-
name: "2022",
111+
id: "202209",
112+
name: "September 2022",
113113
},
114114
],
115115
allowFuturePeriods: false,

src/components/PeriodSelector/components/CalendarSpecificPeriodDimension/index.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,21 @@ export default function CalendarSpecificPeriodSelector({
3232
singleSelection,
3333
allowFuturePeriods,
3434
}: CalendarSpecificPeriodSelectorProps) {
35-
const periodInstance = new Period().setCalendar(CalendarTypes.ETHIOPIAN);
35+
const periodInstance = new Period().setCalendar(CalendarTypes.ETHIOPIAN).setPreferences({ allowFuturePeriods: true });
36+
const selectedPeriod = !isEmpty(selectedPeriods) ? periodInstance.getById(head(selectedPeriods)?.id as unknown as string) : undefined;
37+
const defaultPeriodType = selectedPeriod?.type;
3638

37-
const [year, setYear] = useState<number>(new Date().getFullYear());
39+
const defaultPeriodTypeIsFixed = typeof selectedPeriod?.id === "string" && /\d{4}/.test(selectedPeriod?.id);
40+
41+
const [year, setYear] = useState<number>(
42+
defaultPeriodTypeIsFixed ? new Date(selectedPeriod?.startDate as unknown as string).getFullYear() ?? new Date().getFullYear() : new Date().getFullYear()
43+
);
3844

3945
useEffect(() => {
4046
periodInstance.setPreferences({ openFuturePeriods: 4, allowFuturePeriods: true });
4147
periodInstance.setCalendar(calendar);
4248
if (calendar === CalendarTypes.ETHIOPIAN) {
4349
setYear(new Date().getFullYear() - 7);
44-
} else {
45-
setYear(new Date().getFullYear());
4650
}
4751
}, [calendar]);
4852
const periodType = new PeriodType();
@@ -54,8 +58,12 @@ export default function CalendarSpecificPeriodSelector({
5458
const relativePeriodTypes = filter(filteredPeriodTypes, ({ id }) => id.toLowerCase().match(RegExp("relative".toLowerCase())));
5559
const fixedPeriodTypes = filter(filteredPeriodTypes, ({ id }) => !id.toLowerCase().match(RegExp("relative".toLowerCase())));
5660

57-
const [selectedRelativePeriodType, setSelectedRelativePeriodType] = useState(head(relativePeriodTypes)?.id);
58-
const [selectedFixedPeriodType, setSelectedFixedPeriodType] = useState(head(fixedPeriodTypes)?.id);
61+
const [selectedRelativePeriodType, setSelectedRelativePeriodType] = useState(
62+
defaultPeriodTypeIsFixed ? head(relativePeriodTypes)?.id : defaultPeriodType ?? head(relativePeriodTypes)?.id
63+
);
64+
const [selectedFixedPeriodType, setSelectedFixedPeriodType] = useState(
65+
defaultPeriodTypeIsFixed ? defaultPeriodType ?? head(fixedPeriodTypes)?.id : head(fixedPeriodTypes)?.id
66+
);
5967

6068
const tabs = useMemo(() => {
6169
const tabs = [];
@@ -69,7 +77,9 @@ export default function CalendarSpecificPeriodSelector({
6977
return tabs;
7078
}, []);
7179

72-
const [selectedPeriodCategory, setSelectedPeriodCategory] = useState(head(tabs));
80+
const defaultTab = find(Object.values(PeriodCategories), ["key", defaultPeriodTypeIsFixed ? "fixed" : "relative"]);
81+
82+
const [selectedPeriodCategory, setSelectedPeriodCategory] = useState(defaultTab);
7383

7484
useEffect(() => {
7585
if (excludeFixedPeriods && excludeRelativePeriods) {
@@ -100,8 +110,6 @@ export default function CalendarSpecificPeriodSelector({
100110
.get()
101111
.list();
102112

103-
console.log(periods);
104-
105113
if (allowFuturePeriods) {
106114
return periods;
107115
} else {
@@ -171,7 +179,7 @@ export default function CalendarSpecificPeriodSelector({
171179
dense
172180
label={i18n.t("Year")}
173181
type={"number"}
174-
value={year}
182+
value={year.toString()}
175183
onChange={({ value }: { value: number }) => setYear(value)}
176184
/>
177185
</div>

0 commit comments

Comments
 (0)