Merge branch 'dev' of https://gitlab.com/kluppsoftware/smart-energia-web into dev
This commit is contained in:
commit
ac9a74740d
@ -10,7 +10,7 @@ import TablePagination from '@mui/material/TablePagination'
|
|||||||
import TableRow from '@mui/material/TableRow'
|
import TableRow from '@mui/material/TableRow'
|
||||||
import TableSortLabel from '@mui/material/TableSortLabel'
|
import TableSortLabel from '@mui/material/TableSortLabel'
|
||||||
import { visuallyHidden } from '@mui/utils'
|
import { visuallyHidden } from '@mui/utils'
|
||||||
import { forwardRef, useDeferredValue, useEffect, useState } from 'react'
|
import { ChangeEvent, forwardRef, useDeferredValue, useEffect, useState } from 'react'
|
||||||
|
|
||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
|
|
||||||
@ -145,12 +145,11 @@ function sortedClients(client, search: string) {
|
|||||||
search = sanitizeStringSearch(search)
|
search = sanitizeStringSearch(search)
|
||||||
|
|
||||||
return client
|
return client
|
||||||
.map(client => ({
|
.filter(
|
||||||
...client,
|
(client) => sanitizeStringSearch(client.name).includes(search) ||
|
||||||
name: sanitizeStringSearch(client.name),
|
sanitizeStringSearch(String(client.client_id ?? "")).includes(search) ||
|
||||||
client_id: sanitizeStringSearch(String(client.client_id ?? ""))
|
sanitizeStringSearch(client.email).includes(search)
|
||||||
}))
|
)
|
||||||
.filter((client) => client.name.includes(search) || client.client_id.includes(search))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function EnhancedTableHead(props: EnhancedTableProps) {
|
function EnhancedTableHead(props: EnhancedTableProps) {
|
||||||
@ -224,7 +223,6 @@ export default function ClientTable({
|
|||||||
const [openModalInativar, setOpenModalInativar] = useState(false)
|
const [openModalInativar, setOpenModalInativar] = useState(false)
|
||||||
const [clientEdit, setClientEdit] = useState<any>()
|
const [clientEdit, setClientEdit] = useState<any>()
|
||||||
const [logo, setLogo] = useState(false)
|
const [logo, setLogo] = useState(false)
|
||||||
const [imageURLS, setImageURLs] = useState([])
|
|
||||||
const [images, setImages] = useState([] as any)
|
const [images, setImages] = useState([] as any)
|
||||||
const [nivelAcess, setnivelAcess] = useState<any>(2)
|
const [nivelAcess, setnivelAcess] = useState<any>(2)
|
||||||
const [openEditUserModal, setOpenEditUserModal] = useState<any>(false)
|
const [openEditUserModal, setOpenEditUserModal] = useState<any>(false)
|
||||||
@ -246,6 +244,8 @@ export default function ClientTable({
|
|||||||
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const imageURLS = images.map((img) => URL.createObjectURL(img))
|
||||||
|
|
||||||
// const handleOpen = () => setOpen(true)
|
// const handleOpen = () => setOpen(true)
|
||||||
const handleClose = () => setOpen(false)
|
const handleClose = () => setOpen(false)
|
||||||
|
|
||||||
@ -268,6 +268,11 @@ export default function ClientTable({
|
|||||||
return units
|
return units
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleSearch(e: ChangeEvent<HTMLInputElement>) {
|
||||||
|
setSearch(e.target.value)
|
||||||
|
setPage(0);
|
||||||
|
}
|
||||||
|
|
||||||
const handleCloseSnack = (
|
const handleCloseSnack = (
|
||||||
event?: React.SyntheticEvent | Event,
|
event?: React.SyntheticEvent | Event,
|
||||||
reason?: string
|
reason?: string
|
||||||
@ -363,15 +368,6 @@ export default function ClientTable({
|
|||||||
onChange(selected)
|
onChange(selected)
|
||||||
}, [selected])
|
}, [selected])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (images.length < 1) return
|
|
||||||
const newImageUrls: any = []
|
|
||||||
images.forEach((image: any) =>
|
|
||||||
newImageUrls.push(URL.createObjectURL(image))
|
|
||||||
)
|
|
||||||
setImageURLs(newImageUrls)
|
|
||||||
}, [images])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableView>
|
<TableView>
|
||||||
<Snackbar
|
<Snackbar
|
||||||
@ -389,7 +385,7 @@ export default function ClientTable({
|
|||||||
</Snackbar>
|
</Snackbar>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
onChange={(e) => setSearch(e.target.value)}
|
onChange={handleSearch}
|
||||||
placeholder="Pesquisar por nome:"
|
placeholder="Pesquisar por nome:"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@ -587,8 +583,7 @@ export default function ClientTable({
|
|||||||
<InputUploadView>
|
<InputUploadView>
|
||||||
<div className="imgContainer">
|
<div className="imgContainer">
|
||||||
<article>
|
<article>
|
||||||
{imageURLS.map((imageSrc, index) => {
|
{imageURLS.map((imageSrc, index) => (
|
||||||
return (
|
|
||||||
<Image
|
<Image
|
||||||
src={imageSrc}
|
src={imageSrc}
|
||||||
key={index}
|
key={index}
|
||||||
@ -596,8 +591,7 @@ export default function ClientTable({
|
|||||||
height={30}
|
height={30}
|
||||||
className="image"
|
className="image"
|
||||||
/>
|
/>
|
||||||
)
|
))}
|
||||||
})}
|
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
<div className="update">
|
<div className="update">
|
||||||
|
|||||||
@ -18,9 +18,9 @@ export default function getAPIClient(
|
|||||||
const { '@smartAuth-token': token } = parseCookies(ctx)
|
const { '@smartAuth-token': token } = parseCookies(ctx)
|
||||||
|
|
||||||
const api = axios.create({
|
const api = axios.create({
|
||||||
baseURL: 'https://api.energiasmart.com.br/api'
|
// baseURL: 'https://api.energiasmart.com.br/api'
|
||||||
// baseURL: 'https://api.energiasmart.klupp.com.br/api'
|
// baseURL: 'https://api.energiasmart.klupp.com.br/api'
|
||||||
// baseURL: 'http://api-smart.test/api'
|
baseURL: 'http://api-smart.test/api'
|
||||||
})
|
})
|
||||||
|
|
||||||
api.interceptors.request.use((config) => {
|
api.interceptors.request.use((config) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user