@greatapps/common 1.1.762 → 1.1.764
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/modals/billing/RequiredBillingDataModal.mjs +139 -129
- package/dist/components/modals/billing/RequiredBillingDataModal.mjs.map +1 -1
- package/dist/components/ui/overlay/Dialog.mjs +21 -3
- package/dist/components/ui/overlay/Dialog.mjs.map +1 -1
- package/dist/i18n/messages/en-us.mjs +1 -0
- package/dist/i18n/messages/en-us.mjs.map +1 -1
- package/dist/i18n/messages/es-es.mjs +1 -0
- package/dist/i18n/messages/es-es.mjs.map +1 -1
- package/dist/i18n/messages/pt-br.mjs +1 -0
- package/dist/i18n/messages/pt-br.mjs.map +1 -1
- package/dist/middlewares/chain.mjs +10 -1
- package/dist/middlewares/chain.mjs.map +1 -1
- package/dist/modules/subscriptions/types/subscription.type.mjs +9 -6
- package/dist/modules/subscriptions/types/subscription.type.mjs.map +1 -1
- package/dist/utils/geo-country.mjs +16 -0
- package/dist/utils/geo-country.mjs.map +1 -0
- package/package.json +1 -1
- package/src/components/modals/billing/RequiredBillingDataModal.tsx +163 -144
- package/src/components/ui/overlay/Dialog.tsx +29 -3
- package/src/i18n/messages/en-us.ts +2 -0
- package/src/i18n/messages/es-es.ts +2 -0
- package/src/i18n/messages/pt-br.ts +2 -0
- package/src/middlewares/chain.ts +14 -1
- package/src/modules/subscriptions/types/subscription.type.ts +9 -6
- package/src/utils/geo-country.ts +15 -0
package/src/middlewares/chain.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
2
|
|
|
3
3
|
import { MiddlewareConfig } from './types';
|
|
4
|
+
import { GEO_COUNTRY_COOKIE, GEO_UNKNOWN_COUNTRIES } from '../utils/geo-country';
|
|
5
|
+
|
|
6
|
+
function publishGeoCountry(request: NextRequest, response: NextResponse): void {
|
|
7
|
+
const country = request.headers.get('cf-ipcountry')?.toUpperCase();
|
|
8
|
+
|
|
9
|
+
if (!country || GEO_UNKNOWN_COUNTRIES.includes(country)) return;
|
|
10
|
+
if (request.cookies.get(GEO_COUNTRY_COOKIE)?.value === country) return;
|
|
11
|
+
|
|
12
|
+
response.cookies.set(GEO_COUNTRY_COOKIE, country, { path: '/', sameSite: 'lax' });
|
|
13
|
+
}
|
|
4
14
|
|
|
5
15
|
function shouldProcessPath(pathname: string, config: MiddlewareConfig): boolean {
|
|
6
16
|
const { excludePaths, includePaths } = config;
|
|
@@ -40,6 +50,9 @@ export function createMiddlewareChain(middlewares: MiddlewareConfig[]) {
|
|
|
40
50
|
}
|
|
41
51
|
}
|
|
42
52
|
|
|
43
|
-
|
|
53
|
+
const response = NextResponse.next();
|
|
54
|
+
publishGeoCountry(request, response);
|
|
55
|
+
|
|
56
|
+
return response;
|
|
44
57
|
};
|
|
45
58
|
}
|
|
@@ -66,15 +66,15 @@ export const SubscriptionSchema = z.object({
|
|
|
66
66
|
schedule_id: z.string(),
|
|
67
67
|
schedule_status: z.string(),
|
|
68
68
|
kind: z.string(),
|
|
69
|
-
takes_effect_at: z.number(),
|
|
70
|
-
takes_effect_at_iso: z.string(),
|
|
69
|
+
takes_effect_at: z.number().nullable(),
|
|
70
|
+
takes_effect_at_iso: z.string().nullable(),
|
|
71
71
|
new_plan: z.object({
|
|
72
72
|
id: z.number(),
|
|
73
73
|
name: z.string(),
|
|
74
|
-
periodicity: z.number(),
|
|
74
|
+
periodicity: z.number().nullable(),
|
|
75
75
|
value: z.number(),
|
|
76
76
|
value_gross: z.number(),
|
|
77
|
-
}),
|
|
77
|
+
}).nullable(),
|
|
78
78
|
new_items: z.array(z.object({
|
|
79
79
|
price_id: z.string(),
|
|
80
80
|
id_addon: z.number().nullable(),
|
|
@@ -88,8 +88,11 @@ export const SubscriptionSchema = z.object({
|
|
|
88
88
|
new_discounts: z.array(z.unknown()),
|
|
89
89
|
changes: z.array(z.object({
|
|
90
90
|
type: z.string(),
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
id_addon: z.number().nullable().optional(),
|
|
92
|
+
addon_name: z.string().nullable().optional(),
|
|
93
|
+
quantity: z.number().optional(),
|
|
94
|
+
from: z.unknown().optional(),
|
|
95
|
+
to: z.unknown().optional(),
|
|
93
96
|
})),
|
|
94
97
|
}).nullable().optional(),
|
|
95
98
|
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { COUNTRIES } from './countries';
|
|
2
|
+
|
|
3
|
+
export const GEO_COUNTRY_COOKIE = 'gs-geo-country';
|
|
4
|
+
|
|
5
|
+
export const GEO_UNKNOWN_COUNTRIES = ['XX', 'T1'];
|
|
6
|
+
|
|
7
|
+
export function readGeoCountry(): string | null {
|
|
8
|
+
if (typeof document === 'undefined') return null;
|
|
9
|
+
|
|
10
|
+
const match = new RegExp(`(?:^|;\\s*)${GEO_COUNTRY_COOKIE}=([^;]+)`).exec(document.cookie);
|
|
11
|
+
if (!match) return null;
|
|
12
|
+
|
|
13
|
+
const iso = match[1].toUpperCase();
|
|
14
|
+
return COUNTRIES.some((country: { iso: string }) => country.iso === iso) ? iso : null;
|
|
15
|
+
}
|