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

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

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

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

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

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

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

Loading…
Cancel
Save