|
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'; |
@@ -198,15 +198,28 @@ export const OfferList: React.FC<OfferListProps> = ({ |
198 | 198 | { |
199 | 199 | id: 'availability', |
200 | 200 | content: (gpu: IGpu) => { |
201 | | - // FIXME: array to string comparison never passes. |
202 | | - // Additionally, there are more availability statuses that are worth displaying, |
203 | | - // and several of them may be present at once. |
| 201 | + const availabilityIssues = |
| 202 | + gpu.availability.length > 0 && |
| 203 | + gpu.availability.every((a) => a === 'not_available' || a === 'no_quota' || a === 'no_balance'); |
204 | 204 |
|
205 | | - // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
206 | | - // @ts-expect-error |
207 | | - if (gpu.availability === 'not_available') { |
208 | | - return <StatusIndicator type="warning">Not Available</StatusIndicator>; |
| 205 | + if (!availabilityIssues) { |
| 206 | + return null; |
209 | 207 | } |
| 208 | + |
| 209 | + if (gpu.availability.length === 1) { |
| 210 | + return <span className={styles.greyText}>{t(`offer.availability_${gpu.availability[0]}`)}</span>; |
| 211 | + } |
| 212 | + |
| 213 | + return ( |
| 214 | + <Popover |
| 215 | + dismissButton={false} |
| 216 | + position="top" |
| 217 | + size="small" |
| 218 | + content={gpu.availability.map((a) => t(`offer.availability_${a}`)).join(', ')} |
| 219 | + > |
| 220 | + <span className={styles.greyText}>{t('offer.availability_not_available')}</span> |
| 221 | + </Popover> |
| 222 | + ); |
210 | 223 | }, |
211 | 224 | width: 50, |
212 | 225 | }, |
|
0 commit comments