Skip to content

Commit 5cb6be9

Browse files
committed
fix: type
1 parent 98457bc commit 5cb6be9

File tree

4 files changed

+47
-40
lines changed

4 files changed

+47
-40
lines changed

packages/global/support/wallet/sub/type.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import z from 'zod';
22
import { StandardSubLevelEnum, SubModeEnum, SubTypeEnum } from './constants';
33
import { ObjectIdSchema } from '../../../common/type/mongo';
44

5-
// Content of plan
5+
/**
6+
* Static plan config, stored in global.subPlans
7+
*/
68
export const TeamStandardSubPlanItemSchema = z.object({
79
name: z.string().optional(),
810
desc: z.string().optional(),
@@ -71,6 +73,10 @@ export const SubPlanSchema = z.object({
7173
});
7274
export type SubPlanType = z.infer<typeof SubPlanSchema>;
7375

76+
/**
77+
* TeamSub Schema in DB.
78+
* Configs are optional
79+
*/
7480
export const TeamSubSchema = z.object({
7581
_id: ObjectIdSchema,
7682
teamId: ObjectIdSchema,
@@ -105,7 +111,7 @@ export const TeamSubSchema = z.object({
105111
});
106112
export type TeamSubSchemaType = z.infer<typeof TeamSubSchema>;
107113

108-
// Merged plan type: combines DB subscription record metadata with effective plan limits
114+
/** Merged plan type: combines DB subscription record metadata with effective plan limits */
109115
export const TeamPlanStandardSchema = z.object({
110116
...TeamSubSchema.omit({
111117
maxApp: true,

packages/service/support/wallet/sub/utils.ts

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,30 @@ export const sortStandPlans = (plans: TeamSubSchemaType[]) => {
4242
export const buildStandardPlan = (
4343
standard: TeamSubSchemaType,
4444
standardConstants: NonNullable<ReturnType<typeof getStandardPlanConfig>>
45-
): TeamPlanStandardType => {
46-
return {
47-
...standard,
48-
name: standardConstants.name,
49-
desc: standardConstants.desc,
50-
price: standardConstants.price,
51-
priceDescription: standardConstants.priceDescription,
52-
customFormUrl: standardConstants.customFormUrl,
53-
customDescriptions: standardConstants.customDescriptions,
54-
wecom: standardConstants.wecom,
55-
maxTeamMember: standard?.maxTeamMember ?? standardConstants.maxTeamMember,
56-
maxAppAmount: standard?.maxApp ?? standardConstants.maxAppAmount,
57-
maxDatasetAmount: standard?.maxDataset ?? standardConstants.maxDatasetAmount,
58-
requestsPerMinute: standard?.requestsPerMinute ?? standardConstants.requestsPerMinute,
59-
chatHistoryStoreDuration:
60-
standard?.chatHistoryStoreDuration ?? standardConstants.chatHistoryStoreDuration,
61-
maxDatasetSize: standard?.maxDatasetSize ?? standardConstants.maxDatasetSize,
62-
websiteSyncPerDataset:
63-
standard?.websiteSyncPerDataset ?? standardConstants.websiteSyncPerDataset,
64-
appRegistrationCount: standard?.appRegistrationCount ?? standardConstants.appRegistrationCount,
65-
auditLogStoreDuration:
66-
standard?.auditLogStoreDuration ?? standardConstants.auditLogStoreDuration,
67-
ticketResponseTime: standard?.ticketResponseTime ?? standardConstants.ticketResponseTime,
68-
customDomain: standard?.customDomain ?? standardConstants.customDomain,
69-
maxUploadFileSize: standard?.maxUploadFileSize ?? standardConstants.maxUploadFileSize,
70-
maxUploadFileCount: standard?.maxUploadFileCount ?? standardConstants.maxUploadFileCount
71-
};
72-
};
45+
): TeamPlanStandardType => ({
46+
...standard,
47+
name: standardConstants.name,
48+
desc: standardConstants.desc,
49+
price: standardConstants.price,
50+
priceDescription: standardConstants.priceDescription,
51+
customFormUrl: standardConstants.customFormUrl,
52+
customDescriptions: standardConstants.customDescriptions,
53+
wecom: standardConstants.wecom,
54+
maxTeamMember: standard?.maxTeamMember ?? standardConstants.maxTeamMember,
55+
maxAppAmount: standard?.maxApp ?? standardConstants.maxAppAmount,
56+
maxDatasetAmount: standard?.maxDataset ?? standardConstants.maxDatasetAmount,
57+
requestsPerMinute: standard?.requestsPerMinute ?? standardConstants.requestsPerMinute,
58+
chatHistoryStoreDuration:
59+
standard?.chatHistoryStoreDuration ?? standardConstants.chatHistoryStoreDuration,
60+
maxDatasetSize: standard?.maxDatasetSize ?? standardConstants.maxDatasetSize,
61+
websiteSyncPerDataset: standard?.websiteSyncPerDataset ?? standardConstants.websiteSyncPerDataset,
62+
appRegistrationCount: standard?.appRegistrationCount ?? standardConstants.appRegistrationCount,
63+
auditLogStoreDuration: standard?.auditLogStoreDuration ?? standardConstants.auditLogStoreDuration,
64+
ticketResponseTime: standard?.ticketResponseTime ?? standardConstants.ticketResponseTime,
65+
customDomain: standard?.customDomain ?? standardConstants.customDomain,
66+
maxUploadFileSize: standard?.maxUploadFileSize ?? standardConstants.maxUploadFileSize,
67+
maxUploadFileCount: standard?.maxUploadFileCount ?? standardConstants.maxUploadFileCount
68+
});
7369

7470
export const getTeamStandPlan = async ({ teamId }: { teamId: string }) => {
7571
const plans = await MongoTeamSub.find(

projects/app/src/components/support/wallet/StandardPlanContentList.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import Markdown from '@/components/Markdown';
1212
import MyPopover from '@fastgpt/web/components/common/MyPopover';
1313
import { useUserStore } from '@/web/support/user/useUserStore';
1414
import { formatFileSize } from '@fastgpt/global/common/file/tools';
15-
import type { TeamSubSchemaType } from '@fastgpt/global/support/wallet/sub/type';
15+
import type { TeamPlanStandardType } from '@fastgpt/global/support/wallet/sub/type';
1616

1717
const ModelPriceModal = dynamic(() =>
1818
import('@/components/core/ai/ModelTable').then((mod) => mod.ModelPriceModal)
@@ -25,7 +25,7 @@ const StandardPlanContentList = ({
2525
}: {
2626
level: `${StandardSubLevelEnum}`;
2727
mode: `${SubModeEnum}`;
28-
standplan?: TeamSubSchemaType;
28+
standplan?: TeamPlanStandardType;
2929
}) => {
3030
const { t } = useTranslation();
3131

@@ -58,8 +58,8 @@ const StandardPlanContentList = ({
5858
: plan.totalPoints * (formatMode === SubModeEnum.month ? 1 : 12)),
5959
requestsPerMinute: standplan?.requestsPerMinute ?? plan.requestsPerMinute,
6060
maxTeamMember: standplan?.maxTeamMember ?? plan.maxTeamMember,
61-
maxAppAmount: standplan?.maxApp ?? plan.maxAppAmount,
62-
maxDatasetAmount: standplan?.maxDataset ?? plan.maxDatasetAmount,
61+
maxAppAmount: standplan?.maxAppAmount ?? plan.maxAppAmount,
62+
maxDatasetAmount: standplan?.maxDatasetAmount ?? plan.maxDatasetAmount,
6363
maxDatasetSize: standplan?.maxDatasetSize ?? plan.maxDatasetSize,
6464
websiteSyncPerDataset: standplan?.websiteSyncPerDataset ?? plan.websiteSyncPerDataset,
6565
chatHistoryStoreDuration:
@@ -84,8 +84,8 @@ const StandardPlanContentList = ({
8484
standplan?.annualBonusPoints,
8585
standplan?.requestsPerMinute,
8686
standplan?.maxTeamMember,
87-
standplan?.maxApp,
88-
standplan?.maxDataset,
87+
standplan?.maxAppAmount,
88+
standplan?.maxDatasetAmount,
8989
standplan?.maxDatasetSize,
9090
standplan?.websiteSyncPerDataset,
9191
standplan?.chatHistoryStoreDuration,

projects/app/src/pageComponents/price/Standard.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import { StandardSubLevelEnum, SubModeEnum } from '@fastgpt/global/support/walle
66
import { useSystemStore } from '@/web/common/system/useSystemStore';
77
import { standardSubLevelMap } from '@fastgpt/global/support/wallet/sub/constants';
88
import { useRequest } from '@fastgpt/web/hooks/useRequest';
9-
import { type TeamSubSchemaType } from '@fastgpt/global/support/wallet/sub/type';
9+
import type {
10+
TeamPlanStandardType} from '@fastgpt/global/support/wallet/sub/type';
11+
import {
12+
TeamStandardSubPlanItemType,
13+
type TeamSubSchemaType
14+
} from '@fastgpt/global/support/wallet/sub/type';
1015
import QRCodePayModal, { type QRPayProps } from '@/components/support/wallet/QRCodePayModal';
1116
import { postCreatePayBill } from '@/web/support/wallet/bill/api';
1217
import { getDiscountCouponList } from '@/web/support/wallet/sub/discountCoupon/api';
@@ -35,7 +40,7 @@ const Standard = ({
3540
standardPlan: myStandardPlan,
3641
onPaySuccess
3742
}: {
38-
standardPlan?: TeamSubSchemaType;
43+
standardPlan?: TeamPlanStandardType;
3944
onPaySuccess?: () => void;
4045
}) => {
4146
const { t } = useTranslation();
@@ -113,8 +118,8 @@ const Standard = ({
113118
: value.price * (selectSubMode === SubModeEnum.month ? 1 : 10),
114119
level: level as `${StandardSubLevelEnum}`,
115120
maxTeamMember: myStandardPlan?.maxTeamMember || value.maxTeamMember,
116-
maxAppAmount: myStandardPlan?.maxApp || value.maxAppAmount,
117-
maxDatasetAmount: myStandardPlan?.maxDataset || value.maxDatasetAmount,
121+
maxAppAmount: myStandardPlan?.maxAppAmount || value.maxAppAmount,
122+
maxDatasetAmount: myStandardPlan?.maxDatasetAmount || value.maxDatasetAmount,
118123
chatHistoryStoreDuration: value.chatHistoryStoreDuration,
119124
maxDatasetSize: value.maxDatasetSize,
120125
annualBonusPoints: selectSubMode === SubModeEnum.month ? 0 : value.annualBonusPoints,

0 commit comments

Comments
 (0)