Skip to content

Commit

Permalink
uninstall multi-select, change growing season to only filter outdoor …
Browse files Browse the repository at this point in the history
…months
  • Loading branch information
kylezryr committed Dec 7, 2024
1 parent 30a6d4f commit 8005b0c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 39 deletions.
3 changes: 2 additions & 1 deletion app/seasonal-planting-guide/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import COLORS from '@/styles/colors';
import { Box, Flex } from '@/styles/containers';
import { H1, H3 } from '@/styles/text';
import { DropdownOption, PlantingTypeEnum, SeasonEnum } from '@/types/schema';
import { useTitleCase } from '@/utils/helpers';
import { useProfile } from '@/utils/ProfileProvider';
import {
FilterContainer,
Expand Down Expand Up @@ -71,7 +72,7 @@ export default function SeasonalPlantingGuide() {
useEffect(() => {
if (profileReady && profileData) {
setSelectedUsState({
label: profileData.us_state,
label: useTitleCase(profileData.us_state),

Check failure on line 75 in app/seasonal-planting-guide/page.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint, Prettier, and TypeScript compiler

React Hook "useTitleCase" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function

Check failure on line 75 in app/seasonal-planting-guide/page.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint, Prettier, and TypeScript compiler

React Hook "useTitleCase" cannot be called inside a callback. React Hooks must be called in a React function component or a custom React Hook function
value: profileData.us_state,
});
}
Expand Down
9 changes: 2 additions & 7 deletions components/PlantCardKey/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import COLORS from '@/styles/colors';
import { Flex } from '@/styles/containers';
import { P3 } from '@/styles/text';
import { DifficultyLevelEnum } from '@/types/schema';
import { useTitleCase } from '@/utils/helpers';
import DifficultyLevelBar from '../DifficultyLevelBar';
import Icon from '../Icon';
import {
Expand All @@ -19,18 +20,12 @@ const DifficultyBarAndLabel = ({
}: {
difficultyLevel: DifficultyLevelEnum;
}) => {
// to convert difficulty level enum to title case
const difficultyToTitleCase: Record<DifficultyLevelEnum, string> = {
EASY: 'Easy',
MODERATE: 'Moderate',
HARD: 'Hard',
};
return (
<Flex $direction="column" $align="center" $gap="4px">
<DifficultyLevelBar
difficultyLevel={difficultyLevel as DifficultyLevelEnum}
/>
<P3>{difficultyToTitleCase[difficultyLevel as DifficultyLevelEnum]}</P3>
<P3>{useTitleCase(difficultyLevel)}</P3>
</Flex>
);
};
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"next": "^14.2.10",
"react": "^18",
"react-dom": "^18",
"react-multi-select-component": "^4.3.4",
"react-select": "^5.8.3",
"styled-components": "^6.1.13",
"supabase": "^1.200.3"
Expand Down
14 changes: 0 additions & 14 deletions pnpm-lock.yaml

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

21 changes: 5 additions & 16 deletions utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,17 @@ export function checkGrowingSeason(

// Handle late/early month logic
// Set late/early month to just the month using processPlantMonth
const indoorsStart =
plant.indoors_start && processPlantMonth(plant.indoors_start);
const indoorsEnd = plant.indoors_end && processPlantMonth(plant.indoors_end);
const outdoorsStart =
plant.outdoors_start && processPlantMonth(plant.outdoors_start);
const outdoorsEnd =
plant.outdoors_end && processPlantMonth(plant.outdoors_end);

// Checks if either indoor_start to indoor_end or outdoor_start to outdoor_end
// is within the valid range of months
// Checks if outdoor_start to outdoor_end is within the valid range of months
// exclamation marks to assert values are not undefined
return (
isInRange(
monthToIndex.get(indoorsStart!)!,
monthToIndex.get(indoorsEnd!)!,
validIndexes!,
) ||
isInRange(
monthToIndex.get(outdoorsStart!)!,
monthToIndex.get(outdoorsEnd!)!,
validIndexes!,
)
return isInRange(
monthToIndex.get(outdoorsStart!)!,
monthToIndex.get(outdoorsEnd!)!,
validIndexes!,
);
}

Expand Down

0 comments on commit 8005b0c

Please sign in to comment.