|
1 | 1 | import { PlanCard as UGPlanCard } from '@appquality/unguess-design-system'; |
| 2 | +import { get } from 'http'; |
| 3 | +import { useTranslation } from 'react-i18next'; |
2 | 4 | import { useNavigate } from 'react-router-dom'; |
3 | 5 | import { GetWorkspacesByWidPlansApiResponse } from 'src/features/api'; |
4 | 6 | import { usePlan } from 'src/hooks/usePlan'; |
5 | 7 | import { usePlanStatusLabel } from 'src/hooks/usePlanStatusLabel'; |
| 8 | +import { PlanComposedStatusType } from 'src/types'; |
6 | 9 |
|
7 | 10 | export const PlanCard = ({ |
8 | 11 | plan, |
9 | 12 | }: { |
10 | 13 | plan: GetWorkspacesByWidPlansApiResponse[number]; |
11 | 14 | }) => { |
12 | 15 | const { planComposedStatus } = usePlan(plan.id.toString()); |
| 16 | + const { t } = useTranslation(); |
13 | 17 | const statusLabel = usePlanStatusLabel({ planStatus: planComposedStatus }); |
14 | 18 | const navigate = useNavigate(); |
15 | 19 | const navigateToPlan = () => { |
16 | 20 | navigate(`/plans/${plan.id}`); |
17 | 21 | }; |
| 22 | + |
| 23 | + const getPlanLabel = (planStatus?: PlanComposedStatusType) => { |
| 24 | + switch (planStatus) { |
| 25 | + case 'PurchasableDraft': |
| 26 | + case 'UnquotedDraft': |
| 27 | + case 'PrequotedDraft': |
| 28 | + return t('_PLAN_CARD_LABEL_FINALIZE'); |
| 29 | + case 'Submitted': |
| 30 | + case 'OpsCheck': |
| 31 | + case 'Paying': |
| 32 | + return t('_PLAN_CARD_LABEL_LOOK'); |
| 33 | + case 'AwaitingPayment': |
| 34 | + case 'AwaitingApproval': |
| 35 | + return t('_PLAN_CARD_LABEL_CONFIRM'); |
| 36 | + default: |
| 37 | + return ''; |
| 38 | + } |
| 39 | + }; |
18 | 40 | return ( |
19 | 41 | <UGPlanCard |
20 | 42 | status={planComposedStatus} |
21 | | - i18n={{ statusLabel }} |
| 43 | + i18n={{ statusLabel, planLabel: getPlanLabel(planComposedStatus) }} |
22 | 44 | onClick={navigateToPlan} |
23 | 45 | > |
24 | 46 | <UGPlanCard.ProjectLabel>{plan.project.title}</UGPlanCard.ProjectLabel> |
|
0 commit comments