1
0
mirror of https://github.com/uetchy/namae.git synced 2025-03-16 20:20:38 +09:00

fix: normalize app store result

This commit is contained in:
uetchy 2022-04-13 15:23:55 +09:00
parent e601a75c43
commit afa2e7d52e
2 changed files with 15 additions and 6 deletions

View File

@ -8,6 +8,8 @@ interface App {
version: string; version: string;
price: string; price: string;
trackViewUrl: string; trackViewUrl: string;
sellerName: string;
formattedPrice: string;
} }
interface AppStoreResponse { interface AppStoreResponse {
@ -37,9 +39,7 @@ export default async function handler(
const apps = body.results.map((app) => ({ const apps = body.results.map((app) => ({
id: app.trackId, id: app.trackId,
name: app.trackName, name: app.trackName,
kind: app.kind, author: app.sellerName,
version: app.version,
price: app.price,
viewURL: app.trackViewUrl, viewURL: app.trackViewUrl,
})); }));
send(res, { result: apps }); send(res, { result: apps });

View File

@ -12,7 +12,12 @@ const Search: React.FC<{ query: string }> = ({ query }) => {
'countryCode' 'countryCode'
)}` )}`
) as { ) as {
result: Array<{ name: string; viewURL: string; price: number; id: string }>; result: Array<{
name: string;
viewURL: string;
author: string;
id: string;
}>;
}; };
const apps = response.result; const apps = response.result;
@ -22,14 +27,18 @@ const Search: React.FC<{ query: string }> = ({ query }) => {
apps.map((app) => ( apps.map((app) => (
<Result <Result
title={app.name.split(/[-–—\-:]/)[0]} title={app.name.split(/[-–—\-:]/)[0]}
message={`Price: ${app.price}`} message={`By ${app.author}`}
link={app.viewURL} link={app.viewURL}
icon={<SiAppstore />} icon={<SiAppstore />}
key={app.id} key={app.id}
/> />
)) ))
) : ( ) : (
<Result title={t('noResult')} icon={<FaInfoCircle />} /> <Result
title={t('noResult')}
message={t('noResult')}
icon={<FaInfoCircle />}
/>
)} )}
</> </>
); );