Skip to content

Commit

Permalink
Merge pull request #3116 from LiteFarmOrg/LF-4088-add-new-animals-rou…
Browse files Browse the repository at this point in the history
…te-and-navigation-items

Lf 4088 add new animals route and navigation items
  • Loading branch information
antsgar authored Feb 8, 2024
2 parents 3dd82a9 + 8bc33d8 commit d27f7d4
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/webapp/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,10 @@
},
"MENU": {
"ACTUAL_REVENUES": "Actual revenues",
"ANIMALS": "Animals",
"ANIMALS_GROUPS": "Groups",
"ANIMALS_INVENTORY": "Inventory",
"ANIMALS_LOCATION": "Locations",
"CERTIFICATIONS": "Certifications",
"CROPS": "Crops",
"DOCUMENTS": "Documents",
Expand Down
4 changes: 4 additions & 0 deletions packages/webapp/public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,10 @@
},
"MENU": {
"ACTUAL_REVENUES": "Ingresos reales",
"ANIMALS": "MISSING",
"ANIMALS_GROUPS": "MISSING",
"ANIMALS_INVENTORY": "MISSING",
"ANIMALS_LOCATION": "MISSING",
"CERTIFICATIONS": "Certificaciones",
"CROPS": "Cultivos",
"DOCUMENTS": "Documentos",
Expand Down
6 changes: 5 additions & 1 deletion packages/webapp/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@
},
"REPORT": {
"DATES": "Dates",
"FILE_TITLE": "MISSING",
"FILE_TITLE": "Rapport financier",
"SETTINGS": "Exporter les paramètres",
"TRANSACTION": "Transaction",
"TRANSACTIONS": "Transactions"
Expand Down Expand Up @@ -1213,6 +1213,10 @@
},
"MENU": {
"ACTUAL_REVENUES": "Chiffres d'affaires réels",
"ANIMALS": "Animaux",
"ANIMALS_GROUPS": "Groupes",
"ANIMALS_INVENTORY": "Inventaire",
"ANIMALS_LOCATION": "Emplacements",
"CERTIFICATIONS": "Certifications",
"CROPS": "Cultures",
"DOCUMENTS": "Documents",
Expand Down
4 changes: 4 additions & 0 deletions packages/webapp/public/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,10 @@
},
"MENU": {
"ACTUAL_REVENUES": "Receitas atuais",
"ANIMALS": "MISSING",
"ANIMALS_GROUPS": "MISSING",
"ANIMALS_INVENTORY": "MISSING",
"ANIMALS_LOCATION": "MISSING",
"CERTIFICATIONS": "Certificações",
"CROPS": "Cultivos",
"DOCUMENTS": "Documentos",
Expand Down
10 changes: 10 additions & 0 deletions packages/webapp/src/assets/images/nav/animals.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions packages/webapp/src/containers/Animals/Groups/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2024 LiteFarm.org
* This file is part of LiteFarm.
*
* LiteFarm is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiteFarm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>.
*/

function AnimalGroups() {
return null;
}

export default AnimalGroups;
20 changes: 20 additions & 0 deletions packages/webapp/src/containers/Animals/Inventory/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2024 LiteFarm.org
* This file is part of LiteFarm.
*
* LiteFarm is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiteFarm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>.
*/

function AnimalInventory() {
return null;
}

export default AnimalInventory;
20 changes: 20 additions & 0 deletions packages/webapp/src/containers/Animals/Location/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2024 LiteFarm.org
* This file is part of LiteFarm.
*
* LiteFarm is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiteFarm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>.
*/

function AnimalLocation() {
return null;
}

export default AnimalLocation;
28 changes: 28 additions & 0 deletions packages/webapp/src/hooks/useGetMenuItems.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { ReactComponent as MapIcon } from '../assets/images/nav/map.svg';
import { ReactComponent as TasksIcon } from '../assets/images/nav/tasks.svg';
import { ReactComponent as CropsIcon } from '../assets/images/nav/crops.svg';
import { ReactComponent as AnimalsIcon } from '../assets/images/nav/animals.svg';
import { ReactComponent as FinancesIcon } from '../assets/images/nav/finances.svg';
import { ReactComponent as InsightsIcon } from '../assets/images/nav/insights.svg';
import { ReactComponent as DocumentsIcon } from '../assets/images/nav/documents.svg';
Expand All @@ -29,6 +30,10 @@ import { isAdminSelector } from '../containers/userFarmSlice';
import styles from '../components/Navigation/SideMenu/styles.module.scss';
import {
ACTUAL_REVENUE_URL,
ANIMALS_GROUPS_URL,
ANIMALS_INVENTORY_URL,
ANIMALS_LOCATION_URL,
ANIMALS_URL,
ESTIMATED_REVENUE_URL,
FINANCES_HOME_URL,
FINANCES_URL,
Expand All @@ -50,6 +55,29 @@ export const useGetMenuItems = () => {
path: '/crop_catalogue',
key: 'crops',
},
{
label: t('MENU.ANIMALS'),
icon: <AnimalsIcon />,
path: ANIMALS_URL,
key: 'animals',
subMenu: [
{
label: t('MENU.ANIMALS_INVENTORY'),
path: ANIMALS_INVENTORY_URL,
key: 'animals_inventory',
},
{
label: t('MENU.ANIMALS_LOCATION'),
path: ANIMALS_LOCATION_URL,
key: 'animals_location',
},
{
label: t('MENU.ANIMALS_GROUPS'),
path: ANIMALS_GROUPS_URL,
key: 'animals_groups',
},
],
},
{ label: t('MENU.INSIGHTS'), icon: <InsightsIcon />, path: '/Insights', key: 'insights' },
];

Expand Down
35 changes: 35 additions & 0 deletions packages/webapp/src/routes/AnimalsRoutes.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2023 LiteFarm.org
* This file is part of LiteFarm.
*
* LiteFarm is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LiteFarm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details, see <https://www.gnu.org/licenses/>.
*/

import React from 'react';
import { Route, Switch } from 'react-router-dom';
import {
ANIMALS_INVENTORY_URL,
ANIMALS_LOCATION_URL,
ANIMALS_GROUPS_URL,
} from '../util/siteMapConstants';
const Inventory = React.lazy(() => import('../containers/Animals/Inventory'));
const Location = React.lazy(() => import('../containers/Animals/Location'));
const Groups = React.lazy(() => import('../containers/Animals/Groups'));

const AnimalsRoutes = () => (
<Switch>
<Route path={ANIMALS_INVENTORY_URL} exact component={Inventory} />
<Route path={ANIMALS_LOCATION_URL} exact component={Location} />
<Route path={ANIMALS_GROUPS_URL} exact component={Groups} />
</Switch>
);

export default AnimalsRoutes;
4 changes: 4 additions & 0 deletions packages/webapp/src/routes/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const People = React.lazy(() => import('../containers/Profile/People/People'));
const EditUser = React.lazy(() => import('../containers/Profile/EditUser'));
const ConsentForm = React.lazy(() => import('../containers/Consent'));
const Finances = React.lazy(() => import('./FinancesRoutes'));
const Animals = React.lazy(() => import('./AnimalsRoutes'));
const ChooseFarm = React.lazy(() => import('../containers/ChooseFarm'));
const PasswordResetAccount = React.lazy(() => import('../containers/PasswordResetAccount'));
const InviteSignUp = React.lazy(() => import('../containers/InviteSignUp'));
Expand Down Expand Up @@ -609,6 +610,7 @@ const Routes = ({ isCompactSideMenu }) => {
component={NotificationReadOnly}
/>
<Route path="/finances/*" exact component={Finances} />
<Route path="/animals/*" exact component={Animals} />
<Route path="/unknown_record" exact component={UnknownRecord} />
<Redirect
to={'/'}
Expand Down Expand Up @@ -898,6 +900,7 @@ const Routes = ({ isCompactSideMenu }) => {
component={NotificationReadOnly}
/>
<Route path="/finances" component={Finances} />
<Route path="/animals/*" exact component={Animals} />
<Route path="/unknown_record" exact component={UnknownRecord} />
<Redirect to={'/'} />
</Switch>
Expand Down Expand Up @@ -996,6 +999,7 @@ const Routes = ({ isCompactSideMenu }) => {
exact
component={NotificationReadOnly}
/>
<Route path="/animals/*" exact component={Animals} />
<Route path="/unknown_record" exact component={UnknownRecord} />
<Redirect to={'/'} />
</Switch>
Expand Down
7 changes: 7 additions & 0 deletions packages/webapp/src/util/siteMapConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
// Type of string has the dual purpose of being used in routes parameter pathing
// as well as accomodating UUID types.

// Animals

export const ANIMALS_URL = '/animals';
export const ANIMALS_INVENTORY_URL = '/animals/inventory';
export const ANIMALS_LOCATION_URL = '/animals/location';
export const ANIMALS_GROUPS_URL = '/animals/groups';

// Finances

export const FINANCES_URL = '/finances';
Expand Down

0 comments on commit d27f7d4

Please sign in to comment.