Skip to content

Commit

Permalink
fix: clean up image config types (#1404)
Browse files Browse the repository at this point in the history
* fix: remove unused REACT_APP_SHARED_DATA_ACCEPTED_EXTENSIONS config from example

* chore: remove REACT_APP_IMAGE_ACCEPTED_EXTENSIONS from sample config

* fix: rework PROFILE_IMAGE_ACCEPTED_EXTENSIONS to match other configs

* fix: update test result output string to match config change
  • Loading branch information
paulschreiber authored Feb 29, 2024
1 parent 3f2ab07 commit 95ff1d8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 0 additions & 2 deletions local.env.sample
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
ENV=development
REACT_APP_TERRASO_API_URL=http://127.0.0.1:8000
REACT_APP_PLAUSIBLE_DOMAIN=app.local.terraso.org
REACT_APP_SHARED_DATA_ACCEPTED_EXTENSIONS=csv,doc,docx,pdf,ppt,pptx,xlsx,xls
REACT_APP_IMAGE_ACCEPTED_EXTENSIONS=jpeg,jpg
REACT_APP_MAPBOX_ACCESS_TOKEN=
REACT_APP_SENTRY_DSN=https://[email protected]/abcd
SENTRY_AUTH_TOKEN=sntrys_eyxxxxxxxxxxx
10 changes: 7 additions & 3 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ export const DOCUMENT_ACCEPTED_TYPES = {
],
};

export const PROFILE_IMAGE_ACCEPTED_TYPES = {
'image/jpeg': ['.jpg', '.jpeg'],
};

export const MEDIA_ACCEPTED_TYPES = {
'image/jpeg': ['.jpg', '.jpeg'],
'image/png': ['.png'],
Expand Down Expand Up @@ -147,9 +151,9 @@ export const SHARED_DATA_ACCEPTED_EXTENSIONS = getTypesExtensions(
SHARED_DATA_ACCEPTED_TYPES
);

export const IMAGE_ACCEPTED_EXTENSIONS = (
process.env.REACT_APP_IMAGE_ACCEPTED_EXTENSIONS || 'jpg,jpeg'
).split(',');
export const PROFILE_IMAGE_ACCEPTED_EXTENSIONS = getTypesExtensions(
PROFILE_IMAGE_ACCEPTED_TYPES
);

export const HUBSPOT_FORMS = {
region: process.env.REACT_APP_HUBSPOT_FORMS_REGION || 'na1',
Expand Down
6 changes: 3 additions & 3 deletions src/landscape/components/LandscapeForm/ProfileImageStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import PageLoader from 'layout/PageLoader';
import Actions from './Actions';

import {
IMAGE_ACCEPTED_EXTENSIONS,
LANDSCAPE_PROFILE_IMAGE_MAX_SIZE,
PROFILE_IMAGE_ACCEPTED_EXTENSIONS,
} from 'config';

const ASPECT_RATIO = 0.5625; // 9 / 16
Expand Down Expand Up @@ -99,7 +99,7 @@ const ProfileImage = props => {
if (_.isEmpty(acceptedFiles)) {
setError(
t('landscape.form_profile_image_file_no_accepted', {
extensions: IMAGE_ACCEPTED_EXTENSIONS.join(', '),
extensions: PROFILE_IMAGE_ACCEPTED_EXTENSIONS.join(', '),
})
);
return;
Expand Down Expand Up @@ -146,7 +146,7 @@ const ProfileImage = props => {
)}
<DropZone
errors={error ? [error] : null}
fileExtensions={IMAGE_ACCEPTED_EXTENSIONS}
fileExtensions={PROFILE_IMAGE_ACCEPTED_EXTENSIONS}
maxSize={LANDSCAPE_PROFILE_IMAGE_MAX_SIZE}
onDrop={onDrop}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const setup = async () => {
});

const dropzone = screen.getByRole('button', {
name: 'Select File Accepted file formats: *.jpg, *.jpeg Maximum file size: 10 MB',
name: 'Select File Accepted file formats: *.jpeg, *.jpg Maximum file size: 10 MB',
});

const dropFiles = async files => {
Expand Down

0 comments on commit 95ff1d8

Please sign in to comment.