Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

fix: handle install page forms

shuaibf4e9824f59a
diff --git a/ui/src/common/interface.ts b/ui/src/common/interface.ts
index 7516a2d7..732964d1 100644
--- a/ui/src/common/interface.ts
+++ b/ui/src/common/interface.ts
@@ -264,7 +264,7 @@ export interface AdminSettingsInterface {
logo: string;
language: string;
theme: string;
- time_zone: string;
+ time_zone?: string;
}
export interface AdminSettingsSmtp {
diff --git a/ui/src/components/Header/index.scss b/ui/src/components/Header/index.scss
index 348632a3..f3f67b78 100644
--- a/ui/src/components/Header/index.scss
+++ b/ui/src/components/Header/index.scss
@@ -50,6 +50,10 @@
@media (max-width: 992.9px) {
#header {
+ .logo {
+ max-width: 93px;
+ max-height: auto;
+ }
.nav-grow {
flex-grow: 1!important;
}
@@ -65,3 +69,12 @@
}
+@media (max-width: 576px) {
+ #header {
+ .logo {
+ max-width: 93px;
+ max-height: auto;
+ }
+ }
+}
+
diff --git a/ui/src/components/Header/index.tsx b/ui/src/components/Header/index.tsx
index 748eb318..4de50cee 100644
--- a/ui/src/components/Header/index.tsx
+++ b/ui/src/components/Header/index.tsx
@@ -71,8 +71,8 @@ const Header: FC = () => {
id="navBarToggle"
/>
- <div className="left-wrap d-flex justify-content-between align-items-center nav-grow">
- <Navbar.Brand to="/" as={Link} className="lh-1">
+ <div className="d-flex justify-content-between align-items-center nav-grow flex-nowrap">
+ <Navbar.Brand to="/" as={Link} className="lh-1 me-0">
{interfaceInfo.logo ? (
<img
className="logo rounded-1 me-0"
diff --git a/ui/src/i18n/locales/en.json b/ui/src/i18n/locales/en.json
index 2a63ecc3..ec9012b2 100644
--- a/ui/src/i18n/locales/en.json
+++ b/ui/src/i18n/locales/en.json
@@ -739,31 +739,36 @@
"title": "Answer",
"next": "Next",
"done": "Done",
- "choose_lang": {
+ "lang": {
"label": "Please choose a language"
},
- "database_engine": {
+ "db_type": {
"label": "Database Engine"
},
- "username": {
+ "db_username": {
"label": "Username",
- "placeholder": "root"
+ "placeholder": "root",
+ "msg": "Username cannot be empty."
},
- "password": {
+ "db_password": {
"label": "Password",
- "placeholder": "root"
+ "placeholder": "root",
+ "msg": "Password cannot be empty."
},
- "database_host": {
+ "db_host": {
"label": "Database Host",
- "placeholder": "db:3306"
+ "placeholder": "db:3306",
+ "msg": "Database Host cannot be empty."
},
- "database_name": {
+ "db_name": {
"label": "Database Name",
- "placeholder": "answer"
+ "placeholder": "answer",
+ "msg": "Database Name cannot be empty."
},
- "table_prefix": {
- "label": "Table Prefix (optional)",
- "placeholder": "answer_"
+ "db_file": {
+ "label": "Database File",
+ "placeholder": "/data/answer.db",
+ "msg": "Database File cannot be empty."
},
"config_yaml": {
"title": "Create config.yaml",
diff --git a/ui/src/index.scss b/ui/src/index.scss
index dd25289f..b9114cd5 100644
--- a/ui/src/index.scss
+++ b/ui/src/index.scss
@@ -78,6 +78,7 @@ a {
min-height: calc(100vh - 148px);
}
.page-wrap2 {
+ background-color: #f5f5f5;
min-height: 100vh;
}
diff --git a/ui/src/pages/Install/components/FirstStep/index.tsx b/ui/src/pages/Install/components/FirstStep/index.tsx
index 156f568d..2a2226d6 100644
--- a/ui/src/pages/Install/components/FirstStep/index.tsx
+++ b/ui/src/pages/Install/components/FirstStep/index.tsx
@@ -1,28 +1,70 @@
-import { FC } from 'react';
+import { FC, useEffect, useState } from 'react';
import { Form, Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
+import type {
+ LangsType,
+ FormValue,
+ FormDataType,
+} from '@answer/common/interface';
import Progress from '../Progress';
+import { languages } from '@/services';
+
interface Props {
+ data: FormValue;
+ changeCallback: (value: FormDataType) => void;
+ nextCallback: () => void;
visible: boolean;
}
-const Index: FC<Props> = ({ visible }) => {
+const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
const { t } = useTranslation('translation', { keyPrefix: 'install' });
+ const [langs, setLangs] = useState<LangsType[]>();
+
+ const getLangs = async () => {
+ const res: LangsType[] = await languages();
+ setLangs(res);
+ };
+
+ const handleSubmit = () => {
+ nextCallback();
+ };
+
+ useEffect(() => {
+ getLangs();
+ }, []);
+
if (!visible) return null;
return (
- <Form>
- <Form.Group controlId="langSelect" className="mb-3">
- <Form.Label>{t('choose_lang.label')}</Form.Label>
- <Form.Select>
- <option>English</option>
+ <Form noValidate onSubmit={handleSubmit}>
+ <Form.Group controlId="lang" className="mb-3">
+ <Form.Label>{t('lang.label')}</Form.Label>
+ <Form.Select
+ value={data.value}
+ isInvalid={data.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ lang: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}>
+ {langs?.map((item) => {
+ return (
+ <option value={item.value} key={item.value}>
+ {item.label}
+ </option>
+ );
+ })}
</Form.Select>
</Form.Group>
<div className="d-flex align-items-center justify-content-between">
<Progress step={1} />
- <Button>{t('next')}</Button>
+ <Button type="submit">{t('next')}</Button>
</div>
</Form>
);
diff --git a/ui/src/pages/Install/components/FourthStep/index.tsx b/ui/src/pages/Install/components/FourthStep/index.tsx
index 25fb47ef..ccd44be2 100644
--- a/ui/src/pages/Install/components/FourthStep/index.tsx
+++ b/ui/src/pages/Install/components/FourthStep/index.tsx
@@ -1,50 +1,204 @@
-import { FC } from 'react';
+import { FC, FormEvent } from 'react';
import { Form, Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
+import type { FormDataType } from '@/common/interface';
import Progress from '../Progress';
interface Props {
+ data: FormDataType;
+ changeCallback: (value: FormDataType) => void;
+ nextCallback: () => void;
visible: boolean;
}
-const Index: FC<Props> = ({ visible }) => {
+const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
const { t } = useTranslation('translation', { keyPrefix: 'install' });
+ const checkValidated = (): boolean => {
+ let bol = true;
+ const {
+ site_name,
+ contact_email,
+ admin_name,
+ admin_password,
+ admin_email,
+ } = data;
+
+ if (!site_name.value) {
+ bol = false;
+ data.site_name = {
+ value: '',
+ isInvalid: true,
+ errorMsg: t('site_name.msg'),
+ };
+ }
+
+ if (!contact_email.value) {
+ bol = false;
+ data.contact_email = {
+ value: '',
+ isInvalid: true,
+ errorMsg: t('contact_email.msg'),
+ };
+ }
+
+ if (!admin_name.value) {
+ bol = false;
+ data.admin_name = {
+ value: '',
+ isInvalid: true,
+ errorMsg: t('admin_name.msg'),
+ };
+ }
+
+ if (!admin_password.value) {
+ bol = false;
+ data.admin_password = {
+ value: '',
+ isInvalid: true,
+ errorMsg: t('admin_password.msg'),
+ };
+ }
+
+ if (!admin_email.value) {
+ bol = false;
+ data.admin_email = {
+ value: '',
+ isInvalid: true,
+ errorMsg: t('admin_email.msg'),
+ };
+ }
+
+ changeCallback({
+ ...data,
+ });
+ return bol;
+ };
+
+ const handleSubmit = (event: FormEvent) => {
+ event.preventDefault();
+ event.stopPropagation();
+ if (!checkValidated()) {
+ return;
+ }
+ nextCallback();
+ };
+
if (!visible) return null;
return (
- <Form>
+ <Form noValidate onSubmit={handleSubmit}>
<h5>{t('site_information')}</h5>
<Form.Group controlId="site_name" className="mb-3">
<Form.Label>{t('site_name.label')}</Form.Label>
- <Form.Control required type="text" />
+ <Form.Control
+ required
+ value={data.site_name.value}
+ isInvalid={data.site_name.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ site_name: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}
+ />
+ <Form.Control.Feedback type="invalid">
+ {data.site_name.errorMsg}
+ </Form.Control.Feedback>
</Form.Group>
<Form.Group controlId="contact_email" className="mb-3">
<Form.Label>{t('contact_email.label')}</Form.Label>
- <Form.Control required type="text" />
+ <Form.Control
+ required
+ value={data.contact_email.value}
+ isInvalid={data.contact_email.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ contact_email: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}
+ />
<Form.Text>{t('contact_email.text')}</Form.Text>
+ <Form.Control.Feedback type="invalid">
+ {data.contact_email.errorMsg}
+ </Form.Control.Feedback>
</Form.Group>
<h5>{t('admin_account')}</h5>
<Form.Group controlId="admin_name" className="mb-3">
<Form.Label>{t('admin_name.label')}</Form.Label>
- <Form.Control required type="text" />
+ <Form.Control
+ required
+ value={data.admin_name.value}
+ isInvalid={data.admin_name.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ admin_name: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}
+ />
+ <Form.Control.Feedback type="invalid">
+ {data.admin_name.errorMsg}
+ </Form.Control.Feedback>
</Form.Group>
<Form.Group controlId="admin_password" className="mb-3">
<Form.Label>{t('admin_password.label')}</Form.Label>
- <Form.Control required type="text" />
+ <Form.Control
+ required
+ value={data.admin_password.value}
+ isInvalid={data.admin_password.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ admin_password: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}
+ />
<Form.Text>{t('admin_password.text')}</Form.Text>
+ <Form.Control.Feedback type="invalid">
+ {data.admin_password.errorMsg}
+ </Form.Control.Feedback>
</Form.Group>
<Form.Group controlId="admin_email" className="mb-3">
<Form.Label>{t('admin_email.label')}</Form.Label>
- <Form.Control required type="text" />
+ <Form.Control
+ required
+ value={data.admin_email.value}
+ isInvalid={data.admin_email.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ admin_email: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}
+ />
<Form.Text>{t('admin_email.text')}</Form.Text>
+ <Form.Control.Feedback type="invalid">
+ {data.admin_email.errorMsg}
+ </Form.Control.Feedback>
</Form.Group>
<div className="d-flex align-items-center justify-content-between">
<Progress step={4} />
- <Button>{t('next')}</Button>
+ <Button type="submit">{t('next')}</Button>
</div>
</Form>
);
diff --git a/ui/src/pages/Install/components/SecondStep/index.tsx b/ui/src/pages/Install/components/SecondStep/index.tsx
index 7b21ab73..6c97ec61 100644
--- a/ui/src/pages/Install/components/SecondStep/index.tsx
+++ b/ui/src/pages/Install/components/SecondStep/index.tsx
@@ -1,54 +1,243 @@
-import { FC } from 'react';
+import { FC, FormEvent } from 'react';
import { Form, Button } from 'react-bootstrap';
import { useTranslation } from 'react-i18next';
import Progress from '../Progress';
+import type { FormDataType } from '@/common/interface';
interface Props {
+ data: FormDataType;
+ changeCallback: (value: FormDataType) => void;
+ nextCallback: () => void;
visible: boolean;
}
-const Index: FC<Props> = ({ visible }) => {
+const sqlData = [
+ {
+ value: 'mysql',
+ label: 'MariaDB/MySQL',
+ },
+ {
+ value: 'sqlite3',
+ label: 'SQLite',
+ },
+ {
+ value: 'postgres',
+ label: 'PostgreSQL',
+ },
+];
+
+const Index: FC<Props> = ({ visible, data, changeCallback, nextCallback }) => {
const { t } = useTranslation('translation', { keyPrefix: 'install' });
+ const checkValidated = (): boolean => {
+ let bol = true;
+ const { db_type, db_username, db_password, db_host, db_name, db_file } =
+ data;
+
+ if (db_type.value !== 'sqllite3') {
+ if (!db_username.value) {
+ bol = false;
+ data.db_username = {
+ value: '',
+ isInvalid: true,
+ errorMsg: t('db_username.msg'),
+ };
+ }
+
+ if (!db_password.value) {
+ bol = false;
+ data.db_password = {
+ value: '',
+ isInvalid: true,
+ errorMsg: t('db_password.msg'),
+ };
+ }
+
+ if (!db_host.value) {
+ bol = false;
+ data.db_host = {
+ value: '',
+ isInvalid: true,
+ errorMsg: t('db_host.msg'),
+ };
+ }
+
+ if (!db_name.value) {
+ bol = false;
+ data.db_name = {
+ value: '',
+ isInvalid: true,
+ errorMsg: t('db_name.msg'),
+ };
+ }
+ } else if (!db_file.value) {
+ bol = false;
+ data.db_file = {
+ value: '',
+ isInvalid: true,
+ errorMsg: t('db_file.msg'),
+ };
+ }
+ changeCallback({
+ ...data,
+ });
+ return bol;
+ };
+
+ const handleSubmit = (event: FormEvent) => {
+ event.preventDefault();
+ event.stopPropagation();
+ if (!checkValidated()) {
+ return;
+ }
+ nextCallback();
+ };
+
if (!visible) return null;
return (
- <Form>
+ <Form noValidate onSubmit={handleSubmit}>
<Form.Group controlId="database_engine" className="mb-3">
- <Form.Label>{t('database_engine.label')}</Form.Label>
- <Form.Select>
- <option>English</option>
+ <Form.Label>{t('db_type.label')}</Form.Label>
+ <Form.Select
+ value={data.db_type.value}
+ isInvalid={data.db_type.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ db_type: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}>
+ {sqlData.map((item) => {
+ return (
+ <option key={item.value} value={item.value}>
+ {item.label}
+ </option>
+ );
+ })}
</Form.Select>
</Form.Group>
+ {data.db_type.value !== 'sqlite3' ? (
+ <>
+ <Form.Group controlId="username" className="mb-3">
+ <Form.Label>{t('db_username.label')}</Form.Label>
+ <Form.Control
+ required
+ placeholder={t('db_username.placeholder')}
+ value={data.db_username.value}
+ isInvalid={data.db_username.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ db_username: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}
+ />
+ <Form.Control.Feedback type="invalid">
+ {data.db_username.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
- <Form.Group controlId="username" className="mb-3">
- <Form.Label>{t('username.label')}</Form.Label>
- <Form.Control placeholder={t('username.placeholder')} />
- </Form.Group>
-
- <Form.Group controlId="password" className="mb-3">
- <Form.Label>{t('password.label')}</Form.Label>
- <Form.Control placeholder={t('password.placeholder')} />
- </Form.Group>
+ <Form.Group controlId="db_password" className="mb-3">
+ <Form.Label>{t('db_password.label')}</Form.Label>
+ <Form.Control
+ required
+ placeholder={t('db_password.placeholder')}
+ value={data.db_password.value}
+ isInvalid={data.db_password.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ db_password: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}
+ />
- <Form.Group controlId="database_host" className="mb-3">
- <Form.Label>{t('database_host.label')}</Form.Label>
- <Form.Control placeholder={t('database_host.placeholder')} />
- </Form.Group>
+ <Form.Control.Feedback type="invalid">
+ {data.db_password.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
- <Form.Group controlId="database_name" className="mb-3">
- <Form.Label>{t('database_name.label')}</Form.Label>
- <Form.Control placeholder={t('database_name.placeholder')} />
- </Form.Group>
+ <Form.Group controlId="db_host" className="mb-3">
+ <Form.Label>{t('db_host.label')}</Form.Label>
+ <Form.Control
+ required
+ placeholder={t('db_host.placeholder')}
+ value={data.db_host.value}
+ isInvalid={data.db_host.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ db_host: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}
+ />
+ <Form.Control.Feedback type="invalid">
+ {data.db_host.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
- <Form.Group controlId="table_prefix" className="mb-3">
- <Form.Label>{t('table_prefix.label')}</Form.Label>
- <Form.Control placeholder={t('table_prefix.placeholder')} />
- </Form.Group>
+ <Form.Group controlId="name" className="mb-3">
+ <Form.Label>{t('db_name.label')}</Form.Label>
+ <Form.Control
+ required
+ placeholder={t('db_name.placeholder')}
+ value={data.db_name.value}
+ isInvalid={data.db_name.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ db_name: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}
+ />
+ <Form.Control.Feedback type="invalid">
+ {data.db_name.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
+ </>
+ ) : (
+ <Form.Group controlId="file" className="mb-3">
+ <Form.Label>{t('db_file.label')}</Form.Label>
+ <Form.Control
+ required
+ placeholder={t('db_file.placeholder')}
+ value={data.db_file.value}
+ isInvalid={data.db_file.isInvalid}
+ onChange={(e) => {
+ changeCallback({
+ db_file: {
+ value: e.target.value,
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+ }}
+ />
+ <Form.Control.Feedback type="invalid">
+ {data.db_file.errorMsg}
+ </Form.Control.Feedback>
+ </Form.Group>
+ )}
<div className="d-flex align-items-center justify-content-between">
<Progress step={2} />
- <Button>{t('next')}</Button>
+ <Button type="submit">{t('next')}</Button>
</div>
</Form>
);
diff --git a/ui/src/pages/Install/components/ThirdStep/index.tsx b/ui/src/pages/Install/components/ThirdStep/index.tsx
index 4d3f702f..3b5ca08c 100644
--- a/ui/src/pages/Install/components/ThirdStep/index.tsx
+++ b/ui/src/pages/Install/components/ThirdStep/index.tsx
@@ -6,9 +6,10 @@ import Progress from '../Progress';
interface Props {
visible: boolean;
+ nextCallback: () => void;
}
-const Index: FC<Props> = ({ visible }) => {
+const Index: FC<Props> = ({ visible, nextCallback }) => {
const { t } = useTranslation('translation', { keyPrefix: 'install' });
if (!visible) return null;
@@ -30,7 +31,7 @@ const Index: FC<Props> = ({ visible }) => {
<div className="mb-3">{t('config_yaml.info')}</div>
<div className="d-flex align-items-center justify-content-between">
<Progress step={3} />
- <Button>{t('next')}</Button>
+ <Button onClick={nextCallback}>{t('next')}</Button>
</div>
</div>
);
diff --git a/ui/src/pages/Install/index.tsx b/ui/src/pages/Install/index.tsx
index 8de7cb11..e8c40d5a 100644
--- a/ui/src/pages/Install/index.tsx
+++ b/ui/src/pages/Install/index.tsx
@@ -1,7 +1,11 @@
-import { FC, useState } from 'react';
+import { FC, useState, useEffect } from 'react';
import { Container, Row, Col, Card, Alert } from 'react-bootstrap';
import { useTranslation, Trans } from 'react-i18next';
+import type { FormDataType } from '@/common/interface';
+import { Storage } from '@/utils';
+import { PageTitle } from '@/components';
+
import {
FirstStep,
SecondStep,
@@ -10,14 +14,109 @@ import {
Fifth,
} from './components';
-import { PageTitle } from '@/components';
-
const Index: FC = () => {
const { t } = useTranslation('translation', { keyPrefix: 'install' });
- const [step] = useState(7);
+ const [step, setStep] = useState(1);
+ const [showError] = useState(false);
+
+ const [formData, setFormData] = useState<FormDataType>({
+ lang: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ db_type: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ db_username: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ db_password: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ db_host: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ db_name: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ db_file: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+
+ site_name: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ contact_email: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ admin_name: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ admin_password: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ admin_email: {
+ value: '',
+ isInvalid: false,
+ errorMsg: '',
+ },
+ });
+
+ const handleChange = (params: FormDataType) => {
+ console.log(params);
+ setFormData({ ...formData, ...params });
+ };
+
+ const handleStep = () => {
+ setStep((pre) => pre + 1);
+ };
+
+ // const handleSubmit = () => {
+ // const params = {
+ // lang: formData.lang.value,
+ // db_type: formData.db_type.value,
+ // db_username: formData.db_username.value,
+ // db_password: formData.db_password.value,
+ // db_host: formData.db_host.value,
+ // db_name: formData.db_name.value,
+ // db_file: formData.db_file.value,
+ // site_name: formData.site_name.value,
+ // contact_email: formData.contact_email.value,
+ // admin_name: formData.admin_name.value,
+ // admin_password: formData.admin_password.value,
+ // admin_email: formData.admin_email.value,
+ // };
+
+ // console.log(params);
+ // };
+
+ useEffect(() => {
+ console.log('step===', Storage.get('INSTALL_STEP'));
+ }, []);
return (
- <div style={{ background: '#f5f5f5', minHeight: '100vh' }}>
+ <div className="page-wrap2">
<PageTitle title={t('install', { keyPrefix: 'page_title' })} />
<Container style={{ paddingTop: '74px' }}>
<Row className="justify-content-center">
@@ -25,14 +124,30 @@ const Index: FC = () => {
<h2 className="mb-4 text-center">{t('title')}</h2>
<Card>
<Card.Body>
- <Alert variant="danger"> show error msg </Alert>
- <FirstStep visible={step === 1} />
+ {showError && <Alert variant="danger"> show error msg </Alert>}
+
+ <FirstStep
+ visible={step === 1}
+ data={formData.lang}
+ changeCallback={handleChange}
+ nextCallback={handleStep}
+ />
- <SecondStep visible={step === 2} />
+ <SecondStep
+ visible={step === 2}
+ data={formData}
+ changeCallback={handleChange}
+ nextCallback={handleStep}
+ />
- <ThirdStep visible={step === 3} />
+ <ThirdStep visible={step === 3} nextCallback={handleStep} />
- <FourthStep visible={step === 4} />
+ <FourthStep
+ visible={step === 4}
+ data={formData}
+ changeCallback={handleChange}
+ nextCallback={handleStep}
+ />
<Fifth visible={step === 5} />
{step === 6 && (
diff --git a/ui/src/pages/Maintenance/index.tsx b/ui/src/pages/Maintenance/index.tsx
index 3a2c2d86..560108bf 100644
--- a/ui/src/pages/Maintenance/index.tsx
+++ b/ui/src/pages/Maintenance/index.tsx
@@ -8,15 +8,19 @@ const Index = () => {
keyPrefix: 'page_maintenance',
});
return (
- <Container className="d-flex flex-column justify-content-center align-items-center page-wrap2">
- <PageTitle title={t('maintenance', { keyPrefix: 'page_title' })} />
- <div
- className="mb-4 text-secondary"
- style={{ fontSize: '120px', lineHeight: 1.2 }}>
- (=‘_‘=)
- </div>
- <div className="text-center mb-4">{t('description')}</div>
- </Container>
+ <div className="page-wrap2">
+ <Container
+ className="d-flex flex-column justify-content-center align-items-center"
+ style={{ minHeight: '100vh' }}>
+ <PageTitle title={t('maintenance', { keyPrefix: 'page_title' })} />
+ <div
+ className="mb-4 text-secondary"
+ style={{ fontSize: '120px', lineHeight: 1.2 }}>
+ (=‘_‘=)
+ </div>
+ <div className="text-center mb-4">{t('description')}</div>
+ </Container>
+ </div>
);
};
diff --git a/ui/src/pages/Upgrade/index.tsx b/ui/src/pages/Upgrade/index.tsx
index aee2a37a..c65c9098 100644
--- a/ui/src/pages/Upgrade/index.tsx
+++ b/ui/src/pages/Upgrade/index.tsx
@@ -14,38 +14,40 @@ const Index = () => {
setStep(2);
};
return (
- <Container className="page-wrap2" style={{ paddingTop: '74px' }}>
- <PageTitle title={t('upgrade', { keyPrefix: 'page_title' })} />
- <Row className="justify-content-center">
- <Col lg={6}>
- <h2 className="text-center mb-4">{t('title')}</h2>
- <Card>
- <Card.Body>
- {step === 1 && (
- <>
- <h5>{t('update_title')}</h5>
- <Trans
- i18nKey="upgrade.update_description"
- components={{ 1: <p /> }}
- />
- <Button className="float-end" onClick={handleUpdate}>
- {t('update_btn')}
- </Button>
- </>
- )}
+ <div className="page-wrap2">
+ <Container style={{ paddingTop: '74px' }}>
+ <PageTitle title={t('upgrade', { keyPrefix: 'page_title' })} />
+ <Row className="justify-content-center">
+ <Col lg={6}>
+ <h2 className="text-center mb-4">{t('title')}</h2>
+ <Card>
+ <Card.Body>
+ {step === 1 && (
+ <>
+ <h5>{t('update_title')}</h5>
+ <Trans
+ i18nKey="upgrade.update_description"
+ components={{ 1: <p /> }}
+ />
+ <Button className="float-end" onClick={handleUpdate}>
+ {t('update_btn')}
+ </Button>
+ </>
+ )}
- {step === 2 && (
- <>
- <h5>{t('done_title')}</h5>
- <p>{t('done_desscription')}</p>
- <Button className="float-end">{t('done_btn')}</Button>
- </>
- )}
- </Card.Body>
- </Card>
- </Col>
- </Row>
- </Container>
+ {step === 2 && (
+ <>
+ <h5>{t('done_title')}</h5>
+ <p>{t('done_desscription')}</p>
+ <Button className="float-end">{t('done_btn')}</Button>
+ </>
+ )}
+ </Card.Body>
+ </Card>
+ </Col>
+ </Row>
+ </Container>
+ </div>
);
};
diff --git a/ui/src/pages/Users/Personal/components/DefaultList/index.tsx b/ui/src/pages/Users/Personal/components/DefaultList/index.tsx
index 980a2df3..e249067f 100644
--- a/ui/src/pages/Users/Personal/components/DefaultList/index.tsx
+++ b/ui/src/pages/Users/Personal/components/DefaultList/index.tsx
@@ -34,7 +34,7 @@ const Index: FC<Props> = ({ visible, tabName, data }) => {
: null}
</a>
</h6>
- <div className="d-flex align-items-center fs-14 text-secondary mb-2">
+ <div className="d-flex flex-wrap align-items-center fs-14 text-secondary mb-2">
{tabName === 'bookmarks' && (
<>
<BaseUserCard data={item.user_info} showAvatar={false} />
diff --git a/ui/src/pages/Users/Personal/components/NavBar/index.tsx b/ui/src/pages/Users/Personal/components/NavBar/index.tsx
index 75fe68ee..4c98ce50 100644
--- a/ui/src/pages/Users/Personal/components/NavBar/index.tsx
+++ b/ui/src/pages/Users/Personal/components/NavBar/index.tsx
@@ -44,7 +44,10 @@ const list = [
const Index: FC<Props> = ({ slug, tabName = 'overview', isSelf }) => {
const { t } = useTranslation('translation', { keyPrefix: 'personal' });
return (
- <Nav className="pt-2 mb-4" variant="pills">
+ <Nav
+ className="pt-2 mb-4 flex-nowrap"
+ variant="pills"
+ style={{ overflow: 'auto' }}>
{list.map((item) => {
if (item.role && !isSelf) {
return null;
diff --git a/ui/src/pages/Users/Personal/components/UserInfo/index.tsx b/ui/src/pages/Users/Personal/components/UserInfo/index.tsx
index 880b810f..c4c6d8b5 100644
--- a/ui/src/pages/Users/Personal/components/UserInfo/index.tsx
+++ b/ui/src/pages/Users/Personal/components/UserInfo/index.tsx
@@ -16,7 +16,7 @@ const Index: FC<Props> = ({ data }) => {
return null;
}
return (
- <div className="d-flex mb-4">
+ <div className="d-flex flex-column flex-md-row mb-4">
{data?.status !== 'deleted' ? (
<Link to={`/users/${data.username}`} reloadDocument>
<Avatar avatar={data.avatar} size="160px" searchStr="s=128" />
@@ -25,7 +25,7 @@ const Index: FC<Props> = ({ data }) => {
<Avatar avatar={data.avatar} size="160px" searchStr="s=128" />
)}
- <div className="ms-4">
+ <div className="ms-0 ms-md-4 mt-4 mt-md-0">
<div className="d-flex align-items-center mb-2">
{data?.status !== 'deleted' ? (
<Link
@@ -51,7 +51,7 @@ const Index: FC<Props> = ({ data }) => {
</div>
<div className="text-secondary mb-4">@{data.username}</div>
- <div className="d-flex mb-3">
+ <div className="d-flex flex-wrap mb-3">
<div className="me-3">
<strong className="fs-5">{data.rank || 0}</strong>
<span className="text-secondary"> {t('x_reputation')}</span>
diff --git a/ui/src/pages/Users/Personal/components/Votes/index.tsx b/ui/src/pages/Users/Personal/components/Votes/index.tsx
index fa5023db..86a37aba 100644
--- a/ui/src/pages/Users/Personal/components/Votes/index.tsx
+++ b/ui/src/pages/Users/Personal/components/Votes/index.tsx
@@ -18,7 +18,7 @@ const Index: FC<Props> = ({ visible, data }) => {
return (
<ListGroupItem className="d-flex py-3 px-0" key={item.object_id}>
<div
- className="me-3 text-end text-secondary"
+ className="me-3 text-end text-secondary flex-shrink-0"
style={{ width: '80px' }}>
{item.vote_type}
</div>
diff --git a/ui/src/pages/Users/Personal/index.tsx b/ui/src/pages/Users/Personal/index.tsx
index 4720db93..12232244 100644
--- a/ui/src/pages/Users/Personal/index.tsx
+++ b/ui/src/pages/Users/Personal/index.tsx
@@ -64,9 +64,9 @@ const Personal: FC = () => {
xxl={3}
lg={4}
sm={12}
- className="d-flex justify-content-end mt-5 mt-lg-0">
+ className="d-flex justify-content-start justify-content-md-end">
{isSelf && (
- <div>
+ <div className="mb-3">
<Button
variant="outline-secondary"
href="/users/settings/profile"
@@ -79,7 +79,7 @@ const Personal: FC = () => {
</Row>
<Row className="justify-content-center">
- <Col lg={10}>
+ <Col lg={12}>
<NavBar tabName={tabName} slug={username} isSelf={isSelf} />
</Col>
<Col xxl={7} lg={8} sm={12}>