Skip to content

Commit

Permalink
Merge pull request #2665 from LiteFarmOrg/integration
Browse files Browse the repository at this point in the history
V3.3.1 Release
  • Loading branch information
kcussen committed May 4, 2023
2 parents 690e290 + a50b5b5 commit e9c846a
Show file tree
Hide file tree
Showing 52 changed files with 401 additions and 146 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ LiteFarm is comprised of three applications which all reside in this monorepo.

The applications are configured with environment variables stored in `.env` files. Configuration information includes secrets like API keys, so the `.env` files are not included in this git repository.

This repository only contains `.env.default` files for api and webapp. To join the LiteFarm team and recieve full versions of the environment files contact community@litefarm.org.

Once you recieve the `.env` files, you will have to rename them correctly and place them in the right folders.
This repository contains a `.env.default` file for api and webapp. These files contain directions to acquire the personal keys needed to get LiteFarm running locally. Please note you will want to copy `.env.default` and rename the file to `.env`. Only after adding the `.env` file should you proceed to add the new keys. If you add your api keys to `.env.default` you may accidentally expose your keys since this file is tracked on git.
If you have questions about the other api keys, or wish to join the LiteFarm team, please contact community@litefarm.org.

# Running the apps

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright 2019, 2020, 2021, 2022, 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/>.
*/

export const up = async function (knex) {
await knex('countries')
.where('country_name', 'Cook Islands')
.update({ currency: 'New Zealand dollar', iso: 'NZD' });
};

export const down = async function (knex) {
await knex('countries')
.where('country_name', 'Cook Islands')
.update({ currency: 'Cook Islands dollar', iso: 'CKD[G]' });
};
22 changes: 22 additions & 0 deletions packages/api/db/migration/20230426222612_update_turkey_name.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2019, 2020, 2021, 2022, 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/>.
*/

export const up = async function (knex) {
await knex('countries').where('country_name', 'Turkey').update({ country_name: 'Türkiye' });
};

export const down = async function (knex) {
await knex('countries').where('country_name', 'Türkiye').update({ country_name: 'Turkey' });
};
4 changes: 2 additions & 2 deletions packages/api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "litefarm-api",
"version": "3.3.0",
"version": "3.3.1",
"description": "LiteFarm API server",
"main": "./api/src/server.js",
"type": "module",
Expand Down
10 changes: 10 additions & 0 deletions packages/api/src/controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import UserFarmModel from '../models/userFarmModel.js';
import PasswordModel from '../models/passwordModel.js';
import EmailTokenModel from '../models/emailTokenModel.js';
import ShiftModel from '../models/shiftModel.js';
import TaskModel from '../models/taskModel.js';
import NotificationUserModel from '../models/notificationUserModel.js';
import FarmModel from '../models/farmModel.js';
import { transaction, Model } from 'objection';
import bcrypt from 'bcryptjs';
Expand Down Expand Up @@ -507,6 +509,14 @@ const userController = {
.context({ user_id: sub })
.where({ user_id })
.patch({ user_id: sub });
await TaskModel.query(trx)
.context({ user_id: sub })
.where({ assignee_user_id: user_id })
.patch({ assignee_user_id: sub });
await NotificationUserModel.query(trx)
.context({ user_id: sub })
.where({ user_id })
.patch({ user_id: sub });
await EmailTokenModel.query(trx).where({ user_id }).patch({ user_id: sub });
await ShowedSpotlightModel.query(trx).insert({ user_id: sub });
await UserFarmModel.query(trx).where({ user_id }).delete();
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "litefarm-webapp",
"version": "3.3.0",
"version": "3.3.1",
"description": "LiteFarm Web application",
"type": "module",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion packages/webapp/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@
"ARCHIVE_DOCUMENT_TEXT": "Archiving this document will move it to the archived section of your documents, but not delete it. Archived documents will not be exported for your certifications. Do you want to proceed?",
"ARCHIVED": "Archived",
"CANCEL": "Cancel",
"CANCEL_MODAL": "document creation",
"COMPLIANCE_DOCUMENTS_AND_CERTIFICATION": "Compliance documents and your certification",
"DOCUMENTS": "Documents",
"EDIT_DOCUMENT": "Edit document",
Expand Down Expand Up @@ -767,7 +768,7 @@
}
},
"FILE_SIZE_MODAL": {
"BODY": "Files can not exceed 25MB or 5 pages.",
"BODY": "Files cannot be larger than 10MB.",
"TITLE": "File size too large"
},
"FILTER": {
Expand Down
3 changes: 2 additions & 1 deletion packages/webapp/public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@
"ARCHIVE_DOCUMENT_TEXT": "Archivar este documento lo moverá a la sección de archivado de sus documentos, pero no lo eliminará. Los documentos archivados no se exportarán para sus certificaciones. Quiere proceder?",
"ARCHIVED": "Archivado",
"CANCEL": "Cancelar",
"CANCEL_MODAL": "creación de documentos",
"COMPLIANCE_DOCUMENTS_AND_CERTIFICATION": "Documentos de cumplimiento y su certificación",
"DOCUMENTS": "Documentos",
"EDIT_DOCUMENT": "Editar documento",
Expand Down Expand Up @@ -766,7 +767,7 @@
}
},
"FILE_SIZE_MODAL": {
"BODY": "Los archivos no pueden exceder los 25 MB o 5 páginas.",
"BODY": "Los archivos no pueden exceder los 10 MB.",
"TITLE": "Tamaño de archivo demasiado grande"
},
"FILTER": {
Expand Down
3 changes: 2 additions & 1 deletion packages/webapp/public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@
"ARCHIVE_DOCUMENT_TEXT": "L'archivage de ce document le déplacera vers la section archivée de vos documents, mais ne le supprimera pas. Les documents archivés ne seront pas exportés pour vos certifications. Voulez-vous continuer\u00a0?",
"ARCHIVED": "Archivé",
"CANCEL": "Annuler",
"CANCEL_MODAL": "création de document",
"COMPLIANCE_DOCUMENTS_AND_CERTIFICATION": "Documents de conformité et votre certification",
"DOCUMENTS": "Documents",
"EDIT_DOCUMENT": "Modifier le document",
Expand Down Expand Up @@ -767,7 +768,7 @@
}
},
"FILE_SIZE_MODAL": {
"BODY": "Les fichiers ne peuvent pas dépasser 25MB ou 5 pages.",
"BODY": "Les fichiers ne peuvent pas dépasser 10MB.",
"TITLE": "Taille du fichier trop grande"
},
"FILTER": {
Expand Down
3 changes: 2 additions & 1 deletion packages/webapp/public/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@
"ARCHIVE_DOCUMENT_TEXT": "Arquivar este documento o moverá para a seção arquivada de seus documentos, mas não o excluirá. Os documentos arquivados não serão exportados para suas certificações. Você quer prosseguir?",
"ARCHIVED": "Arquivado",
"CANCEL": "Cancelar",
"CANCEL_MODAL": "criação de documento",
"COMPLIANCE_DOCUMENTS_AND_CERTIFICATION": "Documentos de conformidade e sua certificação",
"DOCUMENTS": "Documentos",
"EDIT_DOCUMENT": "Editar documento",
Expand Down Expand Up @@ -766,7 +767,7 @@
}
},
"FILE_SIZE_MODAL": {
"BODY": "Os arquivos não podem exceder 25 MB ou 5 páginas.",
"BODY": "Os arquivos não podem exceder 10 MB.",
"TITLE": "Tamanho de arquivo muito grande"
},
"FILTER": {
Expand Down
34 changes: 22 additions & 12 deletions packages/webapp/src/components/AddCropVariety/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Button from '../Form/Button';
import React from 'react';
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';
import { Label } from '../Typography';
Expand All @@ -11,6 +11,8 @@ import { useForm } from 'react-hook-form';
import MultiStepPageTitle from '../PageTitle/MultiStepPageTitle';
import Infoi from '../Tooltip/Infoi';
import { truncateText } from '../../util';
import Spinner from '../Spinner';

export default function PureAddCropVariety({
match,
onSubmit,
Expand Down Expand Up @@ -42,13 +44,15 @@ export default function PureAddCropVariety({
mode: 'onChange',
shouldUnregister: true,
defaultValues: {
crop_variety_photo_url: null,
crop_variety_photo_url: crop.crop_photo_url,
[LIFE_CYCLE]: crop[LIFE_CYCLE],
[HS_CODE_ID]: crop?.[HS_CODE_ID],
...persistedFormData,
},
});

const [showSpinner, setShowSpinner] = useState(false);

const { historyCancel } = useHookFormPersist(getValues);

const disabled = !isValid;
Expand Down Expand Up @@ -174,16 +178,21 @@ export default function PureAddCropVariety({
link={'https://www.litefarm.org/post/cultivars-and-varietals'}
placeholder={t('CROP.CULTIVAR_PLACEHOLDER')}
/>
{crop_variety_photo_url && (
<img
src={crop_variety_photo_url}
alt={crop.crop_common_name}
className={styles.circleImg}
onError={(e) => {
e.target.onerror = null;
e.target.src = 'crop-images/default.jpg';
}}
/>
{showSpinner ? (
<Spinner />
) : (
crop_variety_photo_url &&
crop_variety_photo_url != crop.crop_photo_url && (
<img
src={crop_variety_photo_url}
alt={crop.crop_common_name}
className={styles.circleImg}
onError={(e) => {
e.target.onerror = null;
e.target.src = 'crop-images/default.jpg';
}}
/>
)
)}
<div
style={{
Expand All @@ -201,6 +210,7 @@ export default function PureAddCropVariety({
{React.cloneElement(imageUploader, {
hookFormRegister: imageUrlRegister,
targetRoute: 'crop_variety',
onLoading: setShowSpinner,
})}
<Infoi
style={{
Expand Down
27 changes: 18 additions & 9 deletions packages/webapp/src/components/AddNewCrop/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import MultiStepPageTitle from '../PageTitle/MultiStepPageTitle';
import RadioGroup from '../Form/RadioGroup';
import styles from './styles.module.scss';
import Checkbox from '../Form/Checkbox';
import Spinner from '../Spinner';

export default function PureAddNewCrop({
handleContinue,
Expand Down Expand Up @@ -85,6 +86,8 @@ export default function PureAddNewCrop({
const cropImageUrlRegister = register(CROP_PHOTO_URL, { required: true });
const crop_photo_url = watch(CROP_PHOTO_URL);

const [showSpinner, setShowSpinner] = useState(false);

const farmCrops = useSelector(cropsOnMyFarmSelector);

const uniqueCropName = () => {
Expand Down Expand Up @@ -163,15 +166,20 @@ export default function PureAddNewCrop({
value={progress}
cancelModalTitle={t('CROP_CATALOGUE.CANCEL')}
/>
<img
src={crop_photo_url}
alt={t('translation:CROP.ADD_IMAGE')}
className={styles.circleImg}
onError={(e) => {
e.target.onerror = null;
e.target.src = 'crop-images/default.jpg';
}}
/>
{showSpinner ? (
<Spinner />
) : (
<img
src={crop_photo_url}
alt={t('translation:CROP.ADD_IMAGE')}
className={styles.circleImg}
onError={(e) => {
e.target.onerror = null;
e.target.src = 'crop-images/default.jpg';
}}
/>
)}

<div
style={{
marginLeft: 'auto',
Expand All @@ -188,6 +196,7 @@ export default function PureAddNewCrop({
{React.cloneElement(imageUploader, {
hookFormRegister: cropImageUrlRegister,
targetRoute: 'crop',
onLoading: setShowSpinner,
})}
</div>
<Input
Expand Down
3 changes: 2 additions & 1 deletion packages/webapp/src/components/CreateUserAccount/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Form from '../Form';
import Button from '../Form/Button';
import Input from '../Form/Input';
import Input, { integerOnKeyDown } from '../Form/Input';
import React, { useEffect, useState } from 'react';
import { Title } from '../Typography';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -151,6 +151,7 @@ export default function PureCreateUserAccount({ onSignUp, email, onGoBack }) {
data-cy="createUser-birthYear"
label={t('CREATE_USER.BIRTH_YEAR')}
type="number"
onKeyPress={integerOnKeyDown}
hookFormRegister={register(BIRTHYEAR, {
min: 1900,
max: new Date().getFullYear(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ export default function PureContainerForm({
hookFormRegister={register(NUMBER_OF_CONTAINERS, {
required: true,
valueAsNumber: true,
max: hookFormMaxValidation(9999),
max: hookFormMaxValidation(99999),
})}
max={9999}
max={99999}
type={'number'}
onKeyDown={integerOnKeyDown}
errors={getInputErrors(errors, NUMBER_OF_CONTAINERS)}
Expand All @@ -154,10 +154,10 @@ export default function PureContainerForm({
label={t('MANAGEMENT_PLAN.TOTAL_PLANTS')}
hookFormRegister={register(TOTAL_PLANTS, {
required: true,
max: hookFormMaxValidation(9999),
max: hookFormMaxValidation(99999),
valueAsNumber: true,
})}
max={9999}
max={99999}
style={{ paddingBottom: '40px' }}
type={'number'}
onKeyDown={integerOnKeyDown}
Expand Down
3 changes: 2 additions & 1 deletion packages/webapp/src/components/Documents/Add/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function PureDocumentDetailView({
value={66}
title={t('DOCUMENTS.ADD.TITLE')}
style={{ marginBottom: '24px' }}
cancelModalTitle={t('DOCUMENTS.CANCEL_MODAL')}
/>
)}
<Input
Expand Down Expand Up @@ -229,7 +230,7 @@ function PureDocumentDetailView({
<Loading style={{ minHeight: '192px', width: '100%', maxWidth: '312px' }} />
)}
</div>
{uploadedFiles?.length <= 5 &&
{uploadedFiles?.length < 5 &&
documentUploader({
style: { paddingBottom: '32px' },
linkText: t('DOCUMENTS.ADD.ADD_MORE_PAGES'),
Expand Down

0 comments on commit e9c846a

Please sign in to comment.