Skip to content

Commit

Permalink
fix(web): fix the type of sms code for phone reset (#1402)
Browse files Browse the repository at this point in the history
* fix(web): fix reset phone smscode type

* feat(web): add function template developer info

* refactor(web): add tooltip
  • Loading branch information
newfish-cmyk authored Jul 14, 2023
1 parent 83a9960 commit a79e25a
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 10 deletions.
8 changes: 5 additions & 3 deletions web/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@
"Save": "Save",
"Recommended": "Recommended Template",
"Confirm": "If there are missing dependencies, the application will be automatically restarted. Are you sure you want to use this template?",
"ConfirmDeleteTemplate": "Are you sure you want to delete this function template?"
"ConfirmDeleteTemplate": "Are you sure you want to delete this function template?",
"DeveloperInfo": "Developer Info"
},
"Create function template success": "Create function template successfully",
"Publish": "release",
Expand Down Expand Up @@ -567,5 +568,6 @@
"Core": "Core",
"No History": "No History",
"MyIncomeAndExpenses": "My Income And Expenses",
"Apply": "apply"
}
"Apply": "apply",
"Developing": "Developing"
}
6 changes: 4 additions & 2 deletions web/public/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@
"Save": "保存",
"Recommended": "推荐模板",
"Confirm": "如果存在依赖包未安装,将会自动重启应用,确定使用该模板吗?",
"ConfirmDeleteTemplate": "确定删除模板吗"
"ConfirmDeleteTemplate": "确定删除模板吗?",
"DeveloperInfo": "开发者信息"
},
"Fee": "费用",
"PleaseCloseApplicationFirst": "请先关闭应用",
Expand Down Expand Up @@ -567,5 +568,6 @@
"Core": "",
"No History": "暂无记录",
"MyIncomeAndExpenses": "我的收支",
"Apply": "使用"
"Apply": "使用",
"Developing": "开发中"
}
6 changes: 4 additions & 2 deletions web/public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@
"Save": "保存",
"Recommended": "推荐模板",
"Confirm": "如果存在依赖包未安装,将会自动重启应用,确定使用该模板吗?",
"ConfirmDeleteTemplate": "确定删除模板吗"
"ConfirmDeleteTemplate": "确定删除模板吗?",
"DeveloperInfo": "开发者信息"
},
"Fee": "费用",
"PleaseCloseApplicationFirst": "请先关闭应用",
Expand Down Expand Up @@ -567,5 +568,6 @@
"Hour": "小时",
"Core": "",
"No History": "暂无记录",
"Apply": "使用"
"Apply": "使用",
"Developing": "开发中"
}
4 changes: 4 additions & 0 deletions web/src/apis/typing.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ export type TFunctionTemplate = {
items: { name: string; source: { code: string } }[];
dependencies: string[];
environments: { name: string; value: string }[];
uid: string;
user: { username: string };
};

export type TemplateList = {
Expand Down Expand Up @@ -367,3 +369,5 @@ export type TApplicationItem = {
};
};
};

export type TSmsCode = "Signin" | "Signup" | "ResetPassword" | "Bind" | "Unbind" | "ChangePhone";
6 changes: 4 additions & 2 deletions web/src/components/SendSmsCodeButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import { Button } from "@chakra-ui/react";
import clsx from "clsx";
import { t } from "i18next";

import { TSmsCode } from "@/apis/typing";
import { useSendSmsCodeMutation } from "@/pages/auth/service";
import useGlobalStore from "@/pages/globalStore";

export function SendSmsCodeButton(props: {
getPhone: any;
className?: string;
phoneNumber?: string;
type: TSmsCode;
}) {
const { getPhone, className, phoneNumber } = props;
const { getPhone, className, phoneNumber, type } = props;
const [isSendSmsCode, setIsSendSmsCode] = useState(false);
const [countdown, setCountdown] = useState(60);
const sendSmsCodeMutation = useSendSmsCodeMutation();
Expand Down Expand Up @@ -46,7 +48,7 @@ export function SendSmsCodeButton(props: {

const res = await sendSmsCodeMutation.mutateAsync({
phone,
type: "ResetPassword",
type,
});

if (res?.data) {
Expand Down
1 change: 1 addition & 0 deletions web/src/pages/app/setting/UserInfo/Mods/PasswordEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export default function UserNameEditor(props: { handleBack: any }) {
getPhone={getValues}
phoneNumber={"phone"}
className="!h-6 !text-[12px]"
type="ResetPassword"
/>
</InputRightElement>
</InputGroup>
Expand Down
2 changes: 2 additions & 0 deletions web/src/pages/app/setting/UserInfo/Mods/PhoneEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export default function PhoneEditor(props: { handleBack: any }) {
getPhone={getValues}
phoneNumber={"oldPhoneNumber"}
className="!h-6 !text-[12px]"
type="Unbind"
/>
</InputRightElement>
</InputGroup>
Expand Down Expand Up @@ -119,6 +120,7 @@ export default function PhoneEditor(props: { handleBack: any }) {
getPhone={getValues}
phoneNumber={"newPhoneNumber"}
className="!h-6 !text-[12px]"
type="Bind"
/>
</InputRightElement>
</InputGroup>
Expand Down
2 changes: 1 addition & 1 deletion web/src/pages/auth/reset-password/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default function ResetPassword() {
border={"1px solid #D5D6E1"}
/>
<InputRightElement width="6rem">
<SendSmsCodeButton getPhone={getValues} phoneNumber={"phone"} />
<SendSmsCodeButton getPhone={getValues} phoneNumber={"phone"} type="ResetPassword" />
</InputRightElement>
</InputGroup>
</FormControl>
Expand Down
26 changes: 26 additions & 0 deletions web/src/pages/functionTemplate/Mods/TemplateInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useTranslation } from "react-i18next";
import { Avatar, AvatarGroup, Box, Tooltip, useColorMode } from "@chakra-ui/react";
import clsx from "clsx";

import { GithubIcon, PhoneIcon, WechatIcon } from "@/components/CommonIcon";
import FileTypeIcon from "@/components/FileTypeIcon";
import { getAvatarUrl } from "@/utils/getAvatarUrl";

Expand All @@ -22,6 +23,31 @@ const TemplateInfo = (props: { functionTemplate: TFunctionTemplate; usedBy: any[
<UseTemplate template={functionTemplate} />
<div>
<Box className="border-b-[1px]">
<span className="text-xl font-semibold">{t("Template.DeveloperInfo")}</span>
<Box className="flex max-h-40 overflow-auto py-5">
<Avatar
width={12}
height={12}
border={"2px solid #DEE0E2"}
src={getAvatarUrl(functionTemplate?.uid)}
name={functionTemplate.user.username}
backgroundColor={"primary.500"}
/>
<div className="ml-3 flex flex-col">
<span className="text-lg font-semibold text-grayModern-900">
{functionTemplate.user.username}
</span>
<Tooltip label={t("Developing")}>
<span className="space-x-1 text-grayModern-400">
<WechatIcon />
<GithubIcon />
<PhoneIcon />
</span>
</Tooltip>
</div>
</Box>
</Box>
<Box className="border-b-[1px] pt-5">
<span className="text-xl font-semibold">{t("Template.Function")}</span>
<Box className="max-h-40 overflow-auto py-2">
{(functionList || []).map((item) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const UseTemplateModal = (props: { children: any; templateId: string; packageLis
return ApplicationControllerFindAll({});
},
{
enabled: isOpen,
onSuccess(data) {
setAppList(data?.data || []);
},
Expand Down

0 comments on commit a79e25a

Please sign in to comment.