Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MS] Update invoice translations #9097

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 35 additions & 8 deletions client/src/components/client-area/InvoicesContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,21 @@
{{ invoice.total }}
</ion-text>
<ion-text class="invoices-year-content-list-item__data invoices-status">
<span class="badge-status body-sm incoming">{{ invoice.status }}</span>
<span
class="badge-status body-sm"
:class="invoice.status"
>
{{ $msTranslate(getInvoiceStatusTranslationKey(invoice.status)) }}
</span>
<a
class="custom-button custom-button-ghost button-medium"
:href="invoice.pdfLink"
download
>
<ion-icon :icon="download" />
<ms-image
:image="downloaded"
class="custom-button__icon"
/>
{{ $msTranslate('clientArea.invoices.cell.download') }}
</a>
</ion-text>
Expand All @@ -77,10 +85,11 @@
</template>

<script setup lang="ts">
import { getInvoiceStatusTranslationKey } from '@/services/translation';
import { BmsInvoice } from '@/services/bms';
import { IonItem, IonList, IonText, IonIcon } from '@ionic/vue';
import { download, chevronDown } from 'ionicons/icons';
import { Translatable, I18n } from 'megashark-lib';
import { chevronDown } from 'ionicons/icons';
import { MsImage, Download as downloaded, Translatable, I18n } from 'megashark-lib';
import { ref } from 'vue';

defineProps<{
Expand Down Expand Up @@ -247,15 +256,33 @@ const isVisible = ref(true);
.badge-status {
border-radius: var(--parsec-radius-32);
padding-inline: 0.5rem;
background: var(--parsec-color-light-secondary-disabled);
color: var(--parsec-color-light-secondary-text);

&.incoming {
&.paid {
background: var(--parsec-color-light-info-100);
color: var(--parsec-color-light-info-700);
}

&.paid {
background: var(--parsec-color-light-success-100);
color: var(--parsec-color-light-success-700);
&.open {
background: var(--parsec-color-tags-orange100);
color: var(--parsec-color-tags-orange500);
}
}

.custom-button {
&__icon {
width: 1rem;
--fill-color: var(--parsec-color-light-primary-500);
}

&:hover {
color: var(--parsec-color-light-primary-600);
background: var(--parsec-color-light-primary-50);

.custom-button__icon {
--fill-color: var(--parsec-color-light-primary-600);
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions client/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,13 @@
"status": "Status",
"download": "Download"
},
"status": {
"paid": "Paid",
"toPay": "To pay",
"draft": "In progress",
"uncollectible": "Uncollectible",
"void": "Void"
},
"retrieveError": "Could not retrieve your invoices."
},
"invoicesCustomOrder": {
Expand Down
7 changes: 7 additions & 0 deletions client/src/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,13 @@
"status": "Status",
"download": "Télécharger"
},
"status": {
"paid": "Payée",
"toPay": "À payer",
"draft": "En cours de création",
"uncollectible": "Impayée",
"void": "Vide"
},
"retrieveError": "Impossible de récupérer la liste des factures."
},
"invoicesCustomOrder": {
Expand Down
16 changes: 16 additions & 0 deletions client/src/services/translation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS

import { InvitationStatus, UserProfile, WorkspaceRole } from '@/parsec';
import { InvoiceStatus } from '@/services/bms';
import { Locale, Translatable } from 'megashark-lib';

export function getProfileTranslationKey(profile: UserProfile): Translatable {
Expand All @@ -14,6 +15,21 @@ export function getProfileTranslationKey(profile: UserProfile): Translatable {
return '';
}

export function getInvoiceStatusTranslationKey(status: InvoiceStatus): Translatable {
switch (status) {
case InvoiceStatus.Paid:
return 'clientArea.invoices.status.paid';
case InvoiceStatus.Draft:
return 'clientArea.invoices.status.draft';
case InvoiceStatus.Open:
return 'clientArea.invoices.status.toPay';
case InvoiceStatus.Uncollectible:
return 'clientArea.invoices.status.uncollectible';
default:
return 'clientArea.invoices.status.void';
}
}

interface WorkspaceRoleTranslations {
label: Translatable;
description?: Translatable;
Expand Down
66 changes: 46 additions & 20 deletions client/src/views/client-area/dashboard/DashboardPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,27 @@
v-for="invoice in invoices"
:key="invoice.id"
>
<ion-text class="invoices-list-item__data invoices-date subtitles-sm">{{ invoice.start.toFormat('LLLL yyyy') }}</ion-text>
<ion-text class="invoices-list-item__data invoices-date subtitles-sm">
{{ $msTranslate(formatTimeSince(invoice.start, '--', 'short')) }}
</ion-text>
<ion-text class="invoices-list-item__data invoices-organization body">{{ invoice.organizationId }}</ion-text>
<ion-text class="invoices-list-item__data invoices-amount body">{{ invoice.total }}</ion-text>
<ion-text class="invoices-list-item__data invoices-status">
<span class="badge-status body-sm incoming">{{ invoice.status }}</span>
<span
class="badge-status body-sm"
:class="invoice.status"
>
{{ $msTranslate(getInvoiceStatusTranslationKey(invoice.status)) }}
</span>
<a
class="custom-button custom-button-ghost button-medium"
:href="invoice.pdfLink"
download
>
<ion-icon :icon="download" />
<ms-image
:image="Download"
class="custom-button__icon"
/>
{{ $msTranslate('clientArea.dashboard.invoices.download') }}
</a>
</ion-text>
Expand Down Expand Up @@ -197,8 +207,8 @@
</template>

<script setup lang="ts">
import { IonTitle, IonText, IonList, IonItem, IonIcon, IonSkeletonText } from '@ionic/vue';
import { download } from 'ionicons/icons';
import { getInvoiceStatusTranslationKey } from '@/services/translation';
import { IonTitle, IonText, IonList, IonItem, IonSkeletonText } from '@ionic/vue';
import { ClientAreaPages, isDefaultOrganization } from '@/views/client-area/types';
import {
BmsAccessInstance,
Expand All @@ -209,7 +219,15 @@ import {
BillingDetailsPaymentMethodCard,
PaymentMethod,
} from '@/services/bms';
import { MsInformationTooltip, I18n, MsStripeCardDetails, PaymentMethod as MsPaymentMethod } from 'megashark-lib';
import {
MsInformationTooltip,
I18n,
MsStripeCardDetails,
PaymentMethod as MsPaymentMethod,
formatTimeSince,
Download,
MsImage,
} from 'megashark-lib';
import { onMounted, ref } from 'vue';
import { formatFileSize } from '@/common/file';
import { DateTime } from 'luxon';
Expand Down Expand Up @@ -333,16 +351,6 @@ onMounted(async () => {
&-text {
color: var(--parsec-color-light-secondary-contrast);
}

&-icon {
color: var(--parsec-color-light-secondary-grey);
font-size: 1.5rem;
cursor: pointer;

&:hover {
color: var(--parsec-color-light-secondary-text);
}
}
}

.data-info {
Expand Down Expand Up @@ -455,15 +463,33 @@ onMounted(async () => {
.badge-status {
border-radius: var(--parsec-radius-32);
padding-inline: 0.5rem;
background: var(--parsec-color-light-secondary-disabled);
color: var(--parsec-color-light-secondary-text);

&.incoming {
&.paid {
background: var(--parsec-color-light-info-100);
color: var(--parsec-color-light-info-700);
}

&.paid {
background: var(--parsec-color-light-success-100);
color: var(--parsec-color-light-success-700);
&.open {
background: var(--parsec-color-tags-orange100);
color: var(--parsec-color-tags-orange500);
}
}

.custom-button {
&__icon {
width: 1rem;
--fill-color: var(--parsec-color-light-primary-500);
}

&:hover {
color: var(--parsec-color-light-primary-600);
background: var(--parsec-color-light-primary-50);

.custom-button__icon {
--fill-color: var(--parsec-color-light-primary-600);
}
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions client/tests/e2e/specs/client_area_dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ msTest('Test dashboard', async ({ clientArea }) => {
const invoices = invoiceContainer.locator('.invoices-list-item');
await expect(invoices).toHaveCount(3);
await expect(invoices.nth(0).locator('.invoices-list-item__data')).toHaveText([
'December 2021',
'Dec 1, 2021',
DEFAULT_ORGANIZATION_INFORMATION.name,
/^\d+$/,
/^(paid|draft|open) Download$/,
/^(Paid|In progress|To pay)\s*Download$/,
]);
await expect(invoices.nth(1).locator('.invoices-list-item__data')).toHaveText([
'November 2021',
'Nov 1, 2021',
DEFAULT_ORGANIZATION_INFORMATION.name,
/^\d+$/,
/^(paid|draft|open) Download$/,
/^(Paid|In progress|To pay)\s*Download$/,
]);
await expect(invoices.nth(2).locator('.invoices-list-item__data')).toHaveText([
'October 2021',
'Oct 1, 2021',
DEFAULT_ORGANIZATION_INFORMATION.name,
/^\d+$/,
/^(paid|draft|open) Download$/,
/^(Paid|In progress|To pay)\s*Download$/,
]);
const paymentButton = clientArea.locator('.payment-container').locator('.custom-button');
await expect(paymentButton).toHaveText('Update');
Expand Down
2 changes: 1 addition & 1 deletion client/tests/e2e/specs/client_area_invoices_page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ msTest('List the invoices', async ({ clientArea }) => {
'2021-12',
DEFAULT_ORGANIZATION_INFORMATION.name,
/^\d+$/,
/^(paid|draft|open) Download$/,
/^(Paid|In progress|To pay)\s*Download$/,
]);
const yearFilterButton = clientArea.locator('.invoices-header-filter').locator('.invoices-header-filter-button').nth(0);
const monthFilterButton = clientArea.locator('.invoices-header-filter').locator('.invoices-header-filter-button').nth(1);
Expand Down
Loading