2020-08-31 09:44:05 +09:00
|
|
|
import useFetch from 'fetch-suspense';
|
|
|
|
import React from 'react';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { FaInfoCircle } from 'react-icons/fa';
|
|
|
|
import { IoMdAppstore } from 'react-icons/io';
|
|
|
|
import { Card, Result } from '../core';
|
|
|
|
|
|
|
|
const Search: React.FC<{ query: string }> = ({ query }) => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const response = useFetch(
|
|
|
|
`/api/services/playstore/${encodeURIComponent(query)}}`
|
|
|
|
) as {
|
|
|
|
result: Array<{
|
|
|
|
id: string;
|
|
|
|
name: string;
|
2022-04-13 15:24:26 +09:00
|
|
|
description: string;
|
2020-08-31 09:44:05 +09:00
|
|
|
author: string;
|
|
|
|
url: string;
|
|
|
|
}>;
|
|
|
|
};
|
|
|
|
const apps = response.result;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{apps && apps.length > 0 ? (
|
|
|
|
apps.map((app) => (
|
|
|
|
<Result
|
|
|
|
title={app.name}
|
2022-04-13 15:24:26 +09:00
|
|
|
message={`${app.author}: ${app.description}`}
|
2020-08-31 09:44:05 +09:00
|
|
|
link={app.url}
|
|
|
|
icon={<IoMdAppstore />}
|
|
|
|
key={app.id}
|
|
|
|
/>
|
|
|
|
))
|
|
|
|
) : (
|
2022-04-13 15:24:26 +09:00
|
|
|
<Result
|
|
|
|
title={t('noResult')}
|
|
|
|
message={t('noResult')}
|
|
|
|
icon={<FaInfoCircle />}
|
|
|
|
/>
|
2020-08-31 09:44:05 +09:00
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const PlayStoreCard: React.FC<{ query: string }> = ({ query }) => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Card title={t('providers.playStore')}>
|
|
|
|
<Search query={query} />
|
|
|
|
</Card>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default PlayStoreCard;
|