2023-09-18 22:32:21 +00:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { CopyIcon, ListBulletIcon, ReloadIcon } from '@radix-ui/react-icons';
|
2023-09-18 23:05:19 +00:00
|
|
|
import { debounce } from 'lodash';
|
|
|
|
|
import { ChangeEvent, useRef } from 'react';
|
2023-09-18 22:32:21 +00:00
|
|
|
import { Button } from '../../../components/Button';
|
|
|
|
|
import PageWrapper from '../../../components/PageWrapper';
|
|
|
|
|
import { SearchBar } from '../../../components/SearchBar';
|
2023-09-18 23:05:19 +00:00
|
|
|
import { AccountListWithServer } from '../../../core/blitz/listPlayers';
|
2023-09-18 22:32:21 +00:00
|
|
|
import * as styles from './page.css';
|
|
|
|
|
|
2023-09-18 21:55:40 +00:00
|
|
|
export default function Page() {
|
2023-09-18 23:05:19 +00:00
|
|
|
const input = useRef<HTMLInputElement>(null);
|
|
|
|
|
const handleChange = debounce(
|
|
|
|
|
async (event: ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
if (event.target.value) {
|
|
|
|
|
const players = await fetch(
|
|
|
|
|
`/api/list/players?search=${event.target.value}`,
|
|
|
|
|
).then((response) => response.json() as Promise<AccountListWithServer>);
|
|
|
|
|
|
|
|
|
|
console.log(
|
|
|
|
|
players
|
|
|
|
|
.map((player) => `${player.region} - ${player.nickname}`)
|
|
|
|
|
.join('\n'),
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
// TODO
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
500,
|
|
|
|
|
);
|
|
|
|
|
|
2023-09-18 22:32:21 +00:00
|
|
|
return (
|
|
|
|
|
<PageWrapper>
|
|
|
|
|
<div className={styles.toolBar}>
|
2023-09-18 23:05:19 +00:00
|
|
|
<SearchBar
|
|
|
|
|
ref={input}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
style={{ flex: 1 }}
|
|
|
|
|
placeholder="Search for a player..."
|
|
|
|
|
/>
|
2023-09-18 22:32:21 +00:00
|
|
|
|
|
|
|
|
<div style={{ display: 'flex', gap: 8 }}>
|
|
|
|
|
<Button className={styles.button} color="dangerous">
|
|
|
|
|
<ReloadIcon /> Reset
|
|
|
|
|
</Button>
|
|
|
|
|
<Button className={styles.button}>
|
|
|
|
|
<CopyIcon /> Embed
|
|
|
|
|
</Button>
|
|
|
|
|
<Button className={styles.button}>
|
|
|
|
|
<ListBulletIcon /> Options
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</PageWrapper>
|
|
|
|
|
);
|
2023-09-18 21:55:40 +00:00
|
|
|
}
|