|
1 | 1 | import React, { useEffect, useState } from 'react'; |
2 | 2 | import { useTranslation } from 'react-i18next'; |
3 | 3 |
|
4 | | -import { Cards, CardsProps, MultiselectCSD, PropertyFilter, StatusIndicator } from 'components'; |
| 4 | +import { Cards, CardsProps, MultiselectCSD, Popover, PropertyFilter } from 'components'; |
5 | 5 |
|
6 | 6 | import { useCollection } from 'hooks'; |
7 | 7 | import { useGetGpusListQuery } from 'services/gpu'; |
@@ -181,15 +181,28 @@ export const OfferList: React.FC<OfferListProps> = ({ withSearchParams, onChange |
181 | 181 | { |
182 | 182 | id: 'availability', |
183 | 183 | content: (gpu: IGpu) => { |
184 | | - // FIXME: array to string comparison never passes. |
185 | | - // Additionally, there are more availability statuses that are worth displaying, |
186 | | - // and several of them may be present at once. |
| 184 | + const availabilityIssues = |
| 185 | + gpu.availability.length > 0 && |
| 186 | + gpu.availability.every((a) => a === 'not_available' || a === 'no_quota' || a === 'no_balance'); |
187 | 187 |
|
188 | | - // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
189 | | - // @ts-expect-error |
190 | | - if (gpu.availability === 'not_available') { |
191 | | - return <StatusIndicator type="warning">Not Available</StatusIndicator>; |
| 188 | + if (!availabilityIssues) { |
| 189 | + return null; |
192 | 190 | } |
| 191 | + |
| 192 | + if (gpu.availability.length === 1) { |
| 193 | + return <span className={styles.greyText}>{t(`offer.availability_${gpu.availability[0]}`)}</span>; |
| 194 | + } |
| 195 | + |
| 196 | + return ( |
| 197 | + <Popover |
| 198 | + dismissButton={false} |
| 199 | + position="top" |
| 200 | + size="small" |
| 201 | + content={gpu.availability.map((a) => t(`offer.availability_${a}`)).join(', ')} |
| 202 | + > |
| 203 | + <span className={styles.greyText}>{t('offer.availability_not_available')}</span> |
| 204 | + </Popover> |
| 205 | + ); |
193 | 206 | }, |
194 | 207 | width: 50, |
195 | 208 | }, |
|
0 commit comments