refactor: Component/BackBtn

feature/price_manager
Lei OT 1 year ago
parent 733c1c0fec
commit 96c8017271

@ -0,0 +1,16 @@
import { createContext, useContext, useEffect, useState } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { Button } from 'antd';
import { isNotEmpty } from '@/utils/commons';
const BackBtn = ({to, ...props}) => {
const { t } = useTranslation();
const navigate = useNavigate();
return (
<>
{isNotEmpty(to) ? <Link to={to}>{t('Back')}l</Link> : <Button type='link' onClick={() => navigate(-1)}>{t('Back')}</Button>}
</>
);
};
export default BackBtn;

@ -5,6 +5,7 @@ import { PlusOutlined } from '@ant-design/icons';
import * as config from '@/config'; import * as config from '@/config';
import useAuthStore from '@/stores/Auth'; import useAuthStore from '@/stores/Auth';
import { getFeedbackDetail, getCustomerFeedbackDetail, getFeedbackImages, getFeedbackInfo, removeFeedbackImages, postFeedbackInfo } from '@/stores/Feedback'; import { getFeedbackDetail, getCustomerFeedbackDetail, getFeedbackImages, getFeedbackInfo, removeFeedbackImages, postFeedbackInfo } from '@/stores/Feedback';
import BackBtn from '@/components/BackBtn';
const { Title, Text, Paragraph } = Typography; const { Title, Text, Paragraph } = Typography;
@ -79,9 +80,7 @@ function Detail() {
<Row gutter={16}> <Row gutter={16}>
<Col span={20}></Col> <Col span={20}></Col>
<Col span={4}> <Col span={4}>
<Button type='link' onClick={() => navigate('/feedback')}> <BackBtn />
Back
</Button>
</Col> </Col>
</Row> </Row>
<Row gutter={16}> <Row gutter={16}>

@ -5,6 +5,7 @@ import { PlusOutlined } from "@ant-design/icons";
import * as config from "@/config"; import * as config from "@/config";
import useAuthStore from '@/stores/Auth'; import useAuthStore from '@/stores/Auth';
import { getFeedbackDetail, getFeedbackImages, getFeedbackInfo, removeFeedbackImages, postFeedbackInfo } from '@/stores/Feedback'; import { getFeedbackDetail, getFeedbackImages, getFeedbackInfo, removeFeedbackImages, postFeedbackInfo } from '@/stores/Feedback';
import BackBtn from "@/components/BackBtn";
const { Title, Text, Paragraph } = Typography; const { Title, Text, Paragraph } = Typography;
function Detail() { function Detail() {
@ -81,9 +82,7 @@ function Detail() {
</Col> </Col>
<Col span={4}> <Col span={4}>
<Button type="link" onClick={() => navigate("/feedback")}> <BackBtn />
Back
</Button>
</Col> </Col>
</Row> </Row>
<Row gutter={16}> <Row gutter={16}>

@ -9,6 +9,7 @@ import { isNotEmpty } from "@/utils/commons";
import * as config from "@/config"; import * as config from "@/config";
import dayjs from "dayjs"; import dayjs from "dayjs";
import useAuthStore from '@/stores/Auth'; import useAuthStore from '@/stores/Auth';
import BackBtn from '@/components/BackBtn';
const { Title,Text } = Typography; const { Title,Text } = Typography;
const { TextArea } = Input; const { TextArea } = Input;
@ -337,9 +338,7 @@ function Detail() {
<Title level={4}>Reference Number: {invoiceGroupInfo.VGroupInfo}</Title> <Title level={4}>Reference Number: {invoiceGroupInfo.VGroupInfo}</Title>
</Col> </Col>
<Col span={4}> <Col span={4}>
<Button type="link" onClick={() => navigate("/invoice")}> <BackBtn />
Back
</Button>
</Col> </Col>
</Row> </Row>
<Title level={5}></Title> <Title level={5}></Title>

@ -10,6 +10,8 @@ import usePresets from '@/hooks/usePresets';
import SearchForm from '@/components/SearchForm'; import SearchForm from '@/components/SearchForm';
import useAuthStore from '@/stores/Auth'; import useAuthStore from '@/stores/Auth';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import BackBtn from '@/components/BackBtn';
const { Title } = Typography; const { Title } = Typography;
function Paid() { function Paid() {
@ -87,9 +89,7 @@ function Paid() {
/> />
</Col> </Col>
<Col span={4}> <Col span={4}>
<Button type='link' onClick={() => navigate('/invoice')}> <BackBtn to={'/invoice'} />
Back
</Button>
</Col> </Col>
</Row> </Row>
<Row> <Row>

@ -7,6 +7,7 @@ import { useStore } from "@/stores/StoreContext.js";
import * as config from "@/config"; import * as config from "@/config";
import { formatDate, isNotEmpty } from "@/utils/commons"; import { formatDate, isNotEmpty } from "@/utils/commons";
import useAuthStore from '@/stores/Auth'; import useAuthStore from '@/stores/Auth';
import BackBtn from '@/components/BackBtn';
const { Title } = Typography; const { Title } = Typography;
@ -52,9 +53,7 @@ function PaidDetail(){
<Col span={20}> <Col span={20}>
</Col> </Col>
<Col span={4}> <Col span={4}>
<Button type="link" onClick={() => navigate("/invoice/paid")}> <BackBtn />
Back
</Button>
</Col> </Col>
</Row> </Row>
<Title level={3}></Title> <Title level={3}></Title>

@ -5,6 +5,7 @@ import * as comm from '@/utils/commons';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { fetchNoticeDetail } from '@/stores/Notice'; import { fetchNoticeDetail } from '@/stores/Notice';
import useAuthStore from '@/stores/Auth'; import useAuthStore from '@/stores/Auth';
import BackBtn from '@/components/BackBtn';
const { Title, Paragraph } = Typography; const { Title, Paragraph } = Typography;
@ -33,7 +34,7 @@ function Detail() {
</Paragraph> </Paragraph>
</Col> </Col>
<Col span={4}> <Col span={4}>
<NavLink to='/notice'>{t('Back')}</NavLink> <BackBtn />
</Col> </Col>
</Row> </Row>
</Space> </Space>

@ -8,6 +8,7 @@ import {
} from '@ant-design/icons'; } from '@ant-design/icons';
import { useStore } from '@/stores/StoreContext.js'; import { useStore } from '@/stores/StoreContext.js';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import BackBtn from '@/components/BackBtn';
const { Title, Paragraph } = Typography; const { Title, Paragraph } = Typography;
const { TextArea } = Input; const { TextArea } = Input;
@ -158,7 +159,7 @@ function Detail() {
<Title level={4}>{t('group:RefNo')}: {reservationDetail.referenceNumber}; {t('group:ArrivalDate')}: {reservationDetail.arrivalDate};</Title> <Title level={4}>{t('group:RefNo')}: {reservationDetail.referenceNumber}; {t('group:ArrivalDate')}: {reservationDetail.arrivalDate};</Title>
</Col> </Col>
<Col span={4}> <Col span={4}>
<Button type="link" onClick={() => navigate('/reservation/newest?back')}>{t('Back')}</Button> <BackBtn to={'/reservation/newest?back'} />
</Col> </Col>
</Row> </Row>
<Row gutter={{ md: 24 }}> <Row gutter={{ md: 24 }}>

Loading…
Cancel
Save