Merged in feature/IO-2448-CC-Search-by-Plate (pull request #1050)
IO-2448 Search by C/C Plate number
This commit is contained in:
@@ -4,14 +4,14 @@ import queryString from "query-string";
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link, useHistory, useLocation } from "react-router-dom";
|
import { Link, useHistory, useLocation } from "react-router-dom";
|
||||||
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
||||||
import { alphaSort } from "../../utils/sorters";
|
import { alphaSort } from "../../utils/sorters";
|
||||||
import ContractsFindModalContainer from "../contracts-find-modal/contracts-find-modal.container";
|
import ContractsFindModalContainer from "../contracts-find-modal/contracts-find-modal.container";
|
||||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
|
||||||
|
|
||||||
|
import moment from "moment";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import moment from "moment";
|
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ export default function CourtesyCarsList({ loading, courtesycars, refetch }) {
|
|||||||
(c.year || "").toLowerCase().includes(searchText.toLowerCase()) ||
|
(c.year || "").toLowerCase().includes(searchText.toLowerCase()) ||
|
||||||
(c.make || "").toLowerCase().includes(searchText.toLowerCase()) ||
|
(c.make || "").toLowerCase().includes(searchText.toLowerCase()) ||
|
||||||
(c.model || "").toLowerCase().includes(searchText.toLowerCase()) ||
|
(c.model || "").toLowerCase().includes(searchText.toLowerCase()) ||
|
||||||
|
(c.plate || "").toLowerCase().includes(searchText.toLowerCase()) ||
|
||||||
(t(c.status) || "").toLowerCase().includes(searchText.toLowerCase())
|
(t(c.status) || "").toLowerCase().includes(searchText.toLowerCase())
|
||||||
)
|
)
|
||||||
: courtesycars;
|
: courtesycars;
|
||||||
|
|||||||
38
hasura/migrations/1699662574943_run_sql_migration/down.sql
Normal file
38
hasura/migrations/1699662574943_run_sql_migration/down.sql
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
-- Could not auto-generate a down migration.
|
||||||
|
-- Please write an appropriate down migration for the SQL below:
|
||||||
|
-- CREATE OR REPLACE FUNCTION public.search_cccontracts(search text)
|
||||||
|
-- RETURNS SETOF cccontracts
|
||||||
|
-- LANGUAGE plpgsql
|
||||||
|
-- STABLE
|
||||||
|
-- AS $function$
|
||||||
|
-- BEGIN
|
||||||
|
-- IF search = '' THEN
|
||||||
|
-- RETURN query
|
||||||
|
-- SELECT
|
||||||
|
-- *
|
||||||
|
-- FROM
|
||||||
|
-- cccontracts c;
|
||||||
|
-- ELSE
|
||||||
|
-- RETURN query
|
||||||
|
-- SELECT
|
||||||
|
-- contracts.*
|
||||||
|
-- FROM
|
||||||
|
-- courtesycars cars,
|
||||||
|
-- jobs jobs,
|
||||||
|
-- cccontracts contracts
|
||||||
|
-- WHERE (jobs.ro_number ILIKE '%' || search || '%'
|
||||||
|
-- OR jobs.ownr_fn ILIKE '%' || search || '%'
|
||||||
|
-- OR jobs.ownr_ln ILIKE '%' || search || '%'
|
||||||
|
-- OR jobs.ownr_co_nm ILIKE '%' || search || '%'
|
||||||
|
-- OR (cast(contracts.agreementnumber as text)) ILIKE '%' || search || '%'
|
||||||
|
-- OR contracts.driver_fn ILIKE '%' || search || '%'
|
||||||
|
-- OR contracts.driver_ln ILIKE '%' || search || '%'
|
||||||
|
-- OR cars.fleetnumber ILIKE '%' || search || '%'
|
||||||
|
-- OR cars.make ILIKE '%' || search || '%'
|
||||||
|
-- OR cars.model ILIKE '%' || search || '%'
|
||||||
|
-- OR cars.plate ILIKE '%' || search || '%')
|
||||||
|
-- AND contracts.jobid = jobs.id
|
||||||
|
-- AND contracts.courtesycarid = cars.id;
|
||||||
|
-- END IF;
|
||||||
|
-- END
|
||||||
|
-- $function$;
|
||||||
36
hasura/migrations/1699662574943_run_sql_migration/up.sql
Normal file
36
hasura/migrations/1699662574943_run_sql_migration/up.sql
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
CREATE OR REPLACE FUNCTION public.search_cccontracts(search text)
|
||||||
|
RETURNS SETOF cccontracts
|
||||||
|
LANGUAGE plpgsql
|
||||||
|
STABLE
|
||||||
|
AS $function$
|
||||||
|
BEGIN
|
||||||
|
IF search = '' THEN
|
||||||
|
RETURN query
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
cccontracts c;
|
||||||
|
ELSE
|
||||||
|
RETURN query
|
||||||
|
SELECT
|
||||||
|
contracts.*
|
||||||
|
FROM
|
||||||
|
courtesycars cars,
|
||||||
|
jobs jobs,
|
||||||
|
cccontracts contracts
|
||||||
|
WHERE (jobs.ro_number ILIKE '%' || search || '%'
|
||||||
|
OR jobs.ownr_fn ILIKE '%' || search || '%'
|
||||||
|
OR jobs.ownr_ln ILIKE '%' || search || '%'
|
||||||
|
OR jobs.ownr_co_nm ILIKE '%' || search || '%'
|
||||||
|
OR (cast(contracts.agreementnumber as text)) ILIKE '%' || search || '%'
|
||||||
|
OR contracts.driver_fn ILIKE '%' || search || '%'
|
||||||
|
OR contracts.driver_ln ILIKE '%' || search || '%'
|
||||||
|
OR cars.fleetnumber ILIKE '%' || search || '%'
|
||||||
|
OR cars.make ILIKE '%' || search || '%'
|
||||||
|
OR cars.model ILIKE '%' || search || '%'
|
||||||
|
OR cars.plate ILIKE '%' || search || '%')
|
||||||
|
AND contracts.jobid = jobs.id
|
||||||
|
AND contracts.courtesycarid = cars.id;
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$function$;
|
||||||
Reference in New Issue
Block a user