@goweekdays/layer-common 0.0.13 → 1.0.0
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/CHANGELOG.md +12 -0
- package/components/AddPaymentMethod.vue +557 -138
- package/components/Input/Number.vue +1 -1
- package/components/Layout/Header.vue +8 -5
- package/components/Layout/NavigationDrawer.vue +6 -3
- package/components/LocalPagination.vue +26 -16
- package/components/NavigationItem.vue +7 -0
- package/components/SwitchOrg.vue +43 -5
- package/composables/useAddress.ts +16 -9
- package/composables/useChartOfAccount.ts +62 -0
- package/composables/useLocal.ts +28 -9
- package/composables/useLocalAuth.ts +62 -6
- package/composables/useOrg.ts +1 -1
- package/composables/usePaymentMethod.ts +41 -5
- package/composables/useSubscription.ts +38 -0
- package/composables/useUtils.ts +10 -1
- package/middleware/org.ts +1 -1
- package/nuxt.config.ts +3 -0
- package/package.json +1 -1
- package/plugins/API.ts +1 -3
- package/types/local.d.ts +1 -0
- package/types/payment-method.d.ts +1 -1
- package/types/xendit.d.ts +3 -0
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
export default function useSubscription() {
|
|
2
|
+
function createSubscriptionPlan(
|
|
3
|
+
seats: number,
|
|
4
|
+
trialDays: number,
|
|
5
|
+
productId: string
|
|
6
|
+
) {
|
|
7
|
+
return useNuxtApp().$api("/api/subscriptions/plan", {
|
|
8
|
+
method: "POST",
|
|
9
|
+
body: {
|
|
10
|
+
seats,
|
|
11
|
+
trialDays,
|
|
12
|
+
productId,
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
2
17
|
function add(subscriptionId: string, user: string) {
|
|
3
18
|
return useNuxtApp().$api("/api/subscriptions", {
|
|
4
19
|
method: "POST",
|
|
@@ -196,6 +211,27 @@ export default function useSubscription() {
|
|
|
196
211
|
});
|
|
197
212
|
}
|
|
198
213
|
|
|
214
|
+
function addOrgSubscription(value: {
|
|
215
|
+
user: string;
|
|
216
|
+
transactionId: string;
|
|
217
|
+
promoCode?: string;
|
|
218
|
+
seats: number;
|
|
219
|
+
perSeatPrice: number;
|
|
220
|
+
currency: string;
|
|
221
|
+
org: {
|
|
222
|
+
name: string;
|
|
223
|
+
email: string;
|
|
224
|
+
contact: string;
|
|
225
|
+
busInst: string;
|
|
226
|
+
type: string;
|
|
227
|
+
};
|
|
228
|
+
}) {
|
|
229
|
+
return useNuxtApp().$api("/api/subscriptions/subscribe", {
|
|
230
|
+
method: "POST",
|
|
231
|
+
body: value,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
199
235
|
return {
|
|
200
236
|
add,
|
|
201
237
|
getById,
|
|
@@ -218,5 +254,7 @@ export default function useSubscription() {
|
|
|
218
254
|
updateBillingContactByAddedAt,
|
|
219
255
|
deleteBillingContactByAddedAt,
|
|
220
256
|
processSubscriptionPayment,
|
|
257
|
+
createSubscriptionPlan,
|
|
258
|
+
addOrgSubscription,
|
|
221
259
|
};
|
|
222
260
|
}
|
package/composables/useUtils.ts
CHANGED
|
@@ -133,7 +133,7 @@ export default function useUtils() {
|
|
|
133
133
|
async function getCountries() {
|
|
134
134
|
try {
|
|
135
135
|
const countries = await useNuxtApp().$api<Array<Record<string, any>>>(
|
|
136
|
-
"https://restcountries.com/v3.1/all",
|
|
136
|
+
"https://restcountries.com/v3.1/all?fields=name,currencies,idd",
|
|
137
137
|
{ method: "GET" }
|
|
138
138
|
);
|
|
139
139
|
|
|
@@ -224,6 +224,14 @@ export default function useUtils() {
|
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
+
function extractMonthYear(expiry: string) {
|
|
228
|
+
const [month, year] = expiry.split("/");
|
|
229
|
+
return {
|
|
230
|
+
month: month.padStart(2, "0"),
|
|
231
|
+
year: 2000 + parseInt(year, 10),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
227
235
|
return {
|
|
228
236
|
requiredRule,
|
|
229
237
|
emailRule,
|
|
@@ -245,5 +253,6 @@ export default function useUtils() {
|
|
|
245
253
|
computeTieredCost,
|
|
246
254
|
requireListRule,
|
|
247
255
|
convertPermissionsToArray,
|
|
256
|
+
extractMonthYear,
|
|
248
257
|
};
|
|
249
258
|
}
|
package/middleware/org.ts
CHANGED
|
@@ -5,7 +5,7 @@ const hexSchema = z
|
|
|
5
5
|
.regex(/^[0-9a-fA-F]{24}$/, "Invalid organization ID");
|
|
6
6
|
|
|
7
7
|
export default defineNuxtRouteMiddleware((to) => {
|
|
8
|
-
const
|
|
8
|
+
const organization = (to.params.organization as string) ?? "";
|
|
9
9
|
|
|
10
10
|
if (organization && !hexSchema.safeParse(organization).success) {
|
|
11
11
|
return navigateTo(
|
package/nuxt.config.ts
CHANGED
|
@@ -8,6 +8,7 @@ export default defineNuxtConfig({
|
|
|
8
8
|
|
|
9
9
|
runtimeConfig: {
|
|
10
10
|
public: {
|
|
11
|
+
XENDIT_PUBLIC_KEY: (process.env.XENDIT_PUBLIC_KEY as string) ?? "",
|
|
11
12
|
BASE_URL: process.env.BASE_URL ?? "/",
|
|
12
13
|
cookieConfig: {
|
|
13
14
|
domain: (process.env.DOMAIN as string) ?? "localhost",
|
|
@@ -24,7 +25,9 @@ export default defineNuxtConfig({
|
|
|
24
25
|
APP_AFFILIATE: (process.env.APP_AFFILIATE as string) ?? "",
|
|
25
26
|
APP_INVENTORY: (process.env.APP_INVENTORY as string) ?? "",
|
|
26
27
|
APP_ASSET: (process.env.APP_ASSET as string) ?? "",
|
|
28
|
+
APP_ACCOUNTING: (process.env.APP_ACCOUNTING as string) ?? "",
|
|
27
29
|
APP_BOOK_KEEPING: (process.env.APP_BOOK_KEEPING as string) ?? "",
|
|
30
|
+
APP_ZONAL: (process.env.APP_ZONAL as string) ?? "",
|
|
28
31
|
},
|
|
29
32
|
},
|
|
30
33
|
|
package/package.json
CHANGED
package/plugins/API.ts
CHANGED
|
@@ -11,9 +11,7 @@ export default defineNuxtPlugin(() => {
|
|
|
11
11
|
retryDelay: 500,
|
|
12
12
|
onRequest({ options }) {
|
|
13
13
|
const accessToken = useCookie("accessToken", cookieConfig).value;
|
|
14
|
-
options.headers
|
|
15
|
-
? { Authorization: `Bearer ${accessToken}` }
|
|
16
|
-
: {};
|
|
14
|
+
options.headers.set("Authorization", `Bearer ${accessToken}`);
|
|
17
15
|
},
|
|
18
16
|
|
|
19
17
|
async onResponseError({ response }) {
|
package/types/local.d.ts
CHANGED