mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-22 13:38:51 +00:00
Format code and update comment section
This commit is contained in:
@@ -3,7 +3,6 @@ import isPropValid from '@emotion/is-prop-valid';
|
|||||||
import { StyleSheetManager } from 'styled-components';
|
import { StyleSheetManager } from 'styled-components';
|
||||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
||||||
import { useEffect, useMemo, useReducer } from 'react';
|
import { useEffect, useMemo, useReducer } from 'react';
|
||||||
// import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
|
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import AppLayout from './components/AppLayout';
|
import AppLayout from './components/AppLayout';
|
||||||
@@ -72,7 +71,6 @@ function App() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
{/* <ReactQueryDevtools initialIsOpen={false} /> */}
|
|
||||||
<StyleSheetManager shouldForwardProp={shouldForwardProp}>
|
<StyleSheetManager shouldForwardProp={shouldForwardProp}>
|
||||||
<UserRoomAvailableContext.Provider value={store}>
|
<UserRoomAvailableContext.Provider value={store}>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import { FormProvider, useForm } from 'react-hook-form';
|
|||||||
|
|
||||||
// Styled
|
// Styled
|
||||||
import Input from '@commonStyle/Input.ts';
|
import Input from '@commonStyle/Input.ts';
|
||||||
import { FormBtn } from './styled.ts';
|
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
import { REQUIRED_FIELD_ERROR } from '@constant/formValidateMessage.ts';
|
import { REQUIRED_FIELD_ERROR } from '@constant/formValidateMessage.ts';
|
||||||
@@ -104,24 +103,24 @@ const BookingForm = ({ onCloseModal, booking }: IBookingFormProp) => {
|
|||||||
reset();
|
reset();
|
||||||
onCloseModal?.();
|
onCloseModal?.();
|
||||||
|
|
||||||
// Update room in global state
|
// Update room status in global state
|
||||||
// Old room
|
// Reset status old room
|
||||||
dispatch!({
|
dispatch!({
|
||||||
type: 'updateStatusRoom',
|
type: 'updateStatusRoom',
|
||||||
payload: [{ id: booking!.rooms!.id, status: false }],
|
payload: [{ id: booking!.rooms!.id, status: false }],
|
||||||
});
|
});
|
||||||
|
|
||||||
// New room
|
// Change status new room
|
||||||
dispatch!({
|
dispatch!({
|
||||||
type: 'updateStatusRoom',
|
type: 'updateStatusRoom',
|
||||||
payload: [{ id: newBooking.roomId, status: true }],
|
payload: [{ id: newBooking.roomId, status: true }],
|
||||||
});
|
});
|
||||||
|
|
||||||
// Update room available in server
|
// Update room status in server
|
||||||
// Old room
|
// Reset status old room
|
||||||
await updateRoomStatus(booking!.rooms!.id, false);
|
await updateRoomStatus(booking!.rooms!.id, false);
|
||||||
|
|
||||||
// New room
|
// Change status new room
|
||||||
await updateRoomStatus(newBooking.roomId, true);
|
await updateRoomStatus(newBooking.roomId, true);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -277,7 +276,7 @@ const BookingForm = ({ onCloseModal, booking }: IBookingFormProp) => {
|
|||||||
</Form.Row>
|
</Form.Row>
|
||||||
|
|
||||||
<Form.Action>
|
<Form.Action>
|
||||||
<FormBtn
|
<Form.Button
|
||||||
type="submit"
|
type="submit"
|
||||||
name="submit"
|
name="submit"
|
||||||
disabled={!isDirty || !isValid || isLoading}
|
disabled={!isDirty || !isValid || isLoading}
|
||||||
@@ -287,10 +286,10 @@ const BookingForm = ({ onCloseModal, booking }: IBookingFormProp) => {
|
|||||||
? 'Add'
|
? 'Add'
|
||||||
: 'Save'
|
: 'Save'
|
||||||
}
|
}
|
||||||
</FormBtn>
|
</Form.Button>
|
||||||
<FormBtn type="button" variations="secondary" onClick={onCloseModal}>
|
<Form.Button type="button" variations="secondary" onClick={onCloseModal}>
|
||||||
Close
|
Close
|
||||||
</FormBtn>
|
</Form.Button>
|
||||||
</Form.Action>
|
</Form.Action>
|
||||||
</Form>
|
</Form>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
|
|||||||
@@ -29,7 +29,15 @@ interface IBookingRow {
|
|||||||
|
|
||||||
const BookingRow = ({ booking }: IBookingRow) => {
|
const BookingRow = ({ booking }: IBookingRow) => {
|
||||||
const { checkOutBooking } = useCheckOut();
|
const { checkOutBooking } = useCheckOut();
|
||||||
const { id, users, startDate, endDate, rooms, amount, status } = booking;
|
const {
|
||||||
|
id,
|
||||||
|
users,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
rooms,
|
||||||
|
amount,
|
||||||
|
status
|
||||||
|
} = booking;
|
||||||
const statusText = status
|
const statusText = status
|
||||||
? 'Check in'
|
? 'Check in'
|
||||||
: 'Check out';
|
: 'Check out';
|
||||||
|
|||||||
@@ -20,8 +20,18 @@ import { useBookings } from '@hook/bookings/useBookings';
|
|||||||
import { TBookingResponse } from '@type/booking';
|
import { TBookingResponse } from '@type/booking';
|
||||||
|
|
||||||
const BookingTable = () => {
|
const BookingTable = () => {
|
||||||
const columnName = ['User', 'Date', 'Room', 'Amount', 'Status'];
|
const columnName = [
|
||||||
const { isLoading, bookings, count } = useBookings();
|
'User',
|
||||||
|
'Date',
|
||||||
|
'Room',
|
||||||
|
'Amount',
|
||||||
|
'Status'
|
||||||
|
];
|
||||||
|
const {
|
||||||
|
isLoading,
|
||||||
|
bookings,
|
||||||
|
count
|
||||||
|
} = useBookings();
|
||||||
|
|
||||||
const renderBookingRow = useCallback(
|
const renderBookingRow = useCallback(
|
||||||
(booking: TBookingResponse) => (
|
(booking: TBookingResponse) => (
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
// Components
|
|
||||||
import Button from '@commonStyle/Button';
|
|
||||||
|
|
||||||
const StyledBooking = styled.main`
|
const StyledBooking = styled.main`
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
padding-bottom: 100px;
|
padding-bottom: 100px;
|
||||||
@@ -18,19 +15,10 @@ const Title = styled.h2`
|
|||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const FormBtn = styled(Button)`
|
|
||||||
width: 100%;
|
|
||||||
|
|
||||||
&:disabled,
|
|
||||||
&[disabled] {
|
|
||||||
background-color: var(--disabled-btn-color);
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StyledOperationTable = styled.div`
|
const StyledOperationTable = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 30px;
|
gap: 30px;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export { StyledBooking, Title, StyledOperationTable, FormBtn };
|
export { StyledBooking, Title, StyledOperationTable };
|
||||||
|
|||||||
Reference in New Issue
Block a user