Merge branch 'react-practice-02' into feat/add-user-rooms-to-global-state

This commit is contained in:
2023-11-22 22:11:23 +07:00
11 changed files with 20 additions and 39 deletions
+2 -2
View File
@@ -26,8 +26,8 @@ const queryClient = new QueryClient({
defaultOptions: { defaultOptions: {
queries: { queries: {
staleTime: 60 * 1000, staleTime: 60 * 1000,
}, }
}, }
}); });
function App() { function App() {
@@ -16,10 +16,10 @@ const variations: IVariations = {
background-color: var(--danger-btn-color); background-color: var(--danger-btn-color);
color: var(--light-text); color: var(--light-text);
`, `,
}; } as const;
interface IButtonStyle { interface IButtonStyle {
variations?: keyof IVariations; variations?: keyof typeof variations;
} }
const Button = styled.button<IButtonStyle>` const Button = styled.button<IButtonStyle>`
@@ -15,7 +15,6 @@ interface IConfirmMessage {
const ConfirmMessage = memo( const ConfirmMessage = memo(
({ message, disabled, onConfirm, onCloseModal }: IConfirmMessage) => { ({ message, disabled, onConfirm, onCloseModal }: IConfirmMessage) => {
return ( return (
<StyledConfirmDelete> <StyledConfirmDelete>
<p>{message}</p> <p>{message}</p>
@@ -1,4 +1,4 @@
import styled from "styled-components"; import styled from 'styled-components';
const StyledConfirmDelete = styled.div` const StyledConfirmDelete = styled.div`
width: 450px; width: 450px;
-16
View File
@@ -43,20 +43,6 @@ const ROOM_PAGE = {
], ],
}; };
const INIT_VALUE_USER_FORM = {
name: '',
id: 0,
identifiedCode: '',
phone: '',
};
const INIT_VALUE_ROOM_FORM = {
name: '',
id: 0,
price: 0,
discount: 0,
};
const FORM = { const FORM = {
EDIT: 'edit', EDIT: 'edit',
DELETE: 'delete', DELETE: 'delete',
@@ -76,6 +62,4 @@ export {
FORM, FORM,
REGEX, REGEX,
ORDERBY_OPTIONS, ORDERBY_OPTIONS,
INIT_VALUE_USER_FORM,
INIT_VALUE_ROOM_FORM,
}; };
-2
View File
@@ -2,5 +2,3 @@ export const DASHBOARD = '/dashboard';
export const USER = '/user'; export const USER = '/user';
export const ROOM = '/room'; export const ROOM = '/room';
export const OTHER_PATH = '*'; export const OTHER_PATH = '*';
export const USER_PATH = 'users';
export const ROOM_PATH = 'rooms';
+5 -5
View File
@@ -1,9 +1,9 @@
import toast from "react-hot-toast"; import toast from 'react-hot-toast';
import { useQuery } from "@tanstack/react-query"; import { useQuery } from '@tanstack/react-query';
import { useSearchParams } from "react-router-dom"; import { useSearchParams } from 'react-router-dom';
// Services // Services
import { getAllRooms } from "@service/roomServices"; import { getAllRooms } from '@service/roomServices';
/** /**
* Fetch room from database * Fetch room from database
@@ -13,7 +13,7 @@ const useRooms = () => {
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
const sortByValue = searchParams.get('sortBy') || 'id'; const sortByValue = searchParams.get('sortBy') || 'id';
const orderByValue = searchParams.get('orderBy') || 'asc'; const orderByValue = searchParams.get('orderBy') || 'asc';
const phoneSearch = searchParams.get('search') || '' const phoneSearch = searchParams.get('search') || '';
const { const {
isLoading, isLoading,
+5 -5
View File
@@ -1,9 +1,9 @@
import toast from "react-hot-toast"; import toast from 'react-hot-toast';
import { useQuery } from "@tanstack/react-query"; import { useQuery } from '@tanstack/react-query';
import { useSearchParams } from "react-router-dom"; import { useSearchParams } from 'react-router-dom';
// Services // Services
import { getAllUsers } from "@service/userServices"; import { getAllUsers } from '@service/userServices';
/** /**
* Fetch data of users from database * Fetch data of users from database
@@ -13,7 +13,7 @@ const useUsers = () => {
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
const sortByValue = searchParams.get('sortBy') || 'id'; const sortByValue = searchParams.get('sortBy') || 'id';
const orderByValue = searchParams.get('orderBy') || 'asc'; const orderByValue = searchParams.get('orderBy') || 'asc';
const phoneSearch = searchParams.get('search') || '' const phoneSearch = searchParams.get('search') || '';
const { const {
isLoading, isLoading,
@@ -25,7 +25,7 @@ const getAllRooms = async (
.from(ROOMS_TABLE) .from(ROOMS_TABLE)
.select('*') .select('*')
.order(sortBy, { ascending: orderBy === 'asc' }) .order(sortBy, { ascending: orderBy === 'asc' })
.like('name', `%${roomName}%`); .ilike('name', `%${roomName}%`);
if (error) { if (error) {
console.error(error.message); console.error(error.message);
@@ -1,8 +1,8 @@
import { createClient } from "@supabase/supabase-js"; import { createClient } from '@supabase/supabase-js';
import { Database } from "@type/supabase"; import { Database } from '@type/supabase';
// Constants // Constants
import { supabaseKey, supabaseUrl } from "@constant/config"; import { supabaseKey, supabaseUrl } from '@constant/config';
const supabase = createClient<Database>(supabaseUrl, supabaseKey!); const supabase = createClient<Database>(supabaseUrl, supabaseKey!);
@@ -65,7 +65,7 @@ const getAllUsers = async (
.from(USERS_TABLE) .from(USERS_TABLE)
.select('*') .select('*')
.order(sortBy, { ascending: orderBy === 'asc' }) .order(sortBy, { ascending: orderBy === 'asc' })
.like('phone', `%${phoneSearch}%`); .ilike('phone', `%${phoneSearch}%`);
if (error) { if (error) {
console.error(error.message); console.error(error.message);