Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lf 4156 create animal batch creation form card #3201

Merged
merged 34 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
395f88e
LF-4156 create new card component
navDhammu Apr 23, 2024
6962ac2
LF-4156 change storybook config to detect story files anywhere inside…
navDhammu Apr 23, 2024
447994e
LF-4156 create component and stories for AddAnimalsFormCard
navDhammu Apr 23, 2024
08d3fc8
LF-4156 fix ts error by updating NumberInput controller props
navDhammu Apr 24, 2024
d06e17a
LF-4156 create separate components for type and breed select
navDhammu Apr 24, 2024
67671e6
LF-4156 fix prop spreading overriding styles prop in react select
navDhammu Apr 24, 2024
a1f951e
LF-4156 create custom menu component for breed select
navDhammu Apr 25, 2024
9adb013
LF-4156 add mock options for type and breed
navDhammu Apr 25, 2024
fa91258
LF-4156 replace useForm with useFormContext
navDhammu Apr 26, 2024
af0c2f6
LF-4156 remove if condition from react select change handler
navDhammu Apr 30, 2024
7549d0d
LF-4156 add className prop to NumberInput and InputBase; adjust width…
navDhammu Apr 30, 2024
d1703ac
LF-4156 remove width:100% from InputBase wrapper
navDhammu Apr 30, 2024
9349371
LF-4156 use max count as useMemo dependancy to re-render sex details …
navDhammu Apr 30, 2024
9c5da14
LF-4156 register checkbox for creating individual profiles; update ho…
navDhammu Apr 30, 2024
6b5f78c
LF-4156 register group name
navDhammu Apr 30, 2024
5f946ca
LF-4156 add click handler to remove button
navDhammu Apr 30, 2024
52c9d9a
LF-4156 add translations
navDhammu Apr 30, 2024
d81487e
LF-4156 conditionally render batch or group name input
navDhammu Apr 30, 2024
c21b524
LF-4156 create stories for cardv2
navDhammu May 2, 2024
a8ba4a8
LF-4156 use Main typography component for card heading
navDhammu May 2, 2024
23da542
LF-4156 change breed select to be disabled if type is not selected
navDhammu May 2, 2024
4158705
LF-4156 fix sex details input not taking full width on mobile
navDhammu May 3, 2024
357cf4f
LF-4156 show search icon in searchable react select
navDhammu May 3, 2024
76d9e7f
Merge branch integration into LF-4156-create-animal-batch-creation-fo…
navDhammu May 3, 2024
fd0817a
LF-4156 remove unused translation and run i18n script
navDhammu May 3, 2024
2fa5c53
LF-4156 remove empty string in jsx
navDhammu May 8, 2024
5915dfa
LF-4156 use constants for form field names
navDhammu May 8, 2024
2e57a34
LF-4156 add license
navDhammu May 8, 2024
91e51c7
LF-4156 add hover state and adjust padding on remove button
navDhammu May 8, 2024
39d9b1f
LF-4156 add border radius on card
navDhammu May 8, 2024
1593538
LF-4156 replace names with constants
navDhammu May 10, 2024
a9883ba
LF-4156 move stories to stories folder
navDhammu May 17, 2024
0212fa0
Revert "LF-4156 change storybook config to detect story files anywher…
navDhammu May 17, 2024
8de2691
LF-4156 fix import
navDhammu May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions packages/webapp/.storybook/main.cjs
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
module.exports = {
SayakaOno marked this conversation as resolved.
Show resolved Hide resolved
stories: ['../src/stories/**/*.stories.mdx', '../src/stories/**/*.stories.@(js|jsx|ts|tsx)'],
"addons": ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/addon-interactions", '@storybook/addon-a11y'],
"framework": {
name: "@storybook/react-vite",
options: {}
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-a11y',
],
framework: {
name: '@storybook/react-vite',
options: {},
},
"features": {
"storyStoreV7": true
features: {
storyStoreV7: true,
},
async viteFinal(config) {
return {
...config,
plugins: [...config.plugins.filter(plugin => !['@mdx-js/rollup'].includes(plugin.name))],
plugins: [...config.plugins.filter((plugin) => !['@mdx-js/rollup'].includes(plugin.name))],
optimizeDeps: {
...config.optimizeDeps,
include: [...(config.optimizeDeps?.include ?? []), '@storybook/addon-docs/blocks']
}
include: [...(config.optimizeDeps?.include ?? []), '@storybook/addon-docs/blocks'],
},
};
},
docs: {
autodocs: true
}
};
autodocs: true,
},
};
2 changes: 2 additions & 0 deletions packages/webapp/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"CLOSE": "Close",
"CONFIRM": "Confirm",
"CONTINUE": "Continue",
"COUNT": "Count",
"CREATE": "Create",
"CREATE_A_TASK": "Create a task",
"DATE": "Date",
Expand Down Expand Up @@ -54,6 +55,7 @@
"PLANNED": "Planned",
"PROCEED": "Proceed",
"QUANTITY": "Quantity",
"REMOVE": "Remove",
"REMOVE_ITEM": "Remove item",
"REQUIRED": "Required",
"RETIRE": "Retire",
Expand Down
14 changes: 13 additions & 1 deletion packages/webapp/public/locales/en/translation.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
{
"ADD_ANIMAL": {
"ADD_TO_INVENTORY": "Add animal to your inventory",
"ANIMALS_TOTAL_one": "{{count}} animal total",
"ANIMALS_TOTAL_other": "{{count}} animals total",
"ANIMALS_UNSPECIFIED_one": "{{count}} unspecified",
"ANIMALS_UNSPECIFIED_other": "{{count}} unspecified",
"BATCH_NAME": "Batch name",
"BATCH_NAME_PLACEHOLDER": "Type in batch name",
"BREED": "Breed",
"BREED_PLACEHOLDER": "Add your animal breed",
"CREATE_INDIVIDUAL_PROFILES": "Create individual animal profiles",
"CREATE_INDIVIDUAL_PROFILES_TOOLTIP": "Select this option if you want to track and manage each animal separately. This allows for detailed records and individualised care plans, all animals will be conveniently grouped. If you don't select 'Create Individual Animal Profiles' you'll create an Animal Batch. This is ideal for\u00a0managing animals collectively. In batch mode, individual animal details are not tracked.",
"GROUP_NAME": "Group name",
"GROUP_NAME_PLACEHOLDER": "Type in group name",
"NO_TYPE_SELECTED_MESSAGE": "Please select a type first",
"SELECT_SEXES": "Select sexes",
"SEX_DETAIL": "Sex detail",
"SEX_DETAIL_ERROR_one": "Maximum animal count: {{count}}",
Expand All @@ -20,7 +30,9 @@
"BATCH_SUMMARY_COUNT_other": "{{count}} batches",
"HERE_IS_SUMMARY": "Here is a summary of your added animals:",
"MAIN": "You successfully added {{animalCount}} {{and}} {{batchCount}} to your inventory."
}
},
"TYPE": "Type",
"TYPE_PLACEHOLDER": "Select the animal type"
},
"ADD_FARM": {
"ADDRESS_IS_REQUIRED": "Address is required",
Expand Down
2 changes: 2 additions & 0 deletions packages/webapp/public/locales/es/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"CLOSE": "Cerrar",
"CONFIRM": "Confirmar",
"CONTINUE": "Continuar",
"COUNT": "MISSING",
"CREATE": "Agregar",
"CREATE_A_TASK": "MISSING",
"DATE": "Fecha",
Expand Down Expand Up @@ -54,6 +55,7 @@
"PLANNED": "Planificado",
"PROCEED": "Proceder",
"QUANTITY": "Cantidad",
"REMOVE": "MISSING",
"REMOVE_ITEM": "Eliminar item",
"REQUIRED": "Requerido",
"RETIRE": "Retirar",
Expand Down
14 changes: 13 additions & 1 deletion packages/webapp/public/locales/es/translation.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"ADD_ANIMAL": {
"ADD_TO_INVENTORY": "MISSING",
"ANIMALS_TOTAL_one": "MISSING",
"ANIMALS_TOTAL_many": "MISSING",
"ANIMALS_TOTAL_other": "MISSING",
"ANIMALS_UNSPECIFIED_one": "MISSING",
"ANIMALS_UNSPECIFIED_many": "MISSING",
"ANIMALS_UNSPECIFIED_other": "MISSING",
"BATCH_NAME": "MISSING",
"BATCH_NAME_PLACEHOLDER": "MISSING",
"BREED": "MISSING",
"BREED_PLACEHOLDER": "MISSING",
"CREATE_INDIVIDUAL_PROFILES": "MISSING",
"CREATE_INDIVIDUAL_PROFILES_TOOLTIP": "MISSING",
"GROUP_NAME": "MISSING",
"GROUP_NAME_PLACEHOLDER": "MISSING",
"NO_TYPE_SELECTED_MESSAGE": "MISSING",
"SELECT_SEXES": "MISSING",
"SEX_DETAIL": "MISSING",
"SEX_DETAIL_ERROR_one": "MISSING",
Expand All @@ -20,7 +30,9 @@
"ALL_DONE": "MISSING",
"HERE_IS_SUMMARY": "MISSING",
"MAIN": "MISSING"
}
},
"TYPE": "MISSING",
"TYPE_PLACEHOLDER": "MISSING"
},
"ADD_FARM": {
"ADDRESS_IS_REQUIRED": "MISSING",
Expand Down
2 changes: 2 additions & 0 deletions packages/webapp/public/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"CLOSE": "Fermer",
"CONFIRM": "Valider",
"CONTINUE": "Continuer",
"COUNT": "MISSING",
"CREATE": "Créer",
"CREATE_A_TASK": "MISSING",
"DATE": "Date",
Expand Down Expand Up @@ -54,6 +55,7 @@
"PLANNED": "Planifié",
"PROCEED": "Continuer",
"QUANTITY": "Quantité",
"REMOVE": "MISSING",
"REMOVE_ITEM": "Supprimer l'item",
"REQUIRED": "Réponse requise",
"RETIRE": "Abandonner",
Expand Down
14 changes: 13 additions & 1 deletion packages/webapp/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"ADD_ANIMAL": {
"ADD_TO_INVENTORY": "MISSING",
"ANIMALS_TOTAL_one": "MISSING",
"ANIMALS_TOTAL_many": "MISSING",
"ANIMALS_TOTAL_other": "MISSING",
"ANIMALS_UNSPECIFIED_one": "MISSING",
"ANIMALS_UNSPECIFIED_many": "MISSING",
"ANIMALS_UNSPECIFIED_other": "MISSING",
"BATCH_NAME": "MISSING",
"BATCH_NAME_PLACEHOLDER": "MISSING",
"BREED": "MISSING",
"BREED_PLACEHOLDER": "MISSING",
"CREATE_INDIVIDUAL_PROFILES": "MISSING",
"CREATE_INDIVIDUAL_PROFILES_TOOLTIP": "MISSING",
"GROUP_NAME": "MISSING",
"GROUP_NAME_PLACEHOLDER": "MISSING",
"NO_TYPE_SELECTED_MESSAGE": "MISSING",
"SELECT_SEXES": "MISSING",
"SEX_DETAIL": "MISSING",
"SEX_DETAIL_ERROR_one": "MISSING",
Expand All @@ -24,7 +34,9 @@
"BATCH_SUMMARY_COUNT_other": "MISSING",
"HERE_IS_SUMMARY": "MISSING",
"MAIN": "MISSING"
}
},
"TYPE": "MISSING",
"TYPE_PLACEHOLDER": "MISSING"
},
"ADD_FARM": {
"ADDRESS_IS_REQUIRED": "Une adresse est requise",
Expand Down
2 changes: 2 additions & 0 deletions packages/webapp/public/locales/pt/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"CLOSE": "Fechar",
"CONFIRM": "Confirmar",
"CONTINUE": "Continuar",
"COUNT": "MISSING",
"CREATE": "Adicionar",
"CREATE_A_TASK": "MISSING",
"DATE": "Data",
Expand Down Expand Up @@ -54,6 +55,7 @@
"PLANNED": "Planejado",
"PROCEED": "Continuar",
"QUANTITY": "Quantidade",
"REMOVE": "MISSING",
"REMOVE_ITEM": "Remover item",
"REQUIRED": "Obrigatório",
"RETIRE": "Remover",
Expand Down
14 changes: 13 additions & 1 deletion packages/webapp/public/locales/pt/translation.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
{
"ADD_ANIMAL": {
"ADD_TO_INVENTORY": "MISSING",
"ANIMALS_TOTAL_one": "MISSING",
"ANIMALS_TOTAL_many": "MISSING",
"ANIMALS_TOTAL_other": "MISSING",
"ANIMALS_UNSPECIFIED_one": "MISSING",
"ANIMALS_UNSPECIFIED_many": "MISSING",
"ANIMALS_UNSPECIFIED_other": "MISSING",
"BATCH_NAME": "MISSING",
"BATCH_NAME_PLACEHOLDER": "MISSING",
"BREED": "MISSING",
"BREED_PLACEHOLDER": "MISSING",
"CREATE_INDIVIDUAL_PROFILES": "MISSING",
"CREATE_INDIVIDUAL_PROFILES_TOOLTIP": "MISSING",
"GROUP_NAME": "MISSING",
"GROUP_NAME_PLACEHOLDER": "MISSING",
"NO_TYPE_SELECTED_MESSAGE": "MISSING",
"SELECT_SEXES": "MISSING",
"SEX_DETAIL": "MISSING",
"SEX_DETAIL_ERROR_one": "MISSING",
Expand All @@ -24,7 +34,9 @@
"BATCH_SUMMARY_COUNT_other": "MISSING",
"HERE_IS_SUMMARY": "MISSING",
"MAIN": "MISSING"
}
},
"TYPE": "MISSING",
"TYPE_PLACEHOLDER": "MISSING"
},
"ADD_FARM": {
"ADDRESS_IS_REQUIRED": "É necessário informar um endereço",
Expand Down
3 changes: 3 additions & 0 deletions packages/webapp/src/assets/images/x-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* 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/>.
*/

import type { Meta, StoryObj } from '@storybook/react';

import AddAnimalsFormCard from './AddAnimalsFormCard';
import { componentDecorators } from '../../../stories/Pages/config/Decorators';
import { Option } from './AnimalSelect';
import { FormProvider, useForm } from 'react-hook-form';

const mockSelectOptions = (...labels: string[]): Option[] =>
labels.map((label, i) => ({ label: label, value: i }));

const meta: Meta<typeof AddAnimalsFormCard> = {
title: 'Components/AddAnimalsFormCard',
component: AddAnimalsFormCard,
decorators: [
...componentDecorators,
(Story) => {
const methods = useForm();
return (
<FormProvider {...methods}>
<Story />
</FormProvider>
);
},
],
args: {
typeOptions: mockSelectOptions('Chicken', 'Cattle', 'Sheep', 'Dog'),
breedOptions: mockSelectOptions('Hereform', 'Angus', 'Landrace', 'Leghorn', 'German Shephard'),
sexDetailsOptions: [
{ id: 0, label: 'Male', count: 0 },
{ id: 1, label: 'Female', count: 0 },
],
},
};

export default meta;
type Story = StoryObj<typeof AddAnimalsFormCard>;

export const Primary: Story = {
args: {},
};

export const Active: Story = {
args: { isActive: true },
};

export const WithRemoveButton: Story = {
args: { ...Active.args, showRemoveButton: true },
};
Loading