Skip to content

Commit

Permalink
Merge pull request #313 from e-picsa/feat/seasonal-calendar-options
Browse files Browse the repository at this point in the history
feat(seasonal-calendar): crop activities and images
  • Loading branch information
chrismclarke authored Aug 1, 2024
2 parents 4c99aed + 849549c commit eddfa97
Show file tree
Hide file tree
Showing 19 changed files with 400 additions and 45 deletions.
2 changes: 1 addition & 1 deletion apps/picsa-apps/extension-app/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"output": "assets/svgs/weather"
},
{
"glob": "*.svg",
"glob": "*",
"input": "libs/data/crop_activity/svgs",
"output": "assets/svgs/crop_activity"
},
Expand Down
77 changes: 34 additions & 43 deletions libs/data/crop_activity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,46 @@ const CROP_ACTIVITY_BASE = {
sowing: { label: translateMarker('Sowing') },
watering: { label: translateMarker('Watering') },
weeding: { label: translateMarker('Weeding') },
// updates
bagging: { label: translateMarker('bagging'), pngIcon: true },
banding: { label: translateMarker('banding') },
compost_manure_making: { label: translateMarker('compost manure making'), pngIcon: true },
harvesting: { label: translateMarker('harvesting') },
land_clearing: { label: translateMarker('land clearing') },
marketing_and_selling: { label: translateMarker('marketing and selling') },
mulching: { label: translateMarker('mulching'), pngIcon: true },
pesticide_apply: { label: translateMarker('apply pesticide') },
ploughing: { label: translateMarker('ploughing') },
post_harvest_handling: { label: translateMarker('post-harvest handling') },
shelling: { label: translateMarker('shelling'), pngIcon: true },
storage: { label: translateMarker('storage') },
threshing: { label: translateMarker('threshing'), pngIcon: true },
transport: { label: translateMarker('transport') },
value_addition: { label: translateMarker('value addition') },
// TODO - should ideally migrate budget and include mapped options
} as const;

// Extract list of available weather names
type CropActivityName = keyof typeof CROP_ACTIVITY_BASE;
export type ICropActivityDataEntry = typeof CROP_ACTIVITY_DATA[0];

// TODO - migrate budget tool to use
export const CROP_ACTIVITY_DATA = Object.entries(CROP_ACTIVITY_BASE).map(([id, { label }]) => {
const data: IPicsaDataWithIcons = {
assetIconPath: `assets/svgs/crop_activity/${id}.svg`,
svgIcon: id,
};
return {
id: id as CropActivityName,
label: label as string,
...data,
};
});
export const CROP_ACTIVITY_DATA = Object.entries(CROP_ACTIVITY_BASE)
.map(([id, entry]) => {
const assetIconPath = `assets/svgs/crop_activity/${id}.svg`;
const data: IPicsaDataWithIcons = { assetIconPath, svgIcon: id };
// HACK - include png icons while pending new svgs
if (entry['pngIcon']) {
data.assetIconPath = `assets/svgs/crop_activity/${id}.png`;
data.svgIcon = '';
}
return {
id: id as CropActivityName,
label: entry.label as string,
...data,
};
})
.sort((a, b) => (a.label.toLowerCase() > b.label.toLowerCase() ? 1 : -1));

console.log({ CROP_ACTIVITY_DATA });
export const CROP_ACTIVITY_HASHMAP = arrayToHashmap(CROP_ACTIVITY_DATA, 'id');

// TODO - should ideally migrate budget and include mapped options
/**
[ 'build-housing',
'dipping',
'feeding-livestock',
'provide-supplements',
'provide-water',
'relocation',
'transport-livestock',
'vaccinate',
'apply-fertiliser',
'apply-pesticide',
'bagging',
'banding',
'compost-manure-making',
'harvesting',
'land-clearing',
'mulching',
'ploughing',
'post-harvest-handling',
'shelling',
'sowing',
'storage',
'threshing',
'transport',
'watering',
'weeding',
'marketing-and-selling',
'value-addition',
'purchase' ]
*/
Binary file added libs/data/crop_activity/svgs/bagging.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 90 additions & 0 deletions libs/data/crop_activity/svgs/banding.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions libs/data/crop_activity/svgs/harvesting.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions libs/data/crop_activity/svgs/land_clearing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions libs/data/crop_activity/svgs/marketing_and_selling.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added libs/data/crop_activity/svgs/mulching.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions libs/data/crop_activity/svgs/pesticide_apply.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit eddfa97

Please sign in to comment.