Skip to content

Commit

Permalink
individuation page and pay modal amount (#27)
Browse files Browse the repository at this point in the history
* feat: individuation page

* team chat config

* pay modal
  • Loading branch information
c121914yu authored Feb 27, 2024
1 parent 9aa21c7 commit 964edba
Show file tree
Hide file tree
Showing 14 changed files with 133 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"i18n-ally.keystyle": "nested",
"i18n-ally.sortKeys": true,
"i18n-ally.keepFulfilled": true,
"i18n-ally.sourceLanguage": "zh", // 根据此语言文件翻译其他语言文件的变量和内容
"i18n-ally.sourceLanguage": "en", // 根据此语言文件翻译其他语言文件的变量和内容
"i18n-ally.displayLanguage": "en", // 显示语言
}
4 changes: 3 additions & 1 deletion docSite/content/docs/development/upgrading/469.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ curl --location --request POST 'https://{{host}}/api/init/v469' \

1. 新增 - 完善了HTTP模块的变量提示。
2. 新增 - HTTP模块支持OpenAI单接口导入。
3. 优化 - 重写了计量模式
3. 优化 - 问题补全。增加英文类型。同时可以设置为单独模块,方便复用。
4. 优化 - 重写了计量模式
5. 修复 - 标注功能。
1 change: 1 addition & 0 deletions packages/global/common/system/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type FastGPTFeConfigsType = {
show_pay?: boolean;
show_openai_account?: boolean;
show_promotion?: boolean;
show_team_chat?: boolean;
hide_app_flow?: boolean;
concatMd?: string;
docUrl?: string;
Expand Down
1 change: 1 addition & 0 deletions packages/web/components/common/Icon/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export const iconPaths = {
'support/permission/publicLight': () => import('./icons/support/permission/publicLight.svg'),
'support/team/memberLight': () => import('./icons/support/team/memberLight.svg'),
'support/usage/usageRecordLight': () => import('./icons/support/usage/usageRecordLight.svg'),
'support/user/individuation': () => import('./icons/support/user/individuation.svg'),
'support/user/informLight': () => import('./icons/support/user/informLight.svg'),
'support/user/userFill': () => import('./icons/support/user/userFill.svg'),
'support/user/userLight': () => import('./icons/support/user/userLight.svg'),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions projects/app/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,9 @@
"Update Your Plugin": "Update Plugin"
},
"support": {
"account": {
"Individuation": "Individuation"
},
"openapi": {
"Api baseurl": "Baseurl",
"Api manager": "API key management",
Expand Down
3 changes: 3 additions & 0 deletions projects/app/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,9 @@
"Update Your Plugin": "更新插件"
},
"support": {
"account": {
"Individuation": "个性化"
},
"openapi": {
"Api baseurl": "API根地址",
"Api manager": "API 秘钥管理",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { FormDataType, defaultForm } from './EditModal';
import MyMenu from '@/components/MyMenu';
import { useConfirm } from '@/web/common/hooks/useConfirm';
import { useToast } from '@fastgpt/web/hooks/useToast';
import { useSystemStore } from '@/web/common/system/useSystemStore';

const EditModal = dynamic(() => import('./EditModal'));
const InviteModal = dynamic(() => import('./InviteModal'));
Expand All @@ -55,6 +56,7 @@ const TeamManageModal = ({ onClose }: { onClose: () => void }) => {
const { Loading } = useLoading();
const { toast } = useToast();
const { teamPlanStatus } = useUserStore();
const { feConfigs } = useSystemStore();
const [teamsTags, setTeamTags] = useState<any>();

const { ConfirmModal: ConfirmRemoveMemberModal, openConfirm: openRemoveMember } = useConfirm();
Expand Down Expand Up @@ -313,7 +315,7 @@ const TeamManageModal = ({ onClose }: { onClose: () => void }) => {
{t('user.team.Invite Member')}
</Button>
)}
{userInfo.team.role === TeamMemberRoleEnum.owner && (
{userInfo.team.role === TeamMemberRoleEnum.owner && feConfigs?.show_team_chat && (
<Button
variant={'whitePrimary'}
size="sm"
Expand Down
92 changes: 92 additions & 0 deletions projects/app/src/pages/account/components/Individuation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { Box, Card, Flex, Select } from '@chakra-ui/react';
import React, { useCallback, useRef } from 'react';
import MyIcon from '@fastgpt/web/components/common/Icon';
import { useTranslation } from 'next-i18next';
import { timezoneList } from '@fastgpt/global/common/time/timezone';
import { useUserStore } from '@/web/support/user/useUserStore';
import { UserType } from '@fastgpt/global/support/user/type';
import { useToast } from '@fastgpt/web/hooks/useToast';
import { useForm } from 'react-hook-form';
import { UserUpdateParams } from '@/types/user';
import { langMap, setLngStore } from '@/web/common/utils/i18n';
import MySelect from '@/components/Select';
import { useRouter } from 'next/router';

const Individuation = () => {
const { t, i18n } = useTranslation();
const timezones = useRef(timezoneList());
const { userInfo, updateUserInfo, initUserInfo } = useUserStore();
const { toast } = useToast();
const router = useRouter();

const { reset } = useForm<UserUpdateParams>({
defaultValues: userInfo as UserType
});

const onclickSave = useCallback(
async (data: UserType) => {
await updateUserInfo({
timezone: data.timezone
});
reset(data);
toast({
title: t('dataset.data.Update Success Tip'),
status: 'success'
});
},
[reset, t, toast, updateUserInfo]
);

return (
<Box py={[3, '28px']} px={['5vw', '64px']}>
<Flex alignItems={'center'} fontSize={'xl'} h={'30px'}>
<MyIcon mr={2} name={'support/user/individuation'} w={'20px'} />
{t('support.account.Individuation')}
</Flex>

<Card mt={6} px={[3, 10]} py={[3, 7]}>
<Flex alignItems={'center'} w={['85%', '350px']}>
<Box flex={'0 0 80px'}>{t('user.Language')}:&nbsp;</Box>
<Box flex={'1 0 0'}>
<MySelect
value={i18n.language}
list={Object.entries(langMap).map(([key, lang]) => ({
label: lang.label,
value: key
}))}
onchange={(val: any) => {
const lang = val;
setLngStore(lang);
router.replace(
{
query: router.query
},
router.asPath,
{ locale: lang }
);
}}
/>
</Box>
</Flex>
<Flex mt={6} alignItems={'center'} w={['85%', '350px']}>
<Box flex={'0 0 80px'}>{t('user.Timezone')}:&nbsp;</Box>
<Select
value={userInfo?.timezone}
onChange={(e) => {
if (!userInfo) return;
onclickSave({ ...userInfo, timezone: e.target.value });
}}
>
{timezones.current.map((item) => (
<option key={item.value} value={item.value}>
{item.name}
</option>
))}
</Select>
</Flex>
</Card>
</Box>
);
};

export default Individuation;
12 changes: 10 additions & 2 deletions projects/app/src/pages/account/components/PayModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useCallback } from 'react';
import React, { useState, useCallback, useMemo } from 'react';
import { ModalFooter, ModalBody, Button, Input, Box, Grid } from '@chakra-ui/react';
import { getWxPayQRCode } from '@/web/support/wallet/bill/api';
import { useToast } from '@fastgpt/web/hooks/useToast';
Expand All @@ -9,6 +9,7 @@ import MyModal from '@/components/MyModal';
import { BillTypeEnum } from '@fastgpt/global/support/wallet/bill/constants';

import QRCodePayModal, { type QRPayProps } from '@/components/support/wallet/QRCodePayModal';
import { useSystemStore } from '@/web/common/system/useSystemStore';

const PayModal = ({
onClose,
Expand All @@ -22,6 +23,7 @@ const PayModal = ({
const router = useRouter();
const { t } = useTranslation();
const { toast } = useToast();
const { subPlans } = useSystemStore();
const [inputVal, setInputVal] = useState<number | undefined>(defaultValue);
const [loading, setLoading] = useState(false);
const [qrPayData, setQRPayData] = useState<QRPayProps>();
Expand Down Expand Up @@ -49,11 +51,17 @@ const PayModal = ({
setLoading(false);
}, [inputVal, toast]);

const payList = useMemo(() => {
const list = Object.values(subPlans?.standard || {});
const priceList = list.map((item) => item.price);
return priceList.concat(priceList.map((item) => item * 10)).filter(Boolean);
}, [subPlans?.standard]);

return (
<MyModal isOpen={true} onClose={onClose} title={t('user.Pay')} iconSrc="/imgs/modal/pay.svg">
<ModalBody px={0} display={'flex'} flexDirection={'column'}>
<Grid gridTemplateColumns={'repeat(3,1fr)'} gridGap={5} mb={4} px={6}>
{[10, 20, 50, 100, 200, 500].map((item) => (
{payList.map((item) => (
<Button
key={item}
variant={item === inputVal ? 'solid' : 'outline'}
Expand Down
8 changes: 8 additions & 0 deletions projects/app/src/pages/account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ const UsageTable = dynamic(() => import('./components/UsageTable'));
const BillTable = dynamic(() => import('./components/BillTable'));
const InformTable = dynamic(() => import('./components/InformTable'));
const ApiKeyTable = dynamic(() => import('./components/ApiKeyTable'));
const Individuation = dynamic(() => import('./components/Individuation'));

enum TabEnum {
'info' = 'info',
'promotion' = 'promotion',
'usage' = 'usage',
'bill' = 'bill',
'inform' = 'inform',
'individuation' = 'individuation',
'apikey' = 'apikey',
'loginout' = 'loginout'
}
Expand Down Expand Up @@ -77,6 +79,11 @@ const Account = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
}
]
: []),
{
icon: 'support/user/individuation',
label: t('support.account.Individuation'),
id: TabEnum.individuation
},
...(feConfigs.isPlus
? [
{
Expand Down Expand Up @@ -162,6 +169,7 @@ const Account = ({ currentTab }: { currentTab: `${TabEnum}` }) => {
{currentTab === TabEnum.promotion && <Promotion />}
{currentTab === TabEnum.usage && <UsageTable />}
{currentTab === TabEnum.bill && <BillTable />}
{currentTab === TabEnum.individuation && <Individuation />}
{currentTab === TabEnum.inform && <InformTable />}
{currentTab === TabEnum.apikey && <ApiKeyTable />}
</Box>
Expand Down
2 changes: 0 additions & 2 deletions projects/app/src/pages/api/common/system/getInitData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import type { InitDateResponse } from '@/global/common/api/systemRes';
import type { FastGPTConfigFileType } from '@fastgpt/global/common/system/types/index.d';
import { getTikTokenEnc } from '@fastgpt/global/common/string/tiktoken';
import { initHttpAgent } from '@fastgpt/service/common/middle/httpAgent';
import { SimpleModeTemplate_FastGPT_Universal } from '@/global/core/app/constants';
import { getSimpleTemplatesFromPlus } from '@/service/core/app/utils';
import { PluginSourceEnum } from '@fastgpt/global/core/plugin/constants';
import { getFastGPTConfigFromDB } from '@fastgpt/service/common/system/config/controller';
import { connectToDatabase } from '@/service/mongo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import dynamic from 'next/dynamic';
import Avatar from '@/components/Avatar';
import MyIcon from '@fastgpt/web/components/common/Icon';
import TagsEditModal from './tagsEditModal';
import { useSystemStore } from '@/web/common/system/useSystemStore';
const InfoModal = dynamic(() => import('../InfoModal'));

const AppCard = ({ appId }: { appId: string }) => {
const router = useRouter();
const { t } = useTranslation();
const { toast } = useToast();
const { appDetail } = useAppStore();
const { feConfigs } = useSystemStore();
const [settingAppInfo, setSettingAppInfo] = useState<AppSchema>();
const [TeamTagsSet, setTeamTagsSet] = useState<AppSchema>();

Expand Down Expand Up @@ -126,7 +128,7 @@ const AppCard = ({ appId }: { appId: string }) => {
>
{t('core.app.navbar.Publish')}
</Button>
{appDetail.isOwner && (
{appDetail.canWrite && feConfigs?.show_team_chat && (
<Button
mr={3}
size={['sm', 'md']}
Expand Down
2 changes: 1 addition & 1 deletion projects/app/src/service/core/dataset/data/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export async function searchDatasetData(props: SearchDatasetDataProps) {

const formatResult = concatResults
.map((data, index) => {
if (data.collectionId) {
if (!data.collectionId) {
console.log('Collection is not found', data);
}

Expand Down

0 comments on commit 964edba

Please sign in to comment.