Fix style code format

This commit is contained in:
2023-10-31 09:57:10 +07:00
parent 7553e5d170
commit 041b27617c
5 changed files with 71 additions and 31 deletions
@@ -0,0 +1,37 @@
// prettier-ignore
const USER_PAGE = {
SORTBY_OPTIONS: [
{
value: 'id',
label: 'Sort by id',
},
{
value: 'name',
label: 'Sort by name',
},
{
value: 'identifiedCode',
label: 'Sort by identified code',
},
{
value: 'phone',
label: 'Sort by phone',
},
{
value: 'roomId',
label: 'Sort by room',
},
],
ORDERBY_OPTIONS: [
{
value: 'asc',
label: 'Ascending',
},
{
value: 'desc',
label: 'Descending',
},
],
};
export { USER_PAGE };
+14 -3
View File
@@ -56,9 +56,20 @@ const getValueUser = (user: TUser | null = null, prop: string): string => {
}; };
const searchQuery = (phone: string, sort: string, order: string) => { const searchQuery = (phone: string, sort: string, order: string) => {
const phoneParams = phone ? 'phone_like=' + phone : ''; // prettier-ignore
const sortParams = sort ? '_sort=' + sort : ''; const phoneParams = phone
const orderParams = order ? '_order=' + order : ''; ? 'phone_like=' + phone
: '';
// prettier-ignore
const sortParams = sort
? '_sort=' + sort
: '';
// prettier-ignore
const orderParams = order
? '_order=' + order
: '';
const finalParam = [phoneParams, sortParams, orderParams]; const finalParam = [phoneParams, sortParams, orderParams];
let query = ''; let query = '';
let isFirstParam = true; let isFirstParam = true;
+9 -2
View File
@@ -24,8 +24,15 @@ export const useFetch = (
setIsPending(true); setIsPending(true);
// Set default value // Set default value
const sortBy = tempSortBy ? tempSortBy : DEFAULT_SORT_BY; // prettier-ignore
const orderBy = tempOrderBy ? tempOrderBy : DEFAULT_ORDER_BY; const sortBy = tempSortBy
? tempSortBy
: DEFAULT_SORT_BY;
// prettier-ignore
const orderBy = tempOrderBy
? tempOrderBy
: DEFAULT_ORDER_BY;
// Query search // Query search
const query = searchQuery(phoneNum, sortBy, orderBy); const query = searchQuery(phoneNum, sortBy, orderBy);
+8 -8
View File
@@ -198,8 +198,8 @@ const UserForm = ({
label="Full Name" label="Full Name"
error={ error={
// prettier-ignore // prettier-ignore
errors.name && dirty.name ? errors.name && dirty.name
(errors.name as string) ? (errors.name as string)
: '' : ''
} }
> >
@@ -231,8 +231,8 @@ const UserForm = ({
label="Phone" label="Phone"
error={ error={
// prettier-ignore // prettier-ignore
errors.phone && dirty.phone ? errors.phone && dirty.phone
(errors.phone as string) ? (errors.phone as string)
: '' : ''
} }
> >
@@ -248,8 +248,8 @@ const UserForm = ({
label="Room" label="Room"
error={ error={
// prettier-ignore // prettier-ignore
errors.roomId && dirty.roomId ? errors.roomId && dirty.roomId
(errors.roomId as string) ? (errors.roomId as string)
: '' : ''
} }
> >
@@ -265,8 +265,8 @@ const UserForm = ({
label="Address" label="Address"
error={ error={
// prettier-ignore // prettier-ignore
errors.address && dirty.address ? errors.address && dirty.address
(errors.address as string) ? (errors.address as string)
: '' : ''
} }
> >
+3 -18
View File
@@ -28,6 +28,7 @@ import Spinner from '../../commons/styles/Spinner';
// Utils // Utils
import { sendRequest } from '../../helpers/sendRequest'; import { sendRequest } from '../../helpers/sendRequest';
import { USER_PAGE } from '../../constants/variables';
interface IUserRow { interface IUserRow {
user: TUser; user: TUser;
@@ -142,25 +143,9 @@ const UserTable = ({
<> <>
<Direction> <Direction>
<StyledOperationTable> <StyledOperationTable>
<OrderBy <OrderBy options={USER_PAGE.ORDERBY_OPTIONS} />
options={[
{ value: 'asc', label: 'Ascending' },
{ value: 'desc', label: 'Descending' },
]}
/>
<SortBy <SortBy options={USER_PAGE.SORTBY_OPTIONS} />
options={[
{ value: 'id', label: 'Sort by id' },
{ value: 'name', label: 'Sort by name' },
{
value: 'identifiedCode',
label: 'Sort by identified code',
},
{ value: 'phone', label: 'Sort by phone' },
{ value: 'roomId', label: 'Sort by room' },
]}
/>
<Search setPhoneSearch={setPhoneSearch} /> <Search setPhoneSearch={setPhoneSearch} />
</StyledOperationTable> </StyledOperationTable>