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: {
queries: {
staleTime: 60 * 1000,
},
},
}
}
});
function App() {
@@ -16,10 +16,10 @@ const variations: IVariations = {
background-color: var(--danger-btn-color);
color: var(--light-text);
`,
};
} as const;
interface IButtonStyle {
variations?: keyof IVariations;
variations?: keyof typeof variations;
}
const Button = styled.button<IButtonStyle>`
@@ -15,7 +15,6 @@ interface IConfirmMessage {
const ConfirmMessage = memo(
({ message, disabled, onConfirm, onCloseModal }: IConfirmMessage) => {
return (
<StyledConfirmDelete>
<p>{message}</p>
@@ -1,4 +1,4 @@
import styled from "styled-components";
import styled from 'styled-components';
const StyledConfirmDelete = styled.div`
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 = {
EDIT: 'edit',
DELETE: 'delete',
@@ -76,6 +62,4 @@ export {
FORM,
REGEX,
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 ROOM = '/room';
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 { useQuery } from "@tanstack/react-query";
import { useSearchParams } from "react-router-dom";
import toast from 'react-hot-toast';
import { useQuery } from '@tanstack/react-query';
import { useSearchParams } from 'react-router-dom';
// Services
import { getAllRooms } from "@service/roomServices";
import { getAllRooms } from '@service/roomServices';
/**
* Fetch room from database
@@ -13,7 +13,7 @@ const useRooms = () => {
const [searchParams] = useSearchParams();
const sortByValue = searchParams.get('sortBy') || 'id';
const orderByValue = searchParams.get('orderBy') || 'asc';
const phoneSearch = searchParams.get('search') || ''
const phoneSearch = searchParams.get('search') || '';
const {
isLoading,
+5 -5
View File
@@ -1,9 +1,9 @@
import toast from "react-hot-toast";
import { useQuery } from "@tanstack/react-query";
import { useSearchParams } from "react-router-dom";
import toast from 'react-hot-toast';
import { useQuery } from '@tanstack/react-query';
import { useSearchParams } from 'react-router-dom';
// Services
import { getAllUsers } from "@service/userServices";
import { getAllUsers } from '@service/userServices';
/**
* Fetch data of users from database
@@ -13,7 +13,7 @@ const useUsers = () => {
const [searchParams] = useSearchParams();
const sortByValue = searchParams.get('sortBy') || 'id';
const orderByValue = searchParams.get('orderBy') || 'asc';
const phoneSearch = searchParams.get('search') || ''
const phoneSearch = searchParams.get('search') || '';
const {
isLoading,
@@ -25,7 +25,7 @@ const getAllRooms = async (
.from(ROOMS_TABLE)
.select('*')
.order(sortBy, { ascending: orderBy === 'asc' })
.like('name', `%${roomName}%`);
.ilike('name', `%${roomName}%`);
if (error) {
console.error(error.message);
@@ -1,8 +1,8 @@
import { createClient } from "@supabase/supabase-js";
import { Database } from "@type/supabase";
import { createClient } from '@supabase/supabase-js';
import { Database } from '@type/supabase';
// Constants
import { supabaseKey, supabaseUrl } from "@constant/config";
import { supabaseKey, supabaseUrl } from '@constant/config';
const supabase = createClient<Database>(supabaseUrl, supabaseKey!);
@@ -65,7 +65,7 @@ const getAllUsers = async (
.from(USERS_TABLE)
.select('*')
.order(sortBy, { ascending: orderBy === 'asc' })
.like('phone', `%${phoneSearch}%`);
.ilike('phone', `%${phoneSearch}%`);
if (error) {
console.error(error.message);