Skip to content

Commit

Permalink
change search bar input and options prop for filter dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
kylezryr committed Nov 4, 2024
1 parent 5815bf0 commit 370eee1
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 24 deletions.
38 changes: 26 additions & 12 deletions app/seasonal-planting-guide/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { useState } from 'react';
import FilterDropdownMultiple from '@/components/FilterDropdownMultiple';
import FilterDropdownSingle from '@/components/FilterDropdownSingle';
import { PlantList } from '@/components/PlantList';
import SearchBar from '@/components/SearchBar/SearchBar';
import SearchBar from '@/components/SearchBar';
import { DropdownOption } from '@/types/schema';
import {
FilterContainer,
Expand All @@ -13,15 +13,31 @@ import {
StateOptionsContainer,
} from './styles';

const SeasonalPlantingGuide = () => {
const growingSeasonOptions = ['Spring', 'Summer', 'Fall', 'Winter'];
const harvestSeasonOptions = ['Spring', 'Summer', 'Fall', 'Winter'];
const plantingTypeOptions = [
'Start Seeds Indoors',
'Start Seeds Outdoors',
'Plant Seedlings/Transplant Outdoors',
export default function SeasonalPlantingGuide() {
const growingSeasonOptions: DropdownOption[] = [
{ label: 'Spring', value: 'SPRING' },
{ label: 'Summer', value: 'SUMMER' },
{ label: 'Fall', value: 'FALL' },
{ label: 'Winter', value: 'WINTER' },
];
const harvestSeasonOptions: DropdownOption[] = [
{ label: 'Spring', value: 'SPRING' },
{ label: 'Summer', value: 'SUMMER' },
{ label: 'Fall', value: 'FALL' },
{ label: 'Winter', value: 'WINTER' },
];
const plantingTypeOptions: DropdownOption[] = [
{ label: 'Start Seeds Indoors', value: 'Start Seeds Indoors' },
{ label: 'Start Seeds Outdoors', value: 'Start Seeds Outdoors' },
{
label: 'Plant Seedlings/Transplant Outdoors',
value: 'Plant Seedlings/Transplant Outdoors',
},
];
const usStateOptions: DropdownOption[] = [
{ label: 'Tennessee', value: 'TENNESSEE' },
{ label: 'Missouri', value: 'MISSOURI' },
];
const usStateOptions = ['Tennessee', 'Missouri'];

const [selectedGrowingSeason, setSelectedGrowingSeason] = useState<
DropdownOption[]
Expand Down Expand Up @@ -107,6 +123,4 @@ const SeasonalPlantingGuide = () => {
)}
</PageContainer>
);
};

export default SeasonalPlantingGuide;
}
7 changes: 2 additions & 5 deletions components/FilterDropdownMultiple.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DropdownOption } from '@/types/schema';
interface FilterDropdownProps {
value: DropdownOption[];
setStateAction: React.Dispatch<React.SetStateAction<DropdownOption[]>>;
options: string[];
options: DropdownOption[];
placeholder: string;
}

Expand All @@ -17,10 +17,7 @@ export default function FilterDropdownMultiple({
}: FilterDropdownProps) {
return (
<MultiSelect
options={options.map(option => ({
label: option,
value: option.toLocaleUpperCase(),
}))}
options={options}
value={value}
onChange={setStateAction}
labelledBy={placeholder}
Expand Down
7 changes: 4 additions & 3 deletions components/FilterDropdownSingle.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React, { useState } from 'react';
import { DropdownOption } from '@/types/schema';

interface FilterDropdownProps {
name?: string;
id?: string;
value: string;
setStateAction: React.Dispatch<React.SetStateAction<string>>;
options: string[];
options: DropdownOption[];
placeholder: string;
}

Expand Down Expand Up @@ -42,8 +43,8 @@ export default function FilterDropdownSingle({
{placeholder}
</option>
{options.map((option, index) => (
<option key={index} value={option.toLocaleUpperCase()}>
{option}
<option key={index} value={option.value}>
{option.label}
</option>
))}
</select>
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion components/SearchBar/styles.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import styled from 'styled-components';

export const SearchBarContainer = styled.div`
padding: 8px;
background-color: #f7f7f7;
border: none;
border-radius: 8px;
width: 30%;
`;

export const SearchBarInput = styled.input`
padding: 8px;
border: none;
background-color: #f7f7f7;
width: 100%;
`;
6 changes: 3 additions & 3 deletions utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ export function checkPlantingType(
// If it is not null, add true to plantingTypeBoolean
const plantingTypeBoolean: boolean[] = [];
for (const plantingType of plantingTypeFilterValue) {
if (plantingType.value === 'START SEEDS INDOORS') {
if (plantingType.value === 'Start Seeds Indoors') {
plantingTypeBoolean.push(plant.indoors_start !== null);
} else if (plantingType.value === 'START SEEDS OUTDOORS') {
} else if (plantingType.value === 'Start Seeds Outdoors') {
plantingTypeBoolean.push(plant.outdoors_start !== null);
} else if (plantingType.value === 'PLANT SEEDLINGS/TRANSPLANT OUTDOORS') {
} else if (plantingType.value === 'Plant Seedlings/Transplant Outdoors') {
plantingTypeBoolean.push(plant.transplant_start !== null);
}
}
Expand Down

0 comments on commit 370eee1

Please sign in to comment.