import { useCallback } from 'react' import { useApi, useApiCall, Assets, DailyForecasts } from '../../api' import { useAuth } from '../../auth' import { saveFile, buildFilename } from './utils' import Loader, { LoaderColor } from '../Loader' import './styles.css' type Forecasts = DailyForecasts.Forecast[] type PersonalAssets = Assets.Asset[] interface WallpaperData { assets: PersonalAssets forecasts: Forecasts } function WallpaperPage(): JSX.Element { const api = useApi() const { user, token } = useAuth() const category = user?.profile.sign?.sign || '' const loadData = useCallback(() => { return Promise.all([ api.getAssets({ token, category }), api.getDailyForecasts({ token }), ]) .then(([{ assets }, { user_daily_forecast }]) => ({ assets, forecasts: user_daily_forecast.forecasts, })) }, [api, category, token]) const { data, isPending } = useApiCall(loadData) const { assets, forecasts } = data const asset = assets?.at(0) const handleClick = () => asset && saveFile(asset.url, buildFilename(category)) return (
{asset ? {category} : null} {asset ?
: null} {isPending ? : null}
{isPending ? null : ( <>

Analysis of personal background

{forecasts.map((forecast) => (

{forecast.category}

{forecast.body}

))} )}
) } export default WallpaperPage