mirror of
https://github.com/uetchy/namae.git
synced 2025-08-20 09:58:13 +09:00
feat: add Google Play Store
This commit is contained in:
@@ -18,6 +18,7 @@ import NetlifyCard from './providers/Netlify';
|
||||
import NpmCard from './providers/Npm';
|
||||
import NtaCard from './providers/Nta';
|
||||
import OcamlCard from './providers/Ocaml';
|
||||
import PlayStoreCard from './providers/PlayStore';
|
||||
import PypiCard from './providers/PyPI';
|
||||
import RubyGemsCard from './providers/RubyGems';
|
||||
import S3Card from './providers/S3';
|
||||
@@ -58,6 +59,7 @@ const Index: React.FC<{ query: string }> = ({ query }) => {
|
||||
<Cards>
|
||||
<GithubSearchCard query={query} />
|
||||
<AppStoreCard query={query} />
|
||||
<PlayStoreCard query={query} />
|
||||
{language === 'ja' ? <NtaCard query={query} /> : null}
|
||||
</Cards>
|
||||
</>
|
||||
|
52
src/components/cards/providers/PlayStore.tsx
Normal file
52
src/components/cards/providers/PlayStore.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
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;
|
||||
author: string;
|
||||
rating: number;
|
||||
url: string;
|
||||
}>;
|
||||
};
|
||||
const apps = response.result;
|
||||
|
||||
return (
|
||||
<>
|
||||
{apps && apps.length > 0 ? (
|
||||
apps.map((app) => (
|
||||
<Result
|
||||
title={app.name}
|
||||
message={`Rating: ${app.rating}`}
|
||||
link={app.url}
|
||||
icon={<IoMdAppstore />}
|
||||
key={app.id}
|
||||
/>
|
||||
))
|
||||
) : (
|
||||
<Result title={t('noResult')} icon={<FaInfoCircle />} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const PlayStoreCard: React.FC<{ query: string }> = ({ query }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Card title={t('providers.playStore')}>
|
||||
<Search query={query} />
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default PlayStoreCard;
|
Reference in New Issue
Block a user