-
-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
663e3af
commit db5f30a
Showing
15 changed files
with
94 additions
and
260 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,50 @@ | ||
import { useEffect, useState } from 'react' | ||
import { Field } from 'react-final-form' | ||
import { CategoriesSelect } from 'src/pages/Howto/Category/CategoriesSelect' | ||
import { CategoriesSelectV2 } from 'src/pages/common/Category/CategoriesSelectV2' | ||
import { | ||
FormFieldWrapper, | ||
HowtoCategoryGuidance, | ||
} from 'src/pages/Howto/Content/Common' | ||
import { intro } from 'src/pages/Howto/labels' | ||
|
||
import type { ICategory } from 'src/models/categories.model' | ||
import { howtoService } from '../../howto.service' | ||
|
||
interface IProps { | ||
category: ICategory | undefined | ||
} | ||
import type { SelectValue } from 'src/pages/common/Category/CategoriesSelectV2' | ||
|
||
export const HowtoFieldCategory = ({ category }: IProps) => { | ||
export const HowtoFieldCategory = () => { | ||
const { placeholder, title } = intro.category | ||
const [options, setOptions] = useState<SelectValue[]>([]) | ||
|
||
useEffect(() => { | ||
const getCategories = async () => { | ||
const categories = await howtoService.getHowtoCategories() | ||
setOptions( | ||
categories | ||
.filter((x) => !x._deleted) | ||
.map((x) => ({ label: x.label, value: x })), | ||
) | ||
} | ||
|
||
getCategories() | ||
}, []) | ||
|
||
return ( | ||
<FormFieldWrapper text={title} required> | ||
<Field | ||
name="category" | ||
render={({ input, ...rest }) => ( | ||
<CategoriesSelect | ||
{...rest} | ||
isForm={true} | ||
onChange={(category) => input.onChange(category)} | ||
value={input.value} | ||
placeholder={placeholder} | ||
type="howto" | ||
/> | ||
render={({ input }) => ( | ||
<> | ||
<CategoriesSelectV2 | ||
isForm={true} | ||
onChange={(category) => input.onChange(category)} | ||
value={input.value} | ||
placeholder={placeholder || ''} | ||
categories={options} | ||
/> | ||
<HowtoCategoryGuidance category={input.value} type="main" /> | ||
</> | ||
)} | ||
/> | ||
<HowtoCategoryGuidance category={category} type="main" /> | ||
</FormFieldWrapper> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/pages/Research/Content/Common/ResearchCategorySelect.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useEffect, useState } from 'react' | ||
import { Field } from 'react-final-form' | ||
import { CategoriesSelectV2 } from 'src/pages/common/Category/CategoriesSelectV2' | ||
|
||
import { overview } from '../../labels' | ||
import { researchService } from '../../research.service' | ||
|
||
import type { SelectValue } from 'src/pages/common/Category/CategoriesSelectV2' | ||
|
||
const ResearchFieldCategory = () => { | ||
const [options, setOptions] = useState<SelectValue[]>([]) | ||
|
||
useEffect(() => { | ||
const getCategories = async () => { | ||
const categories = await researchService.getResearchCategories() | ||
setOptions( | ||
categories | ||
.filter((x) => !x._deleted) | ||
.map((x) => ({ label: x.label, value: x })), | ||
) | ||
} | ||
|
||
getCategories() | ||
}, []) | ||
|
||
return ( | ||
<Field | ||
name="researchCategory" | ||
render={({ input }) => ( | ||
<CategoriesSelectV2 | ||
isForm={true} | ||
onChange={(category) => input.onChange(category)} | ||
value={input.value} | ||
placeholder={overview.categories.placeholder || ''} | ||
categories={options} | ||
/> | ||
)} | ||
/> | ||
) | ||
} | ||
|
||
export default ResearchFieldCategory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export enum ResearchSearchParams { | ||
category = 'category', | ||
q = 'q', | ||
sort = 'sort', | ||
status = 'status', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
54 changes: 0 additions & 54 deletions
54
src/stores/QuestionCategories/questionCategories.store.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.