Merge branch 'develop' of ssh://thamluu.synology.me:222/sam/fuware into develop

This commit is contained in:
Duy Dang
2024-07-04 15:13:49 +08:00
38 changed files with 592 additions and 152 deletions

16
frontend/src/api/house.js Normal file
View File

@ -0,0 +1,16 @@
import { protocol } from './index'
import { GET_HOUSES_LIST, POST_HOUSE_CREATE } from './url'
export const postCreateHouse = (payload) => {
return protocol.post(POST_HOUSE_CREATE, payload)
}
export const getAllHouse = ({ page, pageSize }) => {
return protocol.get(
GET_HOUSES_LIST({
page,
pageSize,
}),
{},
)
}

View File

@ -3,3 +3,6 @@ export const POST_LOGOUT = '/api/auth/logout'
export const POST_REFRESH = '/api/auth/refresh'
export const GET_USER_PROFILE = '/api/user/me'
export const PUT_UPDATE_USER_PROFILE = '/api/user/update-profile'
export const POST_HOUSE_CREATE = '/api/house/create'
export const GET_HOUSES_LIST = ({ page, pageSize }) =>
`/api/house/all?page=${page}&pageSize=${pageSize}`

View File

@ -1,10 +1,10 @@
import ConfirmPopup from '@components/common/ConfirmPopup'
import Popup from '@components/common/Popup'
import TextInput from '@components/common/TextInput'
import Textarea from '@components/common/Textarea'
import { createForm } from '@felte/solid'
import { validator } from '@felte/validator-yup'
import useLanguage from '@hooks/useLanguage'
import useToast from '@hooks/useToast'
import {
IconAddressBook,
IconCirclePlus,
@ -12,7 +12,7 @@ import {
IconInfoCircle,
IconVector,
} from '@tabler/icons-solidjs'
import { For, Show, createSignal } from 'solid-js'
import { For, Show, createComponent, createSignal } from 'solid-js'
import * as yup from 'yup'
import AreaItem from './AreaItem'
@ -33,7 +33,6 @@ export default function AreaAdd(props) {
const [openModal, setOpenModal] = createSignal(false)
const [data, setData] = createSignal([])
const { language, isRequired } = useLanguage()
const notify = useToast()
const { form, reset, errors } = createForm({
extend: [validator({ schema: areaSchema(language, isRequired) })],
onSubmit: async (values) => {
@ -50,11 +49,18 @@ export default function AreaAdd(props) {
setOpenModal(true)
}
const onDeleteAreaItem = (index) => {
const onConfirmDelete = (index) => {
setData((prev) => [...prev.slice(0, index), ...prev.slice(index + 1)])
}
// console.log(error())
const onClickDeleteItem = (index) => {
createComponent(ConfirmPopup, {
title: language?.message['CONFIRM_DELETE'],
children: language?.message['CONFIRM_DELETE_NOTE'],
deleteId: index,
onConfirm: onConfirmDelete,
})
}
return (
<div class="form-control mb-3">
@ -95,9 +101,9 @@ export default function AreaAdd(props) {
{(item, index) => (
<AreaItem
{...item}
name={props.name}
formName={props.name}
key={index()}
onDelete={onDeleteAreaItem}
onDelete={onClickDeleteItem}
/>
)}
</For>

View File

@ -9,12 +9,12 @@ export default function AreaItem(props) {
<p class="text-xs">{props.description}</p>
<input
type="hidden"
name={`${props.name}.${props.key}.name`}
name={`${props.formName}.${props.key}.name`}
value={props.name}
/>
<input
type="hidden"
name={`${props.name}.${props.key}.desc`}
name={`${props.formName}.${props.key}.desc`}
value={props.description}
/>
</div>

View File

@ -5,6 +5,7 @@ import useAuth from '@hooks/useAuth'
import useToast from '@hooks/useToast'
import { A } from '@solidjs/router'
import { IconLogout, IconMenuDeep, IconUserCircle } from '@tabler/icons-solidjs'
import { Helpers } from '@utils/helper'
import { Show, onMount } from 'solid-js'
export default function Header() {
@ -71,7 +72,7 @@ export default function Header() {
</span>
</li>
<li class="mb-1">
<A href="/me">
<A href={Helpers.getRoutePath('profile')}>
<IconUserCircle size={15} />
Profile
</A>

View File

@ -5,9 +5,10 @@ import { A } from '@solidjs/router'
import {
IconBuildingWarehouse,
IconDashboard,
IconHome,
IconMapPin,
IconTriangle,
} from '@tabler/icons-solidjs'
import { Helpers } from '@utils/helper'
import { For, Show, mergeProps } from 'solid-js'
import { Dynamic } from 'solid-js/web'
import './navbar.scss'
@ -16,15 +17,15 @@ const { language } = useLanguage()
export const NAV_ITEM = (admin = false) => [
{
path: '/dashboard',
pathName: 'dashboard',
show: admin,
icon: IconDashboard,
text: language?.ui.dashboard,
},
{
path: '/house',
pathName: 'location',
show: true,
icon: IconHome,
icon: IconMapPin,
text: language?.ui.house,
},
{
@ -39,7 +40,7 @@ function NavbarItem(props) {
const merged = mergeProps({ active: true }, props)
return (
<Show
when={merged.active && merged.path}
when={merged.active && merged.pathName}
fallback={
<>
<Dynamic component={merged.icon} />
@ -47,7 +48,10 @@ function NavbarItem(props) {
</>
}
>
<A class="hover:text-fu-black" href={merged.path}>
<A
class="hover:text-fu-black"
href={Helpers.getRoutePath(merged.pathName)}
>
<Dynamic component={merged.icon} />
{merged.text}
</A>
@ -126,7 +130,7 @@ export default function Navbar() {
</span>
</li>
<li class="mb-1">
<A href="/me">Profile</A>
<A href={Helpers.getRoutePath('profile')}>Profile</A>
</li>
<li>
<a onClick={logOut}>Logout</a>

View File

@ -1,21 +1,44 @@
import { IconCirclePlus } from '@tabler/icons-solidjs'
import useLanguage from '@hooks/useLanguage'
import { IconAlertTriangle } from '@tabler/icons-solidjs'
import { Show, createSignal } from 'solid-js'
import Popup from '../Popup'
export default function ConfirmPopup(props) {
const [openModal, setOpenModal] = createSignal(true)
const { language } = useLanguage()
const onConfirm = () => {
props.onConfirm(props.deleteId)
setOpenModal(false)
}
return (
<Show when={openModal()}>
<Popup
icon={<IconCirclePlus size={20} class="text-green-500" />}
title="abc"
titleClass="text-lg"
icon={<IconAlertTriangle size={20} class="text-red-500" />}
title={props.title}
titleClass="text-md"
openModal={openModal()}
onModalClose={() => setOpenModal(false)}
class="!w-4/12 !max-w-4xl"
>
<div class="modal-body">{props.children}</div>
<div class="modal-action">
<button
type="submit"
class="btn btn-primary btn-sm"
onClick={onConfirm}
>
{language.ui.confirm}
</button>
<button
type="button"
class="btn btn-ghost btn-sm"
onClick={() => setOpenModal(false)}
>
{language.ui.cancel}
</button>
</div>
</Popup>
</Show>
)

View File

@ -0,0 +1,69 @@
import { DOTS, usePagination } from '@hooks/usePagination'
import { For, Show, splitProps } from 'solid-js'
export default function Pagination(props) {
const [localProps, onEvents] = splitProps(
props,
['currentPage', 'totalCount', 'pageSize'],
['onPageChange'],
)
const paginationRange = usePagination(localProps)
const onNext = () => {
onEvents.onPageChange(localProps.currentPage() + 1)
}
const onPrevious = () => {
onEvents.onPageChange(localProps.currentPage() - 1)
}
return (
<Show when={localProps.currentPage !== 0 || paginationRange().length > 1}>
<div class="pagination join">
<button
class="join-item btn btn-sm border border-gray-300"
disabled={localProps.currentPage() === 1}
onClick={onPrevious}
>
«
</button>
<For each={paginationRange()}>
{(page) => {
if (page === DOTS) {
return (
<button
class="join-item btn btn-sm hidden lg:block border !border-gray-300"
disabled
>
...
</button>
)
}
return (
<button
class="join-item btn btn-sm hidden lg:block border border-gray-300"
classList={{
'!block btn-primary': page === localProps.currentPage(),
}}
onClick={[onEvents.onPageChange, page]}
>
{page}
</button>
)
}}
</For>
<button
class="join-item btn btn-sm border border-gray-300"
disabled={
localProps.currentPage() ===
Math.ceil(localProps.totalCount() / localProps.pageSize())
}
onClick={onNext}
>
»
</button>
</div>
</Show>
)
}

View File

@ -0,0 +1,2 @@
export * from './Pagination'
export { default } from './Pagination'

View File

@ -0,0 +1,60 @@
import { createMemo } from 'solid-js'
export const DOTS = '...'
const range = (start, end) => {
let length = end - start + 1
return Array.from({ length }, (_, idx) => idx + start)
}
export const usePagination = ({
totalCount,
pageSize,
currentPage,
siblingCount = 1,
}) => {
const paginationRange = createMemo(() => {
const totalPageCount = Math.ceil(totalCount() / pageSize())
const totalPageNumbers = siblingCount + 5
if (totalPageNumbers >= totalPageCount) {
return range(1, totalPageCount)
}
const leftSiblingIndex = Math.max(currentPage() - siblingCount, 1)
const rightSiblingIndex = Math.min(
currentPage() + siblingCount,
totalPageCount,
)
const shouldShowLeftDots = leftSiblingIndex > 2
const shouldShowRightDots = rightSiblingIndex < totalPageCount - 2
const firstPageIndex = 1
const lastPageIndex = totalPageCount
if (!shouldShowLeftDots && shouldShowRightDots) {
let leftItemCount = 3 + 2 * siblingCount
let leftRange = range(1, leftItemCount)
return [...leftRange, DOTS, totalPageCount]
}
if (shouldShowLeftDots && !shouldShowRightDots) {
let rightItemCount = 3 + 2 * siblingCount
let rightRange = range(
totalPageCount - rightItemCount + 1,
totalPageCount,
)
return [firstPageIndex, DOTS, ...rightRange]
}
if (shouldShowLeftDots && shouldShowRightDots) {
let middleRange = range(leftSiblingIndex, rightSiblingIndex)
return [firstPageIndex, DOTS, ...middleRange, DOTS, lastPageIndex]
}
})
return paginationRange
}

View File

@ -1,4 +1,64 @@
{
"login": "Login",
"logout": "Logout"
"ui": {
"username": "User name",
"password": "Password",
"login": "Login",
"logout": "Logout",
"dashboard": "Dashboard",
"profile": "Profile",
"changeInfo": "Account information",
"save": "Save",
"clear": "Clear",
"house": "Location",
"action": "Action",
"createNew": "Create new",
"location": "Warehouse",
"displayName": "Display name",
"newPassword": "New password",
"confirmNewPassword": "Confirm new password",
"newHouse": "Create new location",
"houseName": "Location name",
"houseIcon": "Icon",
"houseAddress": "Address",
"areas": "Areas",
"areaName": "Area name",
"areaDesc": "Description",
"addArea": "Add area",
"create": "Create",
"update": "Update",
"delete": "Delete",
"confirm": "Confirm",
"cancel": "Cancel",
"findIconHere": "Find icons here",
"empty": "Empty",
"error": "Error!",
"success": "Success!",
"info": "Info",
"loading": "Loading...",
"showing": "Showing"
},
"table": {
"columnName": {
"no": "No.",
"name": "Name",
"icon": "Icon",
"address": "Address",
"action": "Action"
}
},
"message": {
"CREATE_USER_SUCCESS": "Create account successfully!",
"CREATED_USER": "Username is already in use!",
"LOGIN_WRONG": "Wrong username or password.",
"USER_LOCK": "Your account is locked.",
"IS_REQUIRED": "%s is required.",
"PASSWORD_MUSTMATCH": "Password must match.",
"UPDATE_SUCCESS": "Update successfully!",
"UPDATE_PROFILE_SUCCESS": "Update profile successfully!",
"UPDATE_FAIL": "Update failed!",
"API_CALL_FAIL": "API call failed!",
"CREATE_HOUSE_FAIL": "Create new location failed!",
"CREATE_HOUSE_SUCCESS": "Create new location successfully!",
"CONFIRM_DELETE": "Are you sure you want to delete this item?"
}
}

View File

@ -9,17 +9,17 @@
"changeInfo": "Thông tin tài khoản",
"save": "Lưu",
"clear": "Xóa",
"house": "Nhà",
"house": "Địa điểm",
"action": "Thao Tác",
"createNew": "Tạo mới",
"location": "Khu vực",
"displayName": "Tên hiển thị",
"newPassword": "Mật khẩu mới",
"confirmNewPassword": "Nhập lại mật khẩu",
"newHouse": "Tạo nhà mới",
"houseName": "Tên nhà",
"houseIcon": "Ký tự nhà",
"houseAddress": "Địa chỉ nhà",
"newHouse": "Tạo địa điểm mới",
"houseName": "Tên địa điểm",
"houseIcon": "Ký tự",
"houseAddress": "Địa chỉ",
"areas": "Khu vực",
"areaName": "Tên khu vực",
"areaDesc": "Mô tả",
@ -30,7 +30,12 @@
"confirm": "Xác nhận",
"cancel": "Huỷ",
"findIconHere": "Tìm ở đây",
"empty": "Trống"
"empty": "Trống",
"error": "lỗi!",
"success": "Thành công!",
"info": "Thông tin",
"loading": "Đang tải...",
"showing": "Hiển thị"
},
"table": {
"columnName": {
@ -42,10 +47,19 @@
}
},
"message": {
"CREATED_USER": "Username already registered!",
"LOGIN_WRONG": "Your username or password input is wrong!",
"USER_LOCK": "Your Account was locked",
"IS_REQUIRED": "%s là bắt buộc",
"PASSWORD_MUSTMATCH": "Cần nhập trùng với mật khẩu"
"CREATE_USER_SUCCESS": "Tạo tài khoản thành công!",
"CREATED_USER": "Tên tài khoản đã có người sử dụng!",
"LOGIN_WRONG": "Bạn nhập sai tên người dùng hoặc mật khẩu.",
"USER_LOCK": "Tài khoản bạn hiện đang bị khóa.",
"IS_REQUIRED": "%s là bắt buộc.",
"PASSWORD_MUSTMATCH": "Cần nhập trùng với mật khẩu.",
"UPDATE_SUCCESS": "Cập nhật thành công!",
"UPDATE_PROFILE_SUCCESS": "Cập nhật hồ sơ thành công!",
"UPDATE_FAIL": "Cập nhật thất bại!",
"API_CALL_FAIL": "Call API có vẫn đề!",
"CREATE_HOUSE_FAIL": "Tạo địa điểm mới thất bại!",
"CREATE_HOUSE_SUCCESS": "Tạo địa điểm mới thành công!",
"CONFIRM_DELETE": "Bạn có chắc là muốn xóa mục này?",
"CONFIRM_DELETE_NOTE": "Chú Ý ‼: Một khi đã XÓA thì không thể nào khôi phục lại được."
}
}

View File

@ -1,6 +1,7 @@
import { NAV_ITEM } from '@components/Navbar'
import { useSiteContext } from '@context/SiteContext'
import { useNavigate } from '@solidjs/router'
import { Helpers } from '@utils/helper'
import { createEffect } from 'solid-js'
function getFirstItem(array) {
@ -18,7 +19,12 @@ export default function Home() {
createEffect(() => {
if (store?.userInfo?.isAdmin) {
const first = getFirstItem(NAV_ITEM(store?.userInfo?.isAdmin))
navigate(first ? first.path : '/me', { replace: true })
navigate(
first
? Helpers.getRoutePath(first.pathName)
: Helpers.getRoutePath('profile'),
{ replace: true },
)
}
})

View File

@ -1,21 +1,52 @@
import ViewSwitch, { VIEWDATA } from '@components/ViewSwitch'
import useLanguage from '@hooks/useLanguage'
import { IconHome } from '@tabler/icons-solidjs'
import { createSignal } from 'solid-js'
import * as icons from '@tabler/icons-solidjs'
import { For, createEffect, createResource, createSignal } from 'solid-js'
import { getAllHouse } from '@api/house'
import Pagination from '@components/common/Pagination'
import { A } from '@solidjs/router'
import {
IconHome2,
IconHomeDot,
IconHome,
IconPencil,
IconSquareRoundedPlus,
IconTrash,
} from '@tabler/icons-solidjs'
import { Dynamic } from 'solid-js/web'
import './house.scss'
const PAGE_SIZE = [10, 50, 100]
const getPaginationText = (total, size, page) => {
const start = (page - 1) * size + 1
const end = Math.min(start + size - 1, total)
return `${start} - ${end} / ${total}`
}
const fetchHouses = async ({ page, pageSize }) => {
const response = await getAllHouse({ page, pageSize })
return response
}
export default function House() {
const { language } = useLanguage()
const [pageSize, setPageSize] = createSignal(PAGE_SIZE[0])
const [currentPage, setCurrentPage] = createSignal(1)
const [view, setView] = createSignal(VIEWDATA['list'])
const [record, setRecord] = createSignal(null)
const [totalRecord, setTotalRecord] = createSignal(0)
const [houses] = createResource(
() => ({ page: currentPage(), pageSize: pageSize() }),
fetchHouses,
)
createEffect(() => {
if (houses()) {
setRecord(houses()?.data?.list)
setTotalRecord(houses()?.data?.total)
}
})
const onEdit = () => {
console.log('edit')
@ -25,6 +56,11 @@ export default function House() {
console.log('delete')
}
const onSetPageSize = (pageSize) => {
setPageSize(pageSize)
setCurrentPage(1)
}
return (
<div class="house">
<div class="flex items-center gap-2 mb-5 text-xl">
@ -36,7 +72,7 @@ export default function House() {
<div class="page-topbar flex justify-between mb-4">
<ViewSwitch switchView={setView} />
<A
href="/house/create"
href="/location/create"
class="btn btn-success text-white hover:text-white btn-sm"
>
<IconSquareRoundedPlus size={15} />
@ -58,51 +94,74 @@ export default function House() {
<div class="col w-4/12">{language.table.columnName.address}</div>
<div class="col w-2/12">{language.table.columnName.action}</div>
</div>
<div class="row view-item">
<div class="col hide w-1/12">1</div>
<div class="col w-1/12">
<IconHome2 size={21} />
</div>
<div class="col w-4/12">Nhà 1</div>
<div class="col w-4/12">Data 4</div>
<div class="col actionbar w-2/12">
<button
class="btn btn-ghost btn-sm px-1 text-blue-500 mr-2"
onClick={onEdit}
>
<IconPencil size={20} />
</button>
<button
class="btn btn-ghost btn-sm px-1 text-red-500"
onClick={onDelete}
>
<IconTrash size={20} />
</button>
</div>
<For each={record()}>
{(item, idx) => (
<div class="row view-item">
<div class="col hide w-1/12">
{pageSize() * currentPage() - (pageSize() - idx() - 1)}
</div>
<div class="col w-1/12">
<Dynamic component={icons[item?.icon]} size={21} />
</div>
<div class="col w-4/12">{item?.name}</div>
<div class="col w-4/12">{item?.address}</div>
<div class="col actionbar w-2/12">
<button
class="btn btn-ghost btn-sm px-1 text-blue-500 mr-2"
onClick={onEdit}
>
<IconPencil size={20} />
</button>
<button
class="btn btn-ghost btn-sm px-1 text-red-500"
onClick={onDelete}
>
<IconTrash size={20} />
</button>
</div>
</div>
)}
</For>
</div>
</div>
<div class="page-botbar flex max-xs:flex-col justify-between items-center gap-2 mt-5">
<div class="bar-left flex gap-2 justify-start items-center">
<div class="py-2 px-3 border rounded-lg border-gray-300 leading-none">
<span>
{language.ui.showing}:{' '}
{getPaginationText(totalRecord(), pageSize(), currentPage())}
</span>
</div>
<div class="row view-item">
<div class="col hide w-1/12">2</div>
<div class="col w-1/12">
<IconHomeDot size={21} />
</div>
<div class="col w-4/12">Nhà 2</div>
<div class="col w-4/12">Data 4</div>
<div class="col actionbar w-2/12">
<button
class="btn btn-ghost btn-sm px-1 text-blue-500 mr-2"
onClick={onEdit}
>
<IconPencil size={20} />
</button>
<button
class="btn btn-ghost btn-sm px-1 text-red-500"
onClick={onDelete}
>
<IconTrash size={20} />
</button>
<div class="dropdown dropdown-top dropdown-end">
<div
tabindex="0"
role="button"
class="btn btn-sm border border-gray-300"
>
{pageSize()}
</div>
<ul
tabindex="0"
class="dropdown-content menu bg-base-100 rounded-box z-[1] w-32 p-2 shadow mb-2"
>
<For each={PAGE_SIZE.reverse()}>
{(pageSize) => (
<li>
<a onClick={[onSetPageSize, pageSize]}>{pageSize}</a>
</li>
)}
</For>
</ul>
</div>
</div>
<div class="bar-right">
<Pagination
currentPage={currentPage}
totalCount={totalRecord}
pageSize={pageSize}
onPageChange={setCurrentPage}
/>
</div>
</div>
</div>
)

View File

@ -1,15 +1,18 @@
import { postCreateHouse } from '@api/house'
import AreaAdd from '@components/AreaAdd'
import TextInput from '@components/common/TextInput'
import { createForm } from '@felte/solid'
import { validator } from '@felte/validator-yup'
import useLanguage from '@hooks/useLanguage'
import { A } from '@solidjs/router'
import useToast from '@hooks/useToast'
import { A, useNavigate } from '@solidjs/router'
import {
IconAddressBook,
IconHomePlus,
IconIcons,
IconMapPinPlus,
IconTag,
} from '@tabler/icons-solidjs'
import { Helpers } from '@utils/helper'
import * as yup from 'yup'
const houseSchema = (language, isRequired) =>
@ -17,15 +20,41 @@ const houseSchema = (language, isRequired) =>
icon: yup.string().required(isRequired(language.ui.houseIcon)),
name: yup.string().required(isRequired(language.ui.houseName)),
address: yup.string().required(isRequired(language.ui.houseAddress)),
areas: yup.array().required(isRequired(language.ui.areas)),
areas: yup
.array()
.min(1, isRequired(language.ui.areas))
.required(isRequired(language.ui.areas)),
})
export default function HouseCreate() {
const { language, isRequired } = useLanguage()
const notify = useToast()
const navigate = useNavigate()
const { form, errors } = createForm({
extend: [validator({ schema: houseSchema(language, isRequired) })],
onSubmit: async (values) => {
console.log(values)
const resp = await postCreateHouse(values)
return resp
},
onSuccess: (resp) => {
if (resp.status === 200) {
notify.success({
title: language.ui.success,
description:
language.message[resp.data] ||
language.message['CREATE_HOUSE_SUCCESS'],
})
navigate(Helpers.getRoutePath('location'), { replace: true })
}
},
onError: (error) => {
notify.error({
title: language.ui.error,
description:
language.message[error.data] || language.message['API_CALL_FAIL'],
closable: true,
})
},
})
@ -34,14 +63,14 @@ export default function HouseCreate() {
<div class="text-sm breadcrumbs mb-2">
<ul>
<li>
<A href="/house">{language.ui.house}</A>
<A href={Helpers.getRoutePath('location')}>{language.ui.house}</A>
</li>
<li>{language.ui.newHouse}</li>
</ul>
</div>
<div class="flex items-center gap-2 mb-5 text-xl">
<span class="text-secondary">
<IconHomePlus size={30} />
<IconMapPinPlus size={30} />
</span>
{language.ui.newHouse}
</div>
@ -90,7 +119,13 @@ export default function HouseCreate() {
/>
</div>
<div class="col-auto lg:col-span-2">
<AreaAdd name="areas" error={errors('areas')} />
<AreaAdd
name="areas"
error={
errors('areas') &&
Helpers.clearArrayWithNullObject(errors('areas'))
}
/>
</div>
</div>
<div class="card-actions">

View File

@ -21,7 +21,7 @@ export default function Layout(props) {
<div class="drawer lg:drawer-open">
<input id="nav-menu" type="checkbox" class="drawer-toggle" />
<div class="drawer-content flex flex-col">
<main class="main-content p-3">{props.children}</main>
<main class="main-content p-3 pb-5">{props.children}</main>
</div>
<Navbar />
</div>

View File

@ -46,16 +46,17 @@ export default function Profile() {
setUser(resp.data)
reset()
notify.success({
title: 'Update profile success!',
description: 'Your profile has been updated!',
title: language.ui.success,
description:
language.message[resp.data] ||
language.message['CREATE_USER_SUCCESS'],
})
}
} catch (error) {
notify.error({
title: 'Update profile fail!',
description: error?.data
? language.message[error.data]
: 'Your username or password input is wrong!',
title: language.ui.error,
description:
language.message[error?.data] || language.message['API_CALL_FAIL'],
closable: true,
})
}

View File

@ -2,31 +2,36 @@ import { lazy } from 'solid-js'
export const ROUTES = [
{
name: 'home',
path: '/',
components: lazy(() => import('@pages/Home')),
filter: {},
show: true,
},
{
name: 'profile',
path: '/me',
components: lazy(() => import('@pages/Profile')),
filter: {},
show: true,
},
{
name: 'dashboard',
path: '/dashboard',
components: lazy(() => import('@pages/Dashboard')),
filter: {},
show: true,
},
{
path: '/house',
name: 'location',
path: '/location',
components: lazy(() => import('@pages/House')),
filter: {},
show: true,
},
{
path: '/house/create',
name: 'create-location',
path: '/location/create',
components: lazy(() => import('@pages/HouseCreate')),
filter: {},
show: true,

View File

@ -1,3 +1,4 @@
import { ROUTES } from '@routes/routes'
import { AES, enc } from 'crypto-js'
import { LOGIN_KEY, SECRET_KEY, STORE_KEY } from './enum'
@ -58,16 +59,18 @@ export class Helpers {
}
static clearArrayWithNullObject = (array) => {
console.log(array)
array.forEach((element, i) => {
const obk = this.clearObject(element)
if (obk) array.splice(i, 1)
})
// for (let i = 0; i < array.length; i++) {
// if (array[i] === null || array[i] === undefined) {
// array.splice(i, 1)
// }
// }
if (array instanceof Array) {
array.forEach((element, i) => {
if (element instanceof Object) {
const obk = this.clearObject(element)
if (obk) array.splice(i, 1)
}
})
}
return array.length > 0 ? array : null
}
static getRoutePath = (pathName) =>
ROUTES.filter((r) => r.name === pathName)[0].path
}

View File

@ -6,6 +6,9 @@ export default {
content: ['./src/**/*.{js,jsx}'],
theme: {
extend: {
screens: {
xs: '400px',
},
colors: {
fu: {
white: '#fff',