@greatapps/common 1.1.671 → 1.1.673
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/layouts/NavBar.mjs +5 -3
- package/dist/components/layouts/NavBar.mjs.map +1 -1
- package/dist/components/layouts/NotificationsPopover.mjs +5 -3
- package/dist/components/layouts/NotificationsPopover.mjs.map +1 -1
- package/dist/components/layouts/ProfilePopover.mjs +6 -4
- package/dist/components/layouts/ProfilePopover.mjs.map +1 -1
- package/dist/components/layouts/UsersSelectorPopover.mjs +9 -7
- package/dist/components/layouts/UsersSelectorPopover.mjs.map +1 -1
- package/dist/components/modals/BuyCreditsModal.mjs +17 -18
- package/dist/components/modals/BuyCreditsModal.mjs.map +1 -1
- package/dist/components/modals/CreditsDisabledModal.mjs +6 -4
- package/dist/components/modals/CreditsDisabledModal.mjs.map +1 -1
- package/dist/components/modals/PaidPlanRequiredModal.mjs +5 -3
- package/dist/components/modals/PaidPlanRequiredModal.mjs.map +1 -1
- package/dist/components/modals/cards/AddCardModal.mjs +27 -24
- package/dist/components/modals/cards/AddCardModal.mjs.map +1 -1
- package/dist/components/modals/cards/CannotDeleteCardModal.mjs +9 -7
- package/dist/components/modals/cards/CannotDeleteCardModal.mjs.map +1 -1
- package/dist/components/modals/cards/CardFormFields.mjs +25 -22
- package/dist/components/modals/cards/CardFormFields.mjs.map +1 -1
- package/dist/components/modals/cards/DeleteCardModal.mjs +10 -8
- package/dist/components/modals/cards/DeleteCardModal.mjs.map +1 -1
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs +4 -2
- package/dist/components/navigation/CancelledSubscriptionBanner.mjs.map +1 -1
- package/dist/components/navigation/OverdueInvoiceBanner.mjs +4 -2
- package/dist/components/navigation/OverdueInvoiceBanner.mjs.map +1 -1
- package/dist/components/navigation/PendingCancellationBanner.mjs +4 -6
- package/dist/components/navigation/PendingCancellationBanner.mjs.map +1 -1
- package/dist/components/navigation/ProjectSelectorPopover.mjs +8 -6
- package/dist/components/navigation/ProjectSelectorPopover.mjs.map +1 -1
- package/dist/components/navigation/UpcomingInvoiceBanner.mjs +4 -6
- package/dist/components/navigation/UpcomingInvoiceBanner.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/BottomLinks.mjs +5 -3
- package/dist/components/navigation/subcomponents/BottomLinks.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/CreditsCard.mjs +3 -1
- package/dist/components/navigation/subcomponents/CreditsCard.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/PlanCard.mjs +3 -1
- package/dist/components/navigation/subcomponents/PlanCard.mjs.map +1 -1
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs +5 -3
- package/dist/components/navigation/subcomponents/ProjectSelector.mjs.map +1 -1
- package/dist/components/pages/NotFoundPage.mjs +5 -3
- package/dist/components/pages/NotFoundPage.mjs.map +1 -1
- package/dist/components/pages/notifications/Notifications.mjs +13 -10
- package/dist/components/pages/notifications/Notifications.mjs.map +1 -1
- package/dist/components/ui/buttons/CopyButton.mjs +9 -5
- package/dist/components/ui/buttons/CopyButton.mjs.map +1 -1
- package/dist/components/ui/data-display/CardItem.mjs +7 -5
- package/dist/components/ui/data-display/CardItem.mjs.map +1 -1
- package/dist/components/ui/data-display/PaymentInfoCard.mjs +10 -8
- package/dist/components/ui/data-display/PaymentInfoCard.mjs.map +1 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs +3 -1
- package/dist/components/ui/feedback/DefaultCircularProgress.mjs.map +1 -1
- package/dist/components/ui/form/ComboboxField.mjs +11 -6
- package/dist/components/ui/form/ComboboxField.mjs.map +1 -1
- package/dist/components/ui/form/DatePicker.mjs +5 -2
- package/dist/components/ui/form/DatePicker.mjs.map +1 -1
- package/dist/components/ui/form/DateRangePicker.mjs +5 -2
- package/dist/components/ui/form/DateRangePicker.mjs.map +1 -1
- package/dist/components/ui/form/PhoneInput.mjs +5 -3
- package/dist/components/ui/form/PhoneInput.mjs.map +1 -1
- package/dist/components/ui/form/SelectField.mjs +6 -3
- package/dist/components/ui/form/SelectField.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageCropModal.mjs +11 -18
- package/dist/components/widgets/ImageUpload/ImageCropModal.mjs.map +1 -1
- package/dist/components/widgets/ImageUpload/ImageTooSmallModal.mjs +6 -15
- package/dist/components/widgets/ImageUpload/ImageTooSmallModal.mjs.map +1 -1
- package/dist/i18n/messages/en-us.mjs +231 -0
- package/dist/i18n/messages/en-us.mjs.map +1 -1
- package/dist/i18n/messages/es-es.mjs +231 -0
- package/dist/i18n/messages/es-es.mjs.map +1 -1
- package/dist/i18n/messages/pt-br.mjs +239 -0
- package/dist/i18n/messages/pt-br.mjs.map +1 -1
- package/dist/modules/cards/hooks/handle-delete-card.hook.mjs +2 -1
- package/dist/modules/cards/hooks/handle-delete-card.hook.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/layouts/NavBar.tsx +5 -3
- package/src/components/layouts/NotificationsPopover.tsx +5 -3
- package/src/components/layouts/ProfilePopover.tsx +6 -4
- package/src/components/layouts/UsersSelectorPopover.tsx +9 -7
- package/src/components/modals/BuyCreditsModal.tsx +18 -16
- package/src/components/modals/CreditsDisabledModal.tsx +6 -6
- package/src/components/modals/PaidPlanRequiredModal.tsx +5 -3
- package/src/components/modals/cards/AddCardModal.tsx +29 -27
- package/src/components/modals/cards/CannotDeleteCardModal.tsx +9 -8
- package/src/components/modals/cards/CardFormFields.tsx +25 -22
- package/src/components/modals/cards/DeleteCardModal.tsx +10 -8
- package/src/components/navigation/CancelledSubscriptionBanner.tsx +4 -2
- package/src/components/navigation/OverdueInvoiceBanner.tsx +4 -2
- package/src/components/navigation/PendingCancellationBanner.tsx +4 -2
- package/src/components/navigation/ProjectSelectorPopover.tsx +8 -6
- package/src/components/navigation/UpcomingInvoiceBanner.tsx +4 -2
- package/src/components/navigation/subcomponents/BottomLinks.tsx +5 -3
- package/src/components/navigation/subcomponents/CreditsCard.tsx +3 -1
- package/src/components/navigation/subcomponents/PlanCard.tsx +3 -1
- package/src/components/navigation/subcomponents/ProjectSelector.tsx +5 -3
- package/src/components/pages/NotFoundPage.tsx +5 -3
- package/src/components/pages/notifications/Notifications.tsx +13 -10
- package/src/components/ui/buttons/CopyButton.tsx +10 -5
- package/src/components/ui/data-display/CardItem.tsx +7 -5
- package/src/components/ui/data-display/PaymentInfoCard.tsx +10 -8
- package/src/components/ui/feedback/DefaultCircularProgress.tsx +3 -1
- package/src/components/ui/form/ComboboxField.tsx +11 -6
- package/src/components/ui/form/DatePicker.tsx +5 -2
- package/src/components/ui/form/DateRangePicker.tsx +5 -2
- package/src/components/ui/form/PhoneInput.tsx +5 -3
- package/src/components/ui/form/SelectField.tsx +6 -3
- package/src/components/widgets/ImageUpload/ImageCropModal.tsx +19 -11
- package/src/components/widgets/ImageUpload/ImageTooSmallModal.tsx +6 -5
- package/src/i18n/messages/en-us.ts +234 -0
- package/src/i18n/messages/es-es.ts +234 -0
- package/src/i18n/messages/pt-br.ts +248 -0
- package/src/modules/cards/hooks/handle-delete-card.hook.ts +8 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
import { useTranslations } from "next-intl";
|
|
4
5
|
import { IconPlus, IconUser, IconUsers } from '@tabler/icons-react';
|
|
5
6
|
import { UserAvatar } from "../ui/data-display/UserAvatar";
|
|
6
7
|
import { Popover, PopoverContent, PopoverTrigger } from "../ui/overlay/Popover";
|
|
@@ -46,6 +47,7 @@ export function UsersSelectorPopover({
|
|
|
46
47
|
align,
|
|
47
48
|
contentClassName,
|
|
48
49
|
}: UsersSelectorPopoverProps) {
|
|
50
|
+
const translate = useTranslations();
|
|
49
51
|
const { accountsUrl } = useWhitelabelUrls();
|
|
50
52
|
const [open, setOpen] = useState(false);
|
|
51
53
|
const [hoveredId, setHoveredId] = useState<number | null>(null);
|
|
@@ -108,7 +110,7 @@ export function UsersSelectorPopover({
|
|
|
108
110
|
>
|
|
109
111
|
<div className="flex flex-col p-3 gap-2">
|
|
110
112
|
<div className="flex items-center justify-between">
|
|
111
|
-
<span className="paragraph-small-semibold">
|
|
113
|
+
<span className="paragraph-small-semibold">{translate('common.layout.usersSelector.title')}</span>
|
|
112
114
|
<div className="flex items-center gap-1.5">
|
|
113
115
|
<Button
|
|
114
116
|
variant="secondary"
|
|
@@ -118,14 +120,14 @@ export function UsersSelectorPopover({
|
|
|
118
120
|
}}
|
|
119
121
|
>
|
|
120
122
|
<IconPlus size={16} />
|
|
121
|
-
|
|
123
|
+
{translate('common.layout.usersSelector.add')}
|
|
122
124
|
</Button>
|
|
123
125
|
</div>
|
|
124
126
|
</div>
|
|
125
127
|
|
|
126
128
|
<Command shouldFilter={false} className="gap-2" value="">
|
|
127
129
|
<CommandInput
|
|
128
|
-
placeholder=
|
|
130
|
+
placeholder={translate('common.layout.usersSelector.searchPlaceholder')}
|
|
129
131
|
value={searchInput}
|
|
130
132
|
onValueChange={setSearchInput}
|
|
131
133
|
/>
|
|
@@ -143,12 +145,12 @@ export function UsersSelectorPopover({
|
|
|
143
145
|
<div className="flex flex-col items-center justify-center gap-2 h-full text-gray-400 py-4">
|
|
144
146
|
<IconUsers size={28} className="text-gray-300" />
|
|
145
147
|
<span className="paragraph-small-medium text-center text-gray-500">
|
|
146
|
-
|
|
148
|
+
{translate('common.layout.usersSelector.empty')}
|
|
147
149
|
</span>
|
|
148
150
|
</div>
|
|
149
151
|
) : (
|
|
150
152
|
<>
|
|
151
|
-
<CommandEmpty>
|
|
153
|
+
<CommandEmpty>{translate('common.layout.usersSelector.noResults')}</CommandEmpty>
|
|
152
154
|
{allUsers.map((user) => {
|
|
153
155
|
const inProject = user.in_project ?? false;
|
|
154
156
|
const removable =
|
|
@@ -200,7 +202,7 @@ export function UsersSelectorPopover({
|
|
|
200
202
|
</div>
|
|
201
203
|
</TooltipTrigger>
|
|
202
204
|
<TooltipContent className="z-[1002]">
|
|
203
|
-
{inProject ?
|
|
205
|
+
{inProject ? translate('common.layout.usersSelector.removeFromProject') : translate('common.layout.usersSelector.addToProject')}
|
|
204
206
|
</TooltipContent>
|
|
205
207
|
</Tooltip>
|
|
206
208
|
</div>
|
|
@@ -225,7 +227,7 @@ export function UsersSelectorPopover({
|
|
|
225
227
|
window.location.href = `${accountsUrl}/my-teams`;
|
|
226
228
|
}}
|
|
227
229
|
>
|
|
228
|
-
|
|
230
|
+
{translate('common.layout.usersSelector.manageTeam')}
|
|
229
231
|
</Button>
|
|
230
232
|
</div>
|
|
231
233
|
</PopoverContent>
|
|
@@ -26,6 +26,7 @@ import { useUpdateSubscriptionPlan } from '../../modules/subscriptions/hooks/upd
|
|
|
26
26
|
import { getPriceFromCalculatedData } from '../../modules/subscriptions/utils/periodicity';
|
|
27
27
|
import { useIsDefaultWhitelabel, useExternalContracting } from '../../providers/whitelabel.provider';
|
|
28
28
|
import { IconInfoCircle, IconX, IconLoader2, IconSparkles } from '@tabler/icons-react';
|
|
29
|
+
import { useTranslations } from 'next-intl';
|
|
29
30
|
import { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
30
31
|
import { useForm } from 'react-hook-form';
|
|
31
32
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
@@ -42,6 +43,7 @@ const buyCreditSchema = z.object({
|
|
|
42
43
|
type BuyCreditFormData = z.infer<typeof buyCreditSchema>;
|
|
43
44
|
|
|
44
45
|
export default function BuyCreditsModal() {
|
|
46
|
+
const translate = useTranslations();
|
|
45
47
|
const { open, closeModal } = useBuyCreditsModal();
|
|
46
48
|
const { openModal } = useModalManager();
|
|
47
49
|
const isDefaultWl = useIsDefaultWhitelabel();
|
|
@@ -186,12 +188,12 @@ export default function BuyCreditsModal() {
|
|
|
186
188
|
label: (
|
|
187
189
|
<div className="flex items-center justify-between gap-2 w-full">
|
|
188
190
|
<span className="paragraph-small-medium text-zinc-950 flex-1">
|
|
189
|
-
{opt.credits.toLocaleString('pt-BR')}
|
|
191
|
+
{translate('common.credits.buy.creditsOptionLabel', { credits: opt.credits.toLocaleString('pt-BR') })}
|
|
190
192
|
</span>
|
|
191
193
|
<span className="paragraph-small-medium text-zinc-500 opacity-70">{opt.priceLabel}</span>
|
|
192
194
|
</div>
|
|
193
195
|
),
|
|
194
|
-
displayValue:
|
|
196
|
+
displayValue: translate('common.credits.buy.creditsOptionDisplayValue', { credits: opt.credits.toLocaleString('pt-BR') }),
|
|
195
197
|
}));
|
|
196
198
|
}, []);
|
|
197
199
|
|
|
@@ -217,7 +219,7 @@ export default function BuyCreditsModal() {
|
|
|
217
219
|
toast.custom((t) => (
|
|
218
220
|
<Toast
|
|
219
221
|
variant="success"
|
|
220
|
-
message={
|
|
222
|
+
message={translate('common.credits.buy.creditsChangedToast', { credits: data.creditOption.toLocaleString('pt-BR') })}
|
|
221
223
|
toastId={t}
|
|
222
224
|
/>
|
|
223
225
|
));
|
|
@@ -234,7 +236,7 @@ export default function BuyCreditsModal() {
|
|
|
234
236
|
if (totalPrice !== null) {
|
|
235
237
|
return (
|
|
236
238
|
<span className="paragraph-xlarge-semibold text-zinc-950">
|
|
237
|
-
{totalPrice === 0 ? '
|
|
239
|
+
{totalPrice === 0 ? translate('common.credits.buy.defaultPrice') : formatPrice(totalPrice)}
|
|
238
240
|
</span>
|
|
239
241
|
);
|
|
240
242
|
}
|
|
@@ -251,10 +253,10 @@ export default function BuyCreditsModal() {
|
|
|
251
253
|
</div>
|
|
252
254
|
<div className="flex flex-col gap-2">
|
|
253
255
|
<DialogTitle className="paragraph-medium-semibold text-zinc-950">
|
|
254
|
-
|
|
256
|
+
{translate('common.credits.buy.externalTitle')}
|
|
255
257
|
</DialogTitle>
|
|
256
258
|
<span className="paragraph-small-regular text-zinc-600">
|
|
257
|
-
|
|
259
|
+
{translate('common.credits.buy.externalDescription')}
|
|
258
260
|
</span>
|
|
259
261
|
</div>
|
|
260
262
|
</DialogHeader>
|
|
@@ -266,7 +268,7 @@ export default function BuyCreditsModal() {
|
|
|
266
268
|
redirectToExternal('contracting');
|
|
267
269
|
}}
|
|
268
270
|
>
|
|
269
|
-
|
|
271
|
+
{translate('common.credits.buy.externalButton')}
|
|
270
272
|
</Button>
|
|
271
273
|
</div>
|
|
272
274
|
</DialogContent>
|
|
@@ -282,7 +284,7 @@ export default function BuyCreditsModal() {
|
|
|
282
284
|
>
|
|
283
285
|
<DialogHeader className="px-4 py-3 border-b border-zinc-200 shrink-0 relative">
|
|
284
286
|
<DialogTitle className="paragraph-medium-semibold text-zinc-950 text-center">
|
|
285
|
-
|
|
287
|
+
{translate('common.credits.buy.title')}
|
|
286
288
|
</DialogTitle>
|
|
287
289
|
<button
|
|
288
290
|
type="button"
|
|
@@ -319,8 +321,8 @@ export default function BuyCreditsModal() {
|
|
|
319
321
|
<IconInfoCircle className="size-4 text-zinc-950 shrink-0" />
|
|
320
322
|
<span className="paragraph-small-regular text-zinc-950">
|
|
321
323
|
{isIncreasingCredits
|
|
322
|
-
? '
|
|
323
|
-
: '
|
|
324
|
+
? translate('common.credits.buy.paymentOnConfirm')
|
|
325
|
+
: translate('common.credits.buy.nextInvoiceChanges')}
|
|
324
326
|
</span>
|
|
325
327
|
</div>
|
|
326
328
|
)}
|
|
@@ -331,7 +333,7 @@ export default function BuyCreditsModal() {
|
|
|
331
333
|
<div className="hidden lg:flex flex-col gap-2">
|
|
332
334
|
{immediateChargeTotal !== null && immediateChargeTotal > 0 && (
|
|
333
335
|
<div className="flex items-center justify-between">
|
|
334
|
-
<span className="paragraph-xsmall-medium text-zinc-500">
|
|
336
|
+
<span className="paragraph-xsmall-medium text-zinc-500">{translate('common.credits.buy.immediateCharge')}</span>
|
|
335
337
|
{isCalculatePending ? (
|
|
336
338
|
<Skeleton className="h-5 w-20" />
|
|
337
339
|
) : (
|
|
@@ -342,7 +344,7 @@ export default function BuyCreditsModal() {
|
|
|
342
344
|
</div>
|
|
343
345
|
)}
|
|
344
346
|
<div className="flex items-center justify-between">
|
|
345
|
-
<span className="paragraph-small-medium text-zinc-500">
|
|
347
|
+
<span className="paragraph-small-medium text-zinc-500">{translate('common.credits.buy.totalPlanValue')}</span>
|
|
346
348
|
{renderPriceDisplay()}
|
|
347
349
|
</div>
|
|
348
350
|
</div>
|
|
@@ -353,7 +355,7 @@ export default function BuyCreditsModal() {
|
|
|
353
355
|
className="w-full hidden lg:inline-flex"
|
|
354
356
|
>
|
|
355
357
|
{isSubmitting && <IconLoader2 className="size-4 animate-spin" />}
|
|
356
|
-
|
|
358
|
+
{translate('common.credits.buy.confirmAndPay')}
|
|
357
359
|
</Button>
|
|
358
360
|
</div>
|
|
359
361
|
|
|
@@ -361,7 +363,7 @@ export default function BuyCreditsModal() {
|
|
|
361
363
|
<div className="flex flex-col gap-2">
|
|
362
364
|
{immediateChargeTotal !== null && immediateChargeTotal > 0 && (
|
|
363
365
|
<div className="flex items-center justify-between">
|
|
364
|
-
<span className="paragraph-xsmall-medium text-zinc-500">
|
|
366
|
+
<span className="paragraph-xsmall-medium text-zinc-500">{translate('common.credits.buy.immediateCharge')}</span>
|
|
365
367
|
{isCalculatePending ? (
|
|
366
368
|
<Skeleton className="h-5 w-20" />
|
|
367
369
|
) : (
|
|
@@ -372,13 +374,13 @@ export default function BuyCreditsModal() {
|
|
|
372
374
|
</div>
|
|
373
375
|
)}
|
|
374
376
|
<div className="flex items-center justify-between">
|
|
375
|
-
<span className="paragraph-small-medium text-zinc-500">
|
|
377
|
+
<span className="paragraph-small-medium text-zinc-500">{translate('common.credits.buy.totalPlanValue')}</span>
|
|
376
378
|
{renderPriceDisplay()}
|
|
377
379
|
</div>
|
|
378
380
|
</div>
|
|
379
381
|
<Button type="submit" disabled={isConfirmDisabled} className="w-full">
|
|
380
382
|
{isSubmitting && <IconLoader2 className="size-4 animate-spin" />}
|
|
381
|
-
|
|
383
|
+
{translate('common.credits.buy.confirmAndPay')}
|
|
382
384
|
</Button>
|
|
383
385
|
</div>
|
|
384
386
|
</form>
|
|
@@ -10,9 +10,11 @@ import {
|
|
|
10
10
|
import { Button } from '../ui/buttons/Button';
|
|
11
11
|
import { Separator } from '../ui/data-display/Separator';
|
|
12
12
|
import { IconAlertTriangle } from '@tabler/icons-react';
|
|
13
|
+
import { useTranslations } from 'next-intl';
|
|
13
14
|
import { useCreditsDisabledModal } from '../../store/useCreditsDisabledModal';
|
|
14
15
|
|
|
15
16
|
export default function CreditsDisabledModal() {
|
|
17
|
+
const translate = useTranslations();
|
|
16
18
|
const { open, closeModal } = useCreditsDisabledModal();
|
|
17
19
|
|
|
18
20
|
return (
|
|
@@ -32,14 +34,12 @@ export default function CreditsDisabledModal() {
|
|
|
32
34
|
</div>
|
|
33
35
|
<div className="flex flex-col gap-2">
|
|
34
36
|
<DialogTitle className="paragraph-medium-semibold text-zinc-950">
|
|
35
|
-
|
|
37
|
+
{translate('common.credits.disabled.title')}
|
|
36
38
|
</DialogTitle>
|
|
37
39
|
<DialogDescription className="paragraph-small-regular text-zinc-600" asChild>
|
|
38
40
|
<div className="flex flex-col gap-3">
|
|
39
|
-
<p>
|
|
40
|
-
<p>
|
|
41
|
-
Peça a um administrador ou proprietário da conta para adquirir mais créditos.
|
|
42
|
-
</p>
|
|
41
|
+
<p>{translate('common.credits.disabled.descriptionLine1')}</p>
|
|
42
|
+
<p>{translate('common.credits.disabled.descriptionLine2')}</p>
|
|
43
43
|
</div>
|
|
44
44
|
</DialogDescription>
|
|
45
45
|
</div>
|
|
@@ -53,7 +53,7 @@ export default function CreditsDisabledModal() {
|
|
|
53
53
|
className="h-10! transition-colors"
|
|
54
54
|
onClick={() => closeModal()}
|
|
55
55
|
>
|
|
56
|
-
|
|
56
|
+
{translate('common.credits.disabled.understood')}
|
|
57
57
|
</Button>
|
|
58
58
|
</div>
|
|
59
59
|
</DialogContent>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { IconLock } from '@tabler/icons-react';
|
|
4
|
+
import { useTranslations } from 'next-intl';
|
|
4
5
|
import { Button } from '../ui/buttons/Button';
|
|
5
6
|
import {
|
|
6
7
|
Dialog,
|
|
@@ -14,14 +15,15 @@ import { useModalManager } from '../../store/useModalManager';
|
|
|
14
15
|
import type { ModalData } from '../../store/useModalManager';
|
|
15
16
|
|
|
16
17
|
export default function PaidPlanRequiredModal() {
|
|
18
|
+
const translate = useTranslations();
|
|
17
19
|
const { activeModal, modalData, closeModal } = useModalManager();
|
|
18
20
|
const isOpen = activeModal === 'paidPlanRequiredModal';
|
|
19
21
|
const data = modalData as ModalData & { title?: string; description?: string };
|
|
20
22
|
const { accountsUrl } = useWhitelabelUrls();
|
|
21
23
|
const { redirectToExternal } = useExternalContracting();
|
|
22
24
|
|
|
23
|
-
const title = (data.title as string) ??
|
|
24
|
-
const description = (data.description as string) ??
|
|
25
|
+
const title = (data.title as string) ?? translate('common.credits.paidPlanRequired.defaultTitle');
|
|
26
|
+
const description = (data.description as string) ?? translate('common.credits.paidPlanRequired.defaultDescription');
|
|
25
27
|
|
|
26
28
|
const handleKnowPlans = () => {
|
|
27
29
|
if (redirectToExternal('plans')) return;
|
|
@@ -49,7 +51,7 @@ export default function PaidPlanRequiredModal() {
|
|
|
49
51
|
className="w-fit h-10!"
|
|
50
52
|
onClick={handleKnowPlans}
|
|
51
53
|
>
|
|
52
|
-
|
|
54
|
+
{translate('common.credits.paidPlanRequired.knowPlans')}
|
|
53
55
|
</Button>
|
|
54
56
|
</div>
|
|
55
57
|
</DialogContent>
|
|
@@ -17,6 +17,7 @@ import { useForm } from 'react-hook-form';
|
|
|
17
17
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
18
18
|
import { CardNumberElement, useElements, useStripe } from '@stripe/react-stripe-js';
|
|
19
19
|
import { toast } from 'sonner';
|
|
20
|
+
import { useTranslations } from 'next-intl';
|
|
20
21
|
|
|
21
22
|
const INITIAL_STRIPE_STATUS: StripeElementsStatus = {
|
|
22
23
|
cardNumber: false,
|
|
@@ -24,15 +25,15 @@ const INITIAL_STRIPE_STATUS: StripeElementsStatus = {
|
|
|
24
25
|
cardCvc: false,
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
const STEPS = [
|
|
28
|
-
{ number: 1, label: 'Cobrança' },
|
|
29
|
-
{ number: 2, label: 'Cartão' },
|
|
30
|
-
] as const;
|
|
31
|
-
|
|
32
28
|
function CardStepper({ currentStep }: { readonly currentStep: number }) {
|
|
29
|
+
const translate = useTranslations();
|
|
30
|
+
const steps = [
|
|
31
|
+
{ number: 1, label: translate('common.cards.add.stepBilling') },
|
|
32
|
+
{ number: 2, label: translate('common.cards.add.stepCard') },
|
|
33
|
+
];
|
|
33
34
|
return (
|
|
34
35
|
<div className="flex items-center justify-start gap-2 px-4 py-3 bg-zinc-50 border-b border-zinc-200 lg:border-b-0">
|
|
35
|
-
{
|
|
36
|
+
{steps.map((step, idx) => {
|
|
36
37
|
const isCompleted = currentStep > step.number;
|
|
37
38
|
const isCurrent = currentStep === step.number;
|
|
38
39
|
const isPending = !isCompleted && !isCurrent;
|
|
@@ -61,7 +62,7 @@ function CardStepper({ currentStep }: { readonly currentStep: number }) {
|
|
|
61
62
|
>
|
|
62
63
|
{step.label}
|
|
63
64
|
</span>
|
|
64
|
-
{idx <
|
|
65
|
+
{idx < steps.length - 1 && (
|
|
65
66
|
<IconChevronRight size={16} className="text-zinc-300 ml-1" />
|
|
66
67
|
)}
|
|
67
68
|
</div>
|
|
@@ -72,6 +73,7 @@ function CardStepper({ currentStep }: { readonly currentStep: number }) {
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
export default function AddCardModal() {
|
|
76
|
+
const translate = useTranslations();
|
|
75
77
|
const { activeModal, modalData, closeModal } = useModalManager();
|
|
76
78
|
const isOpen = activeModal === 'addCardModal';
|
|
77
79
|
const { isExternalContracting, redirectToExternal } = useExternalContracting();
|
|
@@ -137,9 +139,9 @@ export default function AddCardModal() {
|
|
|
137
139
|
|
|
138
140
|
async function handleSubmit(data: CardFormData) {
|
|
139
141
|
const newStripeErrors: Record<string, string | undefined> = {};
|
|
140
|
-
if (!stripeStatus.cardNumber) newStripeErrors.cardNumber = '
|
|
141
|
-
if (!stripeStatus.cardExpiry) newStripeErrors.cardExpiry = '
|
|
142
|
-
if (!stripeStatus.cardCvc) newStripeErrors.cardCvc = '
|
|
142
|
+
if (!stripeStatus.cardNumber) newStripeErrors.cardNumber = translate('common.cards.form.cardNumberRequired');
|
|
143
|
+
if (!stripeStatus.cardExpiry) newStripeErrors.cardExpiry = translate('common.cards.form.cardExpiryRequired');
|
|
144
|
+
if (!stripeStatus.cardCvc) newStripeErrors.cardCvc = translate('common.cards.form.cardCvcRequired');
|
|
143
145
|
setStripeErrors(newStripeErrors);
|
|
144
146
|
|
|
145
147
|
const stripeValid =
|
|
@@ -159,7 +161,7 @@ export default function AddCardModal() {
|
|
|
159
161
|
(t) => (
|
|
160
162
|
<Toast
|
|
161
163
|
variant="error"
|
|
162
|
-
message=
|
|
164
|
+
message={translate('common.cards.add.errorInitAuth')}
|
|
163
165
|
toastId={t}
|
|
164
166
|
/>
|
|
165
167
|
),
|
|
@@ -180,7 +182,7 @@ export default function AddCardModal() {
|
|
|
180
182
|
(t) => (
|
|
181
183
|
<Toast
|
|
182
184
|
variant="error"
|
|
183
|
-
message={error.message || '
|
|
185
|
+
message={error.message || translate('common.cards.add.errorAuth')}
|
|
184
186
|
toastId={t}
|
|
185
187
|
/>
|
|
186
188
|
),
|
|
@@ -194,7 +196,7 @@ export default function AddCardModal() {
|
|
|
194
196
|
(t) => (
|
|
195
197
|
<Toast
|
|
196
198
|
variant="error"
|
|
197
|
-
message={
|
|
199
|
+
message={translate('common.cards.add.errorAuthStatus', { status: setupIntent?.status ?? translate('common.cards.add.statusUnknown') })}
|
|
198
200
|
toastId={t}
|
|
199
201
|
/>
|
|
200
202
|
),
|
|
@@ -229,7 +231,7 @@ export default function AddCardModal() {
|
|
|
229
231
|
}
|
|
230
232
|
|
|
231
233
|
toast.custom(
|
|
232
|
-
(t) => <Toast variant="success" message=
|
|
234
|
+
(t) => <Toast variant="success" message={translate('common.cards.add.successToast')} toastId={t} />,
|
|
233
235
|
{ duration: 5000 }
|
|
234
236
|
);
|
|
235
237
|
handleClose();
|
|
@@ -238,7 +240,7 @@ export default function AddCardModal() {
|
|
|
238
240
|
(t) => (
|
|
239
241
|
<Toast
|
|
240
242
|
variant="error"
|
|
241
|
-
message=
|
|
243
|
+
message={translate('common.cards.add.errorSave')}
|
|
242
244
|
toastId={t}
|
|
243
245
|
/>
|
|
244
246
|
),
|
|
@@ -283,10 +285,10 @@ export default function AddCardModal() {
|
|
|
283
285
|
</div>
|
|
284
286
|
<div className="flex flex-col gap-2">
|
|
285
287
|
<DialogTitle className="paragraph-medium-semibold text-zinc-950">
|
|
286
|
-
|
|
288
|
+
{translate('common.cards.add.externalTitle')}
|
|
287
289
|
</DialogTitle>
|
|
288
290
|
<span className="paragraph-small-regular text-zinc-600">
|
|
289
|
-
|
|
291
|
+
{translate('common.cards.add.externalDescription')}
|
|
290
292
|
</span>
|
|
291
293
|
</div>
|
|
292
294
|
</DialogHeader>
|
|
@@ -298,7 +300,7 @@ export default function AddCardModal() {
|
|
|
298
300
|
redirectToExternal('contracting');
|
|
299
301
|
}}
|
|
300
302
|
>
|
|
301
|
-
|
|
303
|
+
{translate('common.cards.add.externalButton')}
|
|
302
304
|
</Button>
|
|
303
305
|
</div>
|
|
304
306
|
</DialogContent>
|
|
@@ -315,7 +317,7 @@ export default function AddCardModal() {
|
|
|
315
317
|
<DialogHeader className="p-0">
|
|
316
318
|
<div className="flex items-center justify-center px-4 py-3 relative border-b border-zinc-200 lg:border-b-0">
|
|
317
319
|
<DialogTitle className="paragraph-medium-semibold text-zinc-950 text-center">
|
|
318
|
-
|
|
320
|
+
{translate('common.cards.add.title')}
|
|
319
321
|
</DialogTitle>
|
|
320
322
|
<Button
|
|
321
323
|
type="button"
|
|
@@ -336,13 +338,13 @@ export default function AddCardModal() {
|
|
|
336
338
|
>
|
|
337
339
|
<div className={`flex flex-col gap-6 lg:gap-8 p-4 lg:p-5 flex-1 lg:flex-none ${currentStep !== 1 ? 'hidden' : ''}`}>
|
|
338
340
|
<h2 className="font-[family-name:var(--font-outfit)] text-[18px] leading-tight font-semibold text-zinc-950">
|
|
339
|
-
|
|
341
|
+
{translate('common.cards.add.billingHeading')}
|
|
340
342
|
</h2>
|
|
341
343
|
<BillingFormFields form={form} />
|
|
342
344
|
</div>
|
|
343
345
|
<div className={`flex flex-col gap-6 lg:gap-8 p-4 lg:p-5 flex-1 lg:flex-none ${currentStep !== 2 ? 'hidden' : ''}`}>
|
|
344
346
|
<h2 className="font-[family-name:var(--font-outfit)] text-[18px] leading-tight font-semibold text-zinc-950">
|
|
345
|
-
|
|
347
|
+
{translate('common.cards.add.cardHeading')}
|
|
346
348
|
</h2>
|
|
347
349
|
<CardFormFields
|
|
348
350
|
form={form}
|
|
@@ -355,7 +357,7 @@ export default function AddCardModal() {
|
|
|
355
357
|
{currentStep === 1 ? (
|
|
356
358
|
<>
|
|
357
359
|
<Button variant="secondary" type="button" onClick={handleClose} className="h-10!">
|
|
358
|
-
|
|
360
|
+
{translate('common.actions.cancel')}
|
|
359
361
|
</Button>
|
|
360
362
|
<Button
|
|
361
363
|
type="button"
|
|
@@ -363,13 +365,13 @@ export default function AddCardModal() {
|
|
|
363
365
|
onClick={handleContinue}
|
|
364
366
|
disabled={!isBillingValid}
|
|
365
367
|
>
|
|
366
|
-
|
|
368
|
+
{translate('common.actions.continue')}
|
|
367
369
|
</Button>
|
|
368
370
|
</>
|
|
369
371
|
) : (
|
|
370
372
|
<>
|
|
371
373
|
<Button variant="secondary" type="button" onClick={handleBack} className="h-10!">
|
|
372
|
-
|
|
374
|
+
{translate('common.actions.back')}
|
|
373
375
|
</Button>
|
|
374
376
|
<Button
|
|
375
377
|
type="submit"
|
|
@@ -378,10 +380,10 @@ export default function AddCardModal() {
|
|
|
378
380
|
loading={isAuthenticating || isSubmitting}
|
|
379
381
|
>
|
|
380
382
|
{isAuthenticating
|
|
381
|
-
? '
|
|
383
|
+
? translate('common.cards.add.authenticating')
|
|
382
384
|
: isSubmitting
|
|
383
|
-
? '
|
|
384
|
-
: '
|
|
385
|
+
? translate('common.cards.add.submitting')
|
|
386
|
+
: translate('common.cards.add.submit')}
|
|
385
387
|
</Button>
|
|
386
388
|
</>
|
|
387
389
|
)}
|
|
@@ -12,8 +12,10 @@ import { useCards } from '../../../modules/cards/hooks/cards.hook';
|
|
|
12
12
|
import { useActiveSubscription } from '../../../modules/subscriptions/hooks/find-active-subscription.hook';
|
|
13
13
|
import { useUpdateSubscriptionPayment } from '../../../modules/subscriptions/hooks/update-subscription-payment.hook';
|
|
14
14
|
import type { Card } from '../../../modules/cards/types';
|
|
15
|
+
import { useTranslations } from 'next-intl';
|
|
15
16
|
|
|
16
17
|
export function CannotDeleteCardModal() {
|
|
18
|
+
const translate = useTranslations();
|
|
17
19
|
const { activeModal, modalData, closeModal, openModal } = useModalManager();
|
|
18
20
|
const { data: cardsData } = useCards();
|
|
19
21
|
const { mutateAsync: updatePayment } = useUpdateSubscriptionPayment();
|
|
@@ -49,7 +51,7 @@ export function CannotDeleteCardModal() {
|
|
|
49
51
|
message={
|
|
50
52
|
error instanceof Error
|
|
51
53
|
? error.message
|
|
52
|
-
: '
|
|
54
|
+
: translate('common.cards.cannotDelete.errorUpdateCard')
|
|
53
55
|
}
|
|
54
56
|
toastId={t}
|
|
55
57
|
/>
|
|
@@ -69,7 +71,7 @@ export function CannotDeleteCardModal() {
|
|
|
69
71
|
return (
|
|
70
72
|
<Dialog open={isOpen} onOpenChange={(open) => !open && closeModal()}>
|
|
71
73
|
<DialogTitle className="sr-only">
|
|
72
|
-
|
|
74
|
+
{translate('common.cards.cannotDelete.title')}
|
|
73
75
|
</DialogTitle>
|
|
74
76
|
<DialogContent className="flex flex-col p-0 max-w-full sm:max-w-full border-0 rounded-t-2xl rounded-b-none h-dvh top-0 bottom-0 left-0 right-0 translate-x-0 translate-y-0 lg:max-w-[436px] lg:h-auto lg:max-h-[90vh] lg:rounded-lg lg:border lg:top-[50%] lg:left-[50%] lg:right-auto lg:bottom-auto lg:translate-x-[-50%] lg:translate-y-[-50%] overflow-hidden">
|
|
75
77
|
<div className="flex flex-col gap-5 p-4 lg:p-5">
|
|
@@ -79,11 +81,10 @@ export function CannotDeleteCardModal() {
|
|
|
79
81
|
|
|
80
82
|
<div className="flex flex-col gap-2">
|
|
81
83
|
<h2 className="paragraph-medium-semibold text-zinc-950">
|
|
82
|
-
|
|
84
|
+
{translate('common.cards.cannotDelete.title')}
|
|
83
85
|
</h2>
|
|
84
86
|
<p className="paragraph-small-regular text-zinc-600">
|
|
85
|
-
|
|
86
|
-
Selecione outro cartão como padrão ou adicione um novo.
|
|
87
|
+
{translate('common.cards.cannotDelete.description')}
|
|
87
88
|
</p>
|
|
88
89
|
</div>
|
|
89
90
|
</div>
|
|
@@ -91,7 +92,7 @@ export function CannotDeleteCardModal() {
|
|
|
91
92
|
{availableCards.length > 0 && (
|
|
92
93
|
<div className="flex flex-col gap-3 px-4 lg:px-5 pb-4 lg:pb-5 overflow-y-auto max-h-[200px] flex-1 lg:flex-none">
|
|
93
94
|
<span className="paragraph-xsmall-semibold text-zinc-600">
|
|
94
|
-
|
|
95
|
+
{translate('common.cards.cannotDelete.selectDefault')}
|
|
95
96
|
</span>
|
|
96
97
|
{availableCards.map((card) => (
|
|
97
98
|
<CardItem
|
|
@@ -107,14 +108,14 @@ export function CannotDeleteCardModal() {
|
|
|
107
108
|
<div className="flex flex-row gap-2 p-4 lg:p-5 border-t border-zinc-200 mt-auto lg:mt-0">
|
|
108
109
|
<Button onClick={handleAddCard} className="h-10! flex-1">
|
|
109
110
|
<IconPlus size={20} />
|
|
110
|
-
|
|
111
|
+
{translate('common.cards.cannotDelete.addNewCard')}
|
|
111
112
|
</Button>
|
|
112
113
|
<Button
|
|
113
114
|
variant="secondary"
|
|
114
115
|
onClick={() => closeModal()}
|
|
115
116
|
className="h-10! flex-1"
|
|
116
117
|
>
|
|
117
|
-
|
|
118
|
+
{translate('common.actions.cancel')}
|
|
118
119
|
</Button>
|
|
119
120
|
</div>
|
|
120
121
|
</DialogContent>
|