Skip to content

Commit

Permalink
add SignSearchDisplay prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Apr 30, 2024
1 parent 39a3be6 commit 515c6b2
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/signs/application/SignService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class SignService {
signName: string,
order: string,
sortEra: string
): Bluebird<string[]> {
): Bluebird<any[]> {
return this.signsRepository.findSignsByOrder(signName, order, sortEra)
}
}
47 changes: 43 additions & 4 deletions src/signs/ui/search/SignsSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import MesZL from 'signs/ui/search/MesZL'
interface Props {
signs: Sign[]
isIncludeHomophones: boolean
signService: SignService
}

function sortSigns(signs: Sign[]): Sign[] {
Expand All @@ -22,13 +23,50 @@ function sortSigns(signs: Sign[]): Sign[] {
)
}

function SignsSearch({ signs, isIncludeHomophones }: Props): JSX.Element {
const SignLists = withData<
{ sign: Sign; order: string },
{ signService: SignService },
any[]
>(
({ data }) => {
console.log(data)
return (
<>
{data.map((item, index) => (
<span key={index}>{item.name}</span>
))}
</>
)
},
(props) =>
props.signService.findSignsByOrder(
props.sign.name,
props.order,
'neoAssyrianOnset'
)
)

function SignsSearch({
signs,
isIncludeHomophones,
signService,
}: Props): JSX.Element {
const signsNew = isIncludeHomophones ? signs : sortSigns(signs)
return (
<ul className="WordSearch-results">
{signsNew.map((sign, index) => (
<li key={index} className="WordSearch-results__result">
<SignComponent sign={sign} />
<SignLists
sign={sign}
signService={signService}
order={'preceding'}
/>
<SignLists
sign={sign}
signService={signService}
order={'following'}
/>
</li>
))}
</ul>
Expand Down Expand Up @@ -75,14 +113,15 @@ function SignComponent({ sign }: { sign: Sign }): JSX.Element {
}

export default withData<
{ signQuery: SignQuery },
{ signService: SignService },
{ signQuery: SignQuery; signService: SignService },
unknown,
Sign[]
>(
({ data, signQuery }) => (
({ data, signQuery, signService }) => (
<SignsSearch
isIncludeHomophones={signQuery.isIncludeHomophones || false}
signs={data}
signService={signService}
/>
),
(props) => props.signService.search(props.signQuery),
Expand Down

0 comments on commit 515c6b2

Please sign in to comment.