2019-09-17 14:30:26 +09:00
|
|
|
import React from 'react';
|
|
|
|
import useFetch from 'fetch-suspense';
|
|
|
|
import {useTranslation} from 'react-i18next';
|
|
|
|
import {FaBuilding, FaInfoCircle} from 'react-icons/fa';
|
2019-09-01 00:00:24 +09:00
|
|
|
|
2020-02-05 16:22:35 +09:00
|
|
|
import {Card, Result} from '../core';
|
2019-09-01 00:00:24 +09:00
|
|
|
|
2019-09-17 14:30:26 +09:00
|
|
|
const Search: React.FC<{query: string}> = ({query}) => {
|
|
|
|
const {t} = useTranslation();
|
|
|
|
const term = encodeURIComponent(query);
|
2019-09-01 01:28:24 +09:00
|
|
|
const response = useFetch(`/availability/nta/${term}`) as {
|
2019-09-17 14:30:26 +09:00
|
|
|
result: Array<{name: string; phoneticName: string}>;
|
|
|
|
};
|
|
|
|
const apps = response.result;
|
2019-09-01 00:00:24 +09:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{apps.length > 0 ? (
|
|
|
|
apps.map((app, i) => (
|
|
|
|
<Result
|
|
|
|
title={app.name}
|
|
|
|
message={`Phonetic: ${app.phoneticName}`}
|
|
|
|
icon={<FaBuilding />}
|
|
|
|
key={i}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
) : (
|
|
|
|
<Result title={t('noResult')} icon={<FaInfoCircle />} />
|
|
|
|
)}
|
|
|
|
</>
|
2019-09-17 14:30:26 +09:00
|
|
|
);
|
|
|
|
};
|
2019-09-01 00:00:24 +09:00
|
|
|
|
2019-09-17 14:30:26 +09:00
|
|
|
const NtaCard: React.FC<{query: string}> = ({query}) => {
|
|
|
|
const {t} = useTranslation();
|
2019-09-01 00:00:24 +09:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Card title={t('providers.nta')}>
|
|
|
|
<Search query={query} />
|
|
|
|
</Card>
|
2019-09-17 14:30:26 +09:00
|
|
|
);
|
|
|
|
};
|
2019-09-01 01:28:24 +09:00
|
|
|
|
2019-09-17 14:30:26 +09:00
|
|
|
export default NtaCard;
|