@goweekdays/layer-common 0.0.13 → 0.1.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.
@@ -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
  }
@@ -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 { organization } = to.params;
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,6 +25,7 @@ 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) ?? "",
28
30
  },
29
31
  },
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@goweekdays/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "0.0.13",
5
+ "version": "0.1.0",
6
6
  "main": "./nuxt.config.ts",
7
7
  "publishConfig": {
8
8
  "access": "public"
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 = accessToken
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
@@ -14,6 +14,7 @@ declare type TNavigationItem = {
14
14
  icon?: string;
15
15
  route?: TNavigationRoute;
16
16
  children?: TNavigationItem[];
17
+ disabled?: boolean;
17
18
  };
18
19
 
19
20
  declare type TKeyValuePair<
@@ -1,5 +1,5 @@
1
1
  declare type TLinkParams = {
2
- subscriptionId: string;
2
+ subscriptionId?: string;
3
3
  paymentMethodType: string;
4
4
  paymentMethodChannel: string;
5
5
  customerId: string;
@@ -0,0 +1,3 @@
1
+ declare interface Window {
2
+ Xendit: Record<any, any>;
3
+ }