From acd263a9db3fba1c183dc9a4f5976ad43b04df22 Mon Sep 17 00:00:00 2001 From: shuai Date: Thu, 10 Nov 2022 12:19:34 +0800 Subject: [PATCH] feat: add brand upload component --- i18n/en_US.yaml | 3 ++ ui/src/common/constants.ts | 7 +++- ui/src/components/BrandUpload/index.tsx | 39 +++++++++++++++++++ ui/src/components/UploadImg/index.tsx | 8 ++-- ui/src/components/index.ts | 2 + ui/src/i18n/locales/en_US.yaml | 3 ++ ui/src/index.scss | 10 +++++ ui/src/pages/Admin/Branding/index.tsx | 37 ++++++++++++++++++ ui/src/pages/Admin/Interface/index.tsx | 4 +- ui/src/pages/Admin/index.tsx | 7 +++- ui/src/pages/Users/Settings/Profile/index.tsx | 6 ++- ui/src/router/routes.ts | 4 ++ 12 files changed, 121 insertions(+), 9 deletions(-) create mode 100644 ui/src/components/BrandUpload/index.tsx create mode 100644 ui/src/pages/Admin/Branding/index.tsx diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml index fa6a1de3..0ade02a1 100644 --- a/i18n/en_US.yaml +++ b/i18n/en_US.yaml @@ -915,6 +915,7 @@ ui: general: General interface: Interface smtp: SMTP + branding: Branding dashboard: title: Dashboard welcome: Welcome to Answer Admin! @@ -1109,3 +1110,5 @@ ui: msg: SMTP authentication cannot be empty. 'yes': 'Yes' 'no': 'No' + branding: + page_title: Branding diff --git a/ui/src/common/constants.ts b/ui/src/common/constants.ts index 1bf1f355..3ed5e37c 100644 --- a/ui/src/common/constants.ts +++ b/ui/src/common/constants.ts @@ -54,7 +54,12 @@ export const ADMIN_NAV_MENUS = [ }, { name: 'settings', - child: [{ name: 'general' }, { name: 'interface' }, { name: 'smtp' }], + child: [ + { name: 'general' }, + { name: 'interface' }, + { name: 'branding' }, + { name: 'smtp' }, + ], }, ]; diff --git a/ui/src/components/BrandUpload/index.tsx b/ui/src/components/BrandUpload/index.tsx new file mode 100644 index 00000000..477efea0 --- /dev/null +++ b/ui/src/components/BrandUpload/index.tsx @@ -0,0 +1,39 @@ +import { FC } from 'react'; +import { ButtonGroup, Button } from 'react-bootstrap'; + +import { Icon, UploadImg } from '@/components'; + +interface Props { + type: string; + imgPath: string; + uploadCallback: (data: FormData) => Promise; + deleteCallback: (type: string) => void; +} + +const Index: FC = ({ + type, + imgPath, + uploadCallback, + deleteCallback, +}) => { + return ( +
+
+ +
+ + + + + + + +
+ ); +}; + +export default Index; diff --git a/ui/src/components/UploadImg/index.tsx b/ui/src/components/UploadImg/index.tsx index 3054fac4..90cca3e4 100644 --- a/ui/src/components/UploadImg/index.tsx +++ b/ui/src/components/UploadImg/index.tsx @@ -3,10 +3,12 @@ import { useTranslation } from 'react-i18next'; interface IProps { type: string; + className?: string; + children?: React.ReactNode; upload: (data: FormData) => Promise; } -const Index: React.FC = ({ type, upload }) => { +const Index: React.FC = ({ type, upload, children, className }) => { const { t } = useTranslation(); const [status, setStatus] = useState(false); @@ -35,8 +37,8 @@ const Index: React.FC = ({ type, upload }) => { }; return ( -