@greatapps/common 1.1.361 → 1.1.362
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,17 +1,8 @@
|
|
|
1
1
|
"use server";
|
|
2
2
|
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
3
3
|
import { subscriptionsService } from "../services/subscriptions.service";
|
|
4
|
-
import { resolvePlanExtrasPrices } from "../utils/resolve-plan-extras-prices";
|
|
5
4
|
async function updateSubscriptionPlanAction(subscriptionId, data) {
|
|
6
5
|
return safeServerAction(async () => {
|
|
7
|
-
if (data.plan_extras?.length) {
|
|
8
|
-
const { data: subscriptions } = await subscriptionsService.listSubscriptions({ active: true });
|
|
9
|
-
const subscription = subscriptions.find((s) => String(s.id) === String(subscriptionId)) ?? subscriptions[0];
|
|
10
|
-
data = {
|
|
11
|
-
...data,
|
|
12
|
-
plan_extras: resolvePlanExtrasPrices(data.plan_extras, subscription?.items ?? [])
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
6
|
return subscriptionsService.updateSubscriptionPlan(subscriptionId, data);
|
|
16
7
|
});
|
|
17
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/modules/subscriptions/actions/update-subscription-plan.action.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/modules/subscriptions/actions/update-subscription-plan.action.ts"],"sourcesContent":["\"use server\";\n\nimport { safeServerAction } from \"../../../utils/safeServerAction\";\nimport type { UpdateSubscriptionPlanRequest } from \"../types/calculate-subscription.type\";\nimport { subscriptionsService } from \"../services/subscriptions.service\";\n\nexport async function updateSubscriptionPlanAction(\n subscriptionId: number | string,\n data: UpdateSubscriptionPlanRequest,\n) {\n return safeServerAction(async () => {\n return subscriptionsService.updateSubscriptionPlan(subscriptionId, data);\n });\n}\n"],"mappings":";AAEA,SAAS,wBAAwB;AAEjC,SAAS,4BAA4B;AAErC,eAAsB,6BACpB,gBACA,MACA;AACA,SAAO,iBAAiB,YAAY;AAClC,WAAO,qBAAqB,uBAAuB,gBAAgB,IAAI;AAAA,EACzE,CAAC;AACH;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use server";
|
|
2
2
|
|
|
3
|
-
import { safeServerAction } from
|
|
4
|
-
import type { UpdateSubscriptionPlanRequest } from
|
|
5
|
-
import { subscriptionsService } from
|
|
6
|
-
import { resolvePlanExtrasPrices } from '../utils/resolve-plan-extras-prices';
|
|
3
|
+
import { safeServerAction } from "../../../utils/safeServerAction";
|
|
4
|
+
import type { UpdateSubscriptionPlanRequest } from "../types/calculate-subscription.type";
|
|
5
|
+
import { subscriptionsService } from "../services/subscriptions.service";
|
|
7
6
|
|
|
8
7
|
export async function updateSubscriptionPlanAction(
|
|
9
8
|
subscriptionId: number | string,
|
|
10
|
-
data: UpdateSubscriptionPlanRequest
|
|
9
|
+
data: UpdateSubscriptionPlanRequest,
|
|
11
10
|
) {
|
|
12
11
|
return safeServerAction(async () => {
|
|
13
|
-
if (data.plan_extras?.length) {
|
|
14
|
-
const { data: subscriptions } = await subscriptionsService.listSubscriptions({ active: true });
|
|
15
|
-
const subscription =
|
|
16
|
-
subscriptions.find((s) => String(s.id) === String(subscriptionId)) ?? subscriptions[0];
|
|
17
|
-
|
|
18
|
-
data = {
|
|
19
|
-
...data,
|
|
20
|
-
plan_extras: resolvePlanExtrasPrices(data.plan_extras, subscription?.items ?? []),
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
12
|
return subscriptionsService.updateSubscriptionPlan(subscriptionId, data);
|
|
25
13
|
});
|
|
26
14
|
}
|