import React, { useEffect, useMemo, useState } from 'react'; import { AppCircle, AppCircleContainer, AppDownloadButton, AppDownloadButtonText, AppInfoAppName, AppInfoSnippetContainer, AppInfoSnippetLeft, AppInfoSnippetMiddle, AppInfoUserName, AppsCategoryInfo, AppsCategoryInfoLabel, AppsCategoryInfoSub, AppsCategoryInfoValue, AppsInfoDescription, AppsLibraryContainer, AppsWidthLimiter, } from './Apps-styles'; import { Avatar, Box, useTheme } from '@mui/material'; import { getBaseApiReact } from '../../App'; import LogoSelected from '../../assets/svgs/LogoSelected.svg'; import { Spacer } from '../../common/Spacer'; import { executeEvent } from '../../utils/events'; import { AppRating } from './AppRating'; import { settingsLocalLastUpdatedAtom, sortablePinnedAppsAtom, } from '../../atoms/global'; import { saveToLocalStorage } from './AppsNavBarDesktop'; import { useRecoilState, useSetRecoilState } from 'recoil'; export const AppInfo = ({ app, myName }) => { const isInstalled = app?.status?.status === 'READY'; const [sortablePinnedApps, setSortablePinnedApps] = useRecoilState( sortablePinnedAppsAtom ); const theme = useTheme(); const isSelectedAppPinned = !!sortablePinnedApps?.find( (item) => item?.name === app?.name && item?.service === app?.service ); const setSettingsLocalLastUpdated = useSetRecoilState( settingsLocalLastUpdatedAtom ); return ( center-icon {app?.metadata?.title || app?.name} {app?.name} { setSortablePinnedApps((prev) => { let updatedApps; if (isSelectedAppPinned) { // Remove the selected app if it is pinned updatedApps = prev.filter( (item) => !( item?.name === app?.name && item?.service === app?.service ) ); } else { // Add the selected app if it is not pinned updatedApps = [ ...prev, { name: app?.name, service: app?.service, }, ]; } saveToLocalStorage( 'ext_saved_settings', 'sortablePinnedApps', updatedApps ); return updatedApps; }); setSettingsLocalLastUpdated(Date.now()); }} sx={{ backgroundColor: theme.palette.background.paper, height: '29px', maxWidth: '320px', opacity: isSelectedAppPinned ? 0.6 : 1, width: '100%', }} > {isSelectedAppPinned ? 'Unpin from dashboard' : 'Pin to dashboard'} { executeEvent('addTab', { data: app, }); }} sx={{ backgroundColor: isInstalled ? '#0091E1' : theme.palette.background.paper, height: '29px', maxWidth: '320px', width: '100%', }} > {isInstalled ? 'Open' : 'Download'} Category: {app?.metadata?.categoryName || 'none'} About this Q-App {app?.metadata?.description || 'No description'} ); };