IO-2261 Add Loading effect
This commit is contained in:
@@ -23,6 +23,7 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
const [openSearchResults, setOpenSearchResults] = useState([]);
|
const [openSearchResults, setOpenSearchResults] = useState([]);
|
||||||
|
const [searchLoading, setSearchLoading] = useState(false);
|
||||||
const { page, sortcolumn, sortorder } = search;
|
const { page, sortcolumn, sortorder } = search;
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
@@ -197,7 +198,6 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (search.search && search.search.trim() !== "") {
|
if (search.search && search.search.trim() !== "") {
|
||||||
// setLoading(true);
|
|
||||||
searchJobs();
|
searchJobs();
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -205,6 +205,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
|||||||
|
|
||||||
async function searchJobs(value) {
|
async function searchJobs(value) {
|
||||||
try {
|
try {
|
||||||
|
setSearchLoading(true);
|
||||||
const searchData = await axios.post("/search", {
|
const searchData = await axios.post("/search", {
|
||||||
search: value || search.search,
|
search: value || search.search,
|
||||||
index: "jobs",
|
index: "jobs",
|
||||||
@@ -213,7 +214,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error while fetching search results", error);
|
console.log("Error while fetching search results", error);
|
||||||
} finally {
|
} finally {
|
||||||
// setLoading(false);
|
setSearchLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,13 +247,14 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
|||||||
history.push({ search: queryString.stringify(search) });
|
history.push({ search: queryString.stringify(search) });
|
||||||
searchJobs(value);
|
searchJobs(value);
|
||||||
}}
|
}}
|
||||||
|
loading={loading || searchLoading}
|
||||||
enterButton
|
enterButton
|
||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Table
|
<Table
|
||||||
loading={loading}
|
loading={loading || searchLoading}
|
||||||
pagination={
|
pagination={
|
||||||
search?.search
|
search?.search
|
||||||
? { pageSize: 25 }
|
? { pageSize: 25 }
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export function PaymentsListPaginated({
|
|||||||
}) {
|
}) {
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
const [openSearchResults, setOpenSearchResults] = useState([]);
|
const [openSearchResults, setOpenSearchResults] = useState([]);
|
||||||
|
const [searchLoading, setSearchLoading] = useState(false);
|
||||||
const { page, sortcolumn, sortorder } = search;
|
const { page, sortcolumn, sortorder } = search;
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
@@ -185,7 +186,6 @@ export function PaymentsListPaginated({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (search.search && search.search.trim() !== "") {
|
if (search.search && search.search.trim() !== "") {
|
||||||
// setLoading(true);
|
|
||||||
searchPayments();
|
searchPayments();
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -193,6 +193,7 @@ export function PaymentsListPaginated({
|
|||||||
|
|
||||||
async function searchPayments(value) {
|
async function searchPayments(value) {
|
||||||
try {
|
try {
|
||||||
|
setSearchLoading(true);
|
||||||
const searchData = await axios.post("/search", {
|
const searchData = await axios.post("/search", {
|
||||||
search: value || search.search,
|
search: value || search.search,
|
||||||
index: "payments",
|
index: "payments",
|
||||||
@@ -201,7 +202,7 @@ export function PaymentsListPaginated({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error while fetching search results", error);
|
console.log("Error while fetching search results", error);
|
||||||
} finally {
|
} finally {
|
||||||
// setLoading(false);
|
setSearchLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,13 +243,14 @@ export function PaymentsListPaginated({
|
|||||||
history.push({ search: queryString.stringify(search) });
|
history.push({ search: queryString.stringify(search) });
|
||||||
searchPayments(value);
|
searchPayments(value);
|
||||||
}}
|
}}
|
||||||
|
loading={loading || searchLoading}
|
||||||
enterButton
|
enterButton
|
||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Table
|
<Table
|
||||||
loading={loading}
|
loading={loading || searchLoading}
|
||||||
scroll={{ x: true }}
|
scroll={{ x: true }}
|
||||||
pagination={
|
pagination={
|
||||||
search?.search
|
search?.search
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ export function BillsListPage({
|
|||||||
}) {
|
}) {
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
const [openSearchResults, setOpenSearchResults] = useState([]);
|
const [openSearchResults, setOpenSearchResults] = useState([]);
|
||||||
|
const [searchLoading, setSearchLoading] = useState(false);
|
||||||
const { page } = search;
|
const { page } = search;
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
@@ -207,7 +208,6 @@ export function BillsListPage({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (search.search && search.search.trim() !== "") {
|
if (search.search && search.search.trim() !== "") {
|
||||||
// setLoading(true);
|
|
||||||
searchBills();
|
searchBills();
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
@@ -215,6 +215,7 @@ export function BillsListPage({
|
|||||||
|
|
||||||
async function searchBills(value) {
|
async function searchBills(value) {
|
||||||
try {
|
try {
|
||||||
|
setSearchLoading(true);
|
||||||
const searchData = await axios.post("/search", {
|
const searchData = await axios.post("/search", {
|
||||||
search: value || search.search,
|
search: value || search.search,
|
||||||
index: "bills",
|
index: "bills",
|
||||||
@@ -223,7 +224,7 @@ export function BillsListPage({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("Error while fetching search results", error);
|
console.log("Error while fetching search results", error);
|
||||||
} finally {
|
} finally {
|
||||||
// setLoading(false);
|
setSearchLoading(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,6 +269,7 @@ export function BillsListPage({
|
|||||||
history.push({ search: queryString.stringify(search) });
|
history.push({ search: queryString.stringify(search) });
|
||||||
searchBills(value);
|
searchBills(value);
|
||||||
}}
|
}}
|
||||||
|
loading={loading || searchLoading}
|
||||||
enterButton
|
enterButton
|
||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
@@ -276,7 +278,7 @@ export function BillsListPage({
|
|||||||
<PartsOrderModalContainer />
|
<PartsOrderModalContainer />
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
loading={loading}
|
loading={loading || searchLoading}
|
||||||
// scroll={{
|
// scroll={{
|
||||||
// x: "50%", // y: "40rem"
|
// x: "50%", // y: "40rem"
|
||||||
// }}
|
// }}
|
||||||
|
|||||||
Reference in New Issue
Block a user