LasTres/js-src/components/pj-list-selection.tsx

41 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-06-08 09:02:32 +02:00
import * as React from 'react'
import type { PJ } from '@lastres/pj'
2023-06-08 09:02:32 +02:00
import PJHealthLikeBar from '@lastres/components/pj-health-like-bar'
interface PJListSelectionProps {
pjs: PJ[] | null
setSelectedPJ: (set: PJ | null) => void
}
export default function PJListSelection (props: PJListSelectionProps): JSX.Element {
2023-06-08 09:02:32 +02:00
const pjs = props.pjs
if (pjs === null) {
return (
<>
2023-06-22 21:54:28 +02:00
<p>Aun no se han descargado los pjs, espera un segundo...</p>
2023-06-08 09:02:32 +02:00
</>
)
}
return (
<>
{
pjs.map((item, i) =>
<a onClick={() => {
props.setSelectedPJ(item)
}} href="#" key={i}>
2023-06-08 09:02:32 +02:00
<span>{item.full_name}</span>
<span>{item.short_name}</span>
<span>{item.nick}</span>
<label className="bar-container">
2023-06-08 09:02:32 +02:00
<PJHealthLikeBar value={item.health} max={item.max_health}/>
</label>
<label className="bar-container">
Mana
2023-06-08 09:02:32 +02:00
<PJHealthLikeBar value={item.mana} max={item.max_mana}/>
</label>
</a>)
2023-06-08 09:02:32 +02:00
}
</>
)
}