From 0ee1017745c5e3cf652330a34daa782e64ced663 Mon Sep 17 00:00:00 2001 From: seemachal-8848 Date: Sat, 19 Apr 2025 10:21:47 +0530 Subject: [PATCH 01/19] feat: drop down filter api integrated --- .../useDropDownFilterHook.ts | 139 ++++++++++++++++++ .../get-product-list-api.ts | 2 + 2 files changed, 141 insertions(+) create mode 100644 hooks/ProductListPageHooks/useDropDownFilterHook.ts diff --git a/hooks/ProductListPageHooks/useDropDownFilterHook.ts b/hooks/ProductListPageHooks/useDropDownFilterHook.ts new file mode 100644 index 00000000..a15228d7 --- /dev/null +++ b/hooks/ProductListPageHooks/useDropDownFilterHook.ts @@ -0,0 +1,139 @@ +import { useEffect, useState } from 'react'; +import { useRouter } from 'next/router'; +import { useSelector } from 'react-redux'; +import { get_access_token } from '../../store/slices/auth/token-login-slice'; +import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; +import { CONSTANTS } from '../../services/config/app-config'; +import fetchProductListingPageFilters from '../../services/api/product-listing-page-apis/get-filters-api'; +import axios from 'axios'; + +const useDropDownFilterHook = () => { + const router: any = useRouter(); + const { query } = useRouter(); + const { SUMMIT_APP_CONFIG }: any = CONSTANTS; + const { isLoading, setIsLoading, errorMessage, setErrMessage }: any = useHandleStateUpdate(); + const tokenFromStore: any = useSelector(get_access_token); + + const [filtersData, setFiltersData] = useState([]); + const [selectedFilters, setSelectedFilters] = useState(); + const [lastChangedSection, setLastChangedSection] = useState(null); + const [initialFiltersSet, setInitialFiltersSet] = useState(false); + + const fetchFiltersDataFunction = async (selectedValues?: any) => { + const vehicleCompany = selectedValues?.[0]; + const url = `https://staging-auto-house-hubli.8848digitalerp.com/api/method/summitapp.sdk.api?version=v2&method=get_vehicle_filters&entity=filter${vehicleCompany ? `&vehicle_company=${vehicleCompany}` : ''}`; + + setIsLoading(true); + try { + const response: any = await axios.get(url); + if (response?.status === 200) { + setFiltersData(response?.data?.message || {}); + setErrMessage(''); + } else { + setFiltersData([]); + setErrMessage(response?.error || 'Something went wrong'); + } + + return response; + } catch (error: any) { + console.error("Error fetching filters:", error); + setFiltersData([]); + setErrMessage(error?.message || 'API error'); + } finally { + setIsLoading(false); + } + }; + + + useEffect(() => { + if (initialFiltersSet) return; + fetchFiltersDataFunction(); + + if (router.query.hasOwnProperty('vehicle_filters')) { + const encodedFilterString: any = router.query.filter; + if (encodedFilterString !== undefined) { + const decodedFilterString = decodeURIComponent(encodedFilterString); + const decodedFilters = JSON.parse(decodedFilterString); + setSelectedFilters(decodedFilters); + } + } + + setInitialFiltersSet(true); // mark initial setup complete + }, [query]); + + // 2️⃣ Watch for Vehicle Company changes (only after initial load) + useEffect(() => { + const changedFilter = selectedFilters?.length > 0 && selectedFilters.find((f: any) => f.name === lastChangedSection); + if (lastChangedSection === 'Vehicle Company' && changedFilter) { + fetchFiltersDataFunction(changedFilter.value); + } + }, [selectedFilters, lastChangedSection, initialFiltersSet]); + + + const handleFilterCheckFun = async (selectedOptions: any, meta: any = null, isColorFilter?: boolean, isActiveColor?: boolean, colorValue?: string) => { + let duplicateFilters: any[] = []; + const section = meta?.name || selectedOptions?.[0]?.section || ''; + + if (!selectedOptions || !Array.isArray(selectedOptions) || selectedOptions.length === 0) { + setSelectedFilters((prevFilters: any) => { + const updatedFilters = prevFilters.filter((filter: any) => filter.name !== section); + duplicateFilters = [...updatedFilters]; + setLastChangedSection(section); // track which section changed + return duplicateFilters; + }); + + } else { + const selectedValues = selectedOptions.map((opt: any) => opt.value); + setSelectedFilters((prevFilters: any) => { + const safePrevFilters = Array.isArray(prevFilters) ? prevFilters : []; + let updatedFilters = [...safePrevFilters]; + const existingSectionIndex = updatedFilters.findIndex((filter: any) => filter.name === section); + + if (existingSectionIndex !== -1) { + updatedFilters[existingSectionIndex].value = selectedValues; + } else { + updatedFilters.push({ name: section, value: selectedValues }); + } + + duplicateFilters = [...updatedFilters] + setLastChangedSection(section); // track which section changed + return duplicateFilters; + }); + } + + const filterString = duplicateFilters?.length > 0 ? `&vehicle_filters=${encodeURIComponent(JSON.stringify(duplicateFilters))}` : ''; + let url = router.asPath; + const existingFilterIndex = url.indexOf('&vehicle_filters='); + if (existingFilterIndex !== -1) { + const ampIndex = url.indexOf('&', existingFilterIndex + 1); + if (ampIndex !== -1) { + url = url.slice(0, existingFilterIndex) + url.slice(ampIndex); + } else { + url = url.slice(0, existingFilterIndex); + } + } + + if (filterString) { + url = `${url.split('?')[0]}?&page=1${filterString}`; + } else { + url = `${url.split('?')[0]}?page=1`; + } + + await router.push(url); + }; + const clearFilters = async () => { + setSelectedFilters([]); + const baseUrl = router.asPath.split('?')[0]; + await router.push(`${baseUrl}?page=1¤cy=INR`); + }; + return { + filtersData, + isLoading, + errorMessage, + handleFilterCheckFun, + selectedFilters, + clearFilters, + }; +}; + +export default useDropDownFilterHook; diff --git a/services/api/product-listing-page-apis/get-product-list-api.ts b/services/api/product-listing-page-apis/get-product-list-api.ts index 08c0a7ea..fd3735df 100644 --- a/services/api/product-listing-page-apis/get-product-list-api.ts +++ b/services/api/product-listing-page-apis/get-product-list-api.ts @@ -22,6 +22,8 @@ const fetchProductListingFromAPI = async (appName: any, query: any, token: any) .map((key) => { if (key === 'filter') { return `${key}={"${query.filterDoctype}":"${query.filterDocname}", "sections":${query.url_params.filter}}`; + } if (key === 'vehicle_filters') { + return `${key}={"${query.filterDoctype}":"${query.filterDocname}", "sections":${query.url_params.vehicle_filters}}`; } else { return `${key}=${encodeURIComponent(query.url_params[key])}`; } From 5f06b5a9f3171fc07d340adfde5329b12ffac6e1 Mon Sep 17 00:00:00 2001 From: seemachal-8848 Date: Sat, 19 Apr 2025 10:22:25 +0530 Subject: [PATCH 02/19] feat: react select package added --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 47b6b61a..44dde76a 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "react-multi-carousel": "^2.8.5", "react-paginate": "^8.2.0", "react-redux": "^8.0.5", + "react-select": "^5.10.1", "react-simple-star-rating": "^5.1.7", "react-social-login-buttons": "^4.1.0", "react-toastify": "^9.1.3", From 3fdb473b8f1fe40cd517abc9f65346f54a8ecbef Mon Sep 17 00:00:00 2001 From: seemachal-8848 Date: Mon, 21 Apr 2025 11:15:08 +0530 Subject: [PATCH 03/19] feat: vehicle filters api file created --- .../useDropDownFilterHook.ts | 6 +++--- .../get-dropdown-filters-api.ts | 17 +++++++++++++++++ utils/api_sdk_registry.ts | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 services/api/product-listing-page-apis/get-dropdown-filters-api.ts diff --git a/hooks/ProductListPageHooks/useDropDownFilterHook.ts b/hooks/ProductListPageHooks/useDropDownFilterHook.ts index a15228d7..5d56a7d5 100644 --- a/hooks/ProductListPageHooks/useDropDownFilterHook.ts +++ b/hooks/ProductListPageHooks/useDropDownFilterHook.ts @@ -6,6 +6,7 @@ import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; import { CONSTANTS } from '../../services/config/app-config'; import fetchProductListingPageFilters from '../../services/api/product-listing-page-apis/get-filters-api'; import axios from 'axios'; +import fetchProductListingPageDropDownFilters from '../../services/api/product-listing-page-apis/get-dropdown-filters-api'; const useDropDownFilterHook = () => { const router: any = useRouter(); @@ -21,11 +22,10 @@ const useDropDownFilterHook = () => { const fetchFiltersDataFunction = async (selectedValues?: any) => { const vehicleCompany = selectedValues?.[0]; - const url = `https://staging-auto-house-hubli.8848digitalerp.com/api/method/summitapp.sdk.api?version=v2&method=get_vehicle_filters&entity=filter${vehicleCompany ? `&vehicle_company=${vehicleCompany}` : ''}`; - + const reqParams = vehicleCompany || '' setIsLoading(true); try { - const response: any = await axios.get(url); + const response: any = await fetchProductListingPageDropDownFilters(SUMMIT_APP_CONFIG, reqParams, tokenFromStore?.token); if (response?.status === 200) { setFiltersData(response?.data?.message || {}); setErrMessage(''); diff --git a/services/api/product-listing-page-apis/get-dropdown-filters-api.ts b/services/api/product-listing-page-apis/get-dropdown-filters-api.ts new file mode 100644 index 00000000..cb751279 --- /dev/null +++ b/services/api/product-listing-page-apis/get-dropdown-filters-api.ts @@ -0,0 +1,17 @@ +import APP_CONFIG from '../../../interfaces/app-config-interface'; +import { executeGETAPI } from '../../../utils/http-methods'; + +const fetchProductListingPageDropDownFilters = async (appConfig: APP_CONFIG, requestParams: any, token: any) => { + const additionalParams = { vehicle_company:requestParams}; // Add additional parameters if needed + // Use executeGETAPI to handle GET Request logic + const response = await executeGETAPI( + appConfig, + 'get-product-listing-dropdown-filters-api', + token, + additionalParams // Pass additional parameters if needed + ); + + return response; +}; + +export default fetchProductListingPageDropDownFilters; diff --git a/utils/api_sdk_registry.ts b/utils/api_sdk_registry.ts index 4100af02..20cca018 100644 --- a/utils/api_sdk_registry.ts +++ b/utils/api_sdk_registry.ts @@ -58,6 +58,7 @@ const apiSdkRegistry: any = { 'sitemap-api': { method: 'get_site_map', entity: 'seo' }, 'promotional-banner-api': { method: '', entity: '' }, 'blog-api': { method: 'get_blog_post_list', entity: 'blog_post' }, + 'get-product-listing-dropdown-filters-api': { method: 'get_vehicle_filters', entity: 'filter' }, }; export default apiSdkRegistry; From e2b2e76c9d0738246df211bd67743e8205c1e3dd Mon Sep 17 00:00:00 2001 From: seemachal-8848 Date: Thu, 24 Apr 2025 17:29:59 +0530 Subject: [PATCH 04/19] feat: check box filter with drop down functionality added --- .../useDropDownFilterHook.ts | 108 ++++++++++++++++-- 1 file changed, 96 insertions(+), 12 deletions(-) diff --git a/hooks/ProductListPageHooks/useDropDownFilterHook.ts b/hooks/ProductListPageHooks/useDropDownFilterHook.ts index 5d56a7d5..ddb5a0fa 100644 --- a/hooks/ProductListPageHooks/useDropDownFilterHook.ts +++ b/hooks/ProductListPageHooks/useDropDownFilterHook.ts @@ -15,42 +15,68 @@ const useDropDownFilterHook = () => { const { isLoading, setIsLoading, errorMessage, setErrMessage }: any = useHandleStateUpdate(); const tokenFromStore: any = useSelector(get_access_token); + const [isLoadingDropDown, setIsLoadingDropDown] = useState(false); + const [errorMessageDropDown, setErrMessageDropDown] = useState(''); const [filtersData, setFiltersData] = useState([]); + const [checkBoxfiltersData, setCheckBoxfiltersData] = useState([]); const [selectedFilters, setSelectedFilters] = useState(); const [lastChangedSection, setLastChangedSection] = useState(null); const [initialFiltersSet, setInitialFiltersSet] = useState(false); - const fetchFiltersDataFunction = async (selectedValues?: any) => { + const fetchDropDownFiltersDataFunction = async (selectedValues?: any) => { const vehicleCompany = selectedValues?.[0]; const reqParams = vehicleCompany || '' - setIsLoading(true); + setIsLoadingDropDown(true); try { const response: any = await fetchProductListingPageDropDownFilters(SUMMIT_APP_CONFIG, reqParams, tokenFromStore?.token); if (response?.status === 200) { setFiltersData(response?.data?.message || {}); - setErrMessage(''); } else { setFiltersData([]); - setErrMessage(response?.error || 'Something went wrong'); + setErrMessageDropDown(response?.error || 'Something went wrong'); } return response; } catch (error: any) { console.error("Error fetching filters:", error); setFiltersData([]); - setErrMessage(error?.message || 'API error'); + setErrMessageDropDown(error?.message || 'API error'); } finally { - setIsLoading(false); + setIsLoadingDropDown(false); } }; + const fetchFiltersDataFunction = async () => { + setIsLoading(true); + const reqParams = { + query: query, + }; + try { + const getFiltersData: any = await fetchProductListingPageFilters(SUMMIT_APP_CONFIG, reqParams, tokenFromStore?.token); + if (getFiltersData?.data?.message?.msg === 'success') { + setCheckBoxfiltersData(getFiltersData?.data?.message?.data); + setIsLoading(false); + } else { + setCheckBoxfiltersData([]); + setIsLoading(false); + setErrMessage(getFiltersData?.data?.message?.error); + } + + return getFiltersData; + } catch (error) { + return; + } finally { + setIsLoading(false); + } + }; useEffect(() => { - if (initialFiltersSet) return; fetchFiltersDataFunction(); - + if (!initialFiltersSet) { + fetchDropDownFiltersDataFunction(); + } if (router.query.hasOwnProperty('vehicle_filters')) { - const encodedFilterString: any = router.query.filter; + const encodedFilterString: any = router.query.vehicle_filters; if (encodedFilterString !== undefined) { const decodedFilterString = decodeURIComponent(encodedFilterString); const decodedFilters = JSON.parse(decodedFilterString); @@ -61,16 +87,16 @@ const useDropDownFilterHook = () => { setInitialFiltersSet(true); // mark initial setup complete }, [query]); - // 2️⃣ Watch for Vehicle Company changes (only after initial load) + // Watch for Vehicle Company changes (only after initial load) useEffect(() => { const changedFilter = selectedFilters?.length > 0 && selectedFilters.find((f: any) => f.name === lastChangedSection); if (lastChangedSection === 'Vehicle Company' && changedFilter) { - fetchFiltersDataFunction(changedFilter.value); + fetchDropDownFiltersDataFunction(changedFilter.value); } }, [selectedFilters, lastChangedSection, initialFiltersSet]); - const handleFilterCheckFun = async (selectedOptions: any, meta: any = null, isColorFilter?: boolean, isActiveColor?: boolean, colorValue?: string) => { + const handleFilterSelectDropDown = async (selectedOptions: any, meta: any = null, isColorFilter?: boolean, isActiveColor?: boolean, colorValue?: string) => { let duplicateFilters: any[] = []; const section = meta?.name || selectedOptions?.[0]?.section || ''; @@ -121,15 +147,73 @@ const useDropDownFilterHook = () => { await router.push(url); }; + + const handleFilterCheckFun = async (event: any, isColorFilter?: boolean, isActiveColor?: boolean, colorValue?: string) => { + let duplicateFilters: any; + const section = isColorFilter ? 'Color' : event.target.name; // Use "Color" for color filters, otherwise from event + const filterValue = isColorFilter ? colorValue : event.target.value; // Use `colorValue` for color filters + const isChecked = isColorFilter ? isActiveColor : event.target.checked; // Colors are selected on click, so treat them as checked + + setSelectedFilters((prevFilters: any) => { + const safePrevFilters = Array.isArray(prevFilters) ? prevFilters : []; + let updatedFilters = [...safePrevFilters]; + + const existingSectionIndex = updatedFilters.findIndex((filter: any) => filter.name === section); + + if (existingSectionIndex !== -1) { + if (isChecked) { + if (!updatedFilters[existingSectionIndex].value.includes(filterValue)) { + updatedFilters[existingSectionIndex].value.push(filterValue); + } + } else { + updatedFilters[existingSectionIndex].value = updatedFilters[existingSectionIndex].value.filter((val: any) => val !== filterValue); + if (updatedFilters[existingSectionIndex].value.length === 0) { + updatedFilters = updatedFilters.filter((filter) => filter.name !== section); + } + } + } else if (isChecked) { + updatedFilters.push({ name: section, value: [filterValue] }); + } + + duplicateFilters = [...updatedFilters]; + return updatedFilters; + }); + + const filterString = duplicateFilters?.length > 0 ? `&vehicle_filters=${encodeURIComponent(JSON.stringify(duplicateFilters))}` : ''; + let url = router.asPath; + const existingFilterIndex = url.indexOf('&vehicle_filters='); + if (existingFilterIndex !== -1) { + const ampIndex = url.indexOf('&', existingFilterIndex + 1); + if (ampIndex !== -1) { + url = url.slice(0, existingFilterIndex) + url.slice(ampIndex); + } else { + url = url.slice(0, existingFilterIndex); + } + } + + if (filterString) { + url = `${url.split('?')[0]}?&page=1${filterString}`; + } else { + url = `${url.split('?')[0]}?page=1`; + } + + await router.push(url); + }; + + const clearFilters = async () => { setSelectedFilters([]); const baseUrl = router.asPath.split('?')[0]; await router.push(`${baseUrl}?page=1¤cy=INR`); }; return { + checkBoxfiltersData, filtersData, + isLoadingDropDown, isLoading, errorMessage, + errorMessageDropDown, + handleFilterSelectDropDown, handleFilterCheckFun, selectedFilters, clearFilters, From f4623fd122a6ffff92111a32c070cf2af473075f Mon Sep 17 00:00:00 2001 From: seemachal-8848 Date: Fri, 16 May 2025 13:15:48 +0530 Subject: [PATCH 05/19] feat: auto house hubli product list page hooks added --- hooks/AuthHooks/useLoginHook.ts | 1 + hooks/CheckoutPageHook/useCheckout.ts | 1 + .../CustomerGroupHook/useCustomerGroupList.ts | 50 ++++ .../useDropDownFilterHook.ts | 262 ++++++++++-------- hooks/WebsiteUserList/useAddMechanic.ts | 49 ++++ hooks/WebsiteUserList/useMechanicList.ts | 50 ++++ hooks/WebsiteUserList/useWebsiteUserList.ts | 50 ++++ package.json | 2 + pages/otp.tsx | 11 + pages/profile.tsx | 12 + .../get-customer-group-list-api.ts | 27 ++ .../get-all-filters-api.ts | 17 ++ .../get-dropdown-filters-api.ts | 7 +- .../get-product-list-api.ts | 2 + services/api/user/add-mechanic-to-user-api.ts | 7 + services/api/user/get-mechanic-list-api.ts | 27 ++ .../api/user/get-website-user-list-api.ts | 27 ++ store/root-reducer.ts | 2 + .../category-breadcrumb-slice.ts | 51 ++++ utils/api_sdk_registry.ts | 5 + 20 files changed, 536 insertions(+), 124 deletions(-) create mode 100644 hooks/CustomerGroupHook/useCustomerGroupList.ts create mode 100644 hooks/WebsiteUserList/useAddMechanic.ts create mode 100644 hooks/WebsiteUserList/useMechanicList.ts create mode 100644 hooks/WebsiteUserList/useWebsiteUserList.ts create mode 100644 pages/otp.tsx create mode 100644 pages/profile.tsx create mode 100644 services/api/customer-group-list-apis/get-customer-group-list-api.ts create mode 100644 services/api/product-listing-page-apis/get-all-filters-api.ts create mode 100644 services/api/user/add-mechanic-to-user-api.ts create mode 100644 services/api/user/get-mechanic-list-api.ts create mode 100644 services/api/user/get-website-user-list-api.ts create mode 100644 store/slices/category-breadcrumb-slice/category-breadcrumb-slice.ts diff --git a/hooks/AuthHooks/useLoginHook.ts b/hooks/AuthHooks/useLoginHook.ts index 8a6d992f..ce864cb0 100644 --- a/hooks/AuthHooks/useLoginHook.ts +++ b/hooks/AuthHooks/useLoginHook.ts @@ -37,6 +37,7 @@ const useLoginHook = () => { localStorage.setItem('isLoggedIn', 'true'); localStorage.setItem('user', values.usr); localStorage.setItem('party_name', tokenData?.data?.full_name); + localStorage.setItem('user_role', JSON.stringify(tokenData?.data?.user_role)); dispatch(storeToken(tokenData?.data)); router.push('/'); diff --git a/hooks/CheckoutPageHook/useCheckout.ts b/hooks/CheckoutPageHook/useCheckout.ts index 1fc1c9da..6a629570 100644 --- a/hooks/CheckoutPageHook/useCheckout.ts +++ b/hooks/CheckoutPageHook/useCheckout.ts @@ -97,6 +97,7 @@ const useCheckout = () => { setErrMessage('Failed to place order'); } finally { setIsLoading(false); + localStorage.setItem('otp_verified', 'false'); } } }; diff --git a/hooks/CustomerGroupHook/useCustomerGroupList.ts b/hooks/CustomerGroupHook/useCustomerGroupList.ts new file mode 100644 index 00000000..1bf6f440 --- /dev/null +++ b/hooks/CustomerGroupHook/useCustomerGroupList.ts @@ -0,0 +1,50 @@ +import { useEffect, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { get_access_token } from '../../store/slices/auth/token-login-slice'; +import { CONSTANTS } from '../../services/config/app-config'; +import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; +import getCustomerGroupListAPI from '../../services/api/customer-group-list-apis/get-customer-group-list-api'; + +const useCustomerGroupList = () => { + const { isLoading, setIsLoading, errorMessage, setErrMessage }: any = useHandleStateUpdate(); + const { SUMMIT_APP_CONFIG }: any = CONSTANTS; + const [customerGroupList, setCustomerGroupList] = useState({}); + const tokenFromStore: any = useSelector(get_access_token); + + const fetchCustomerGroupList: any = async () => { + let customerGroupList: any; + setIsLoading(true); + + /** + * Fetches user details from the API using the given token. + * + * @async + * @function getUserDetailsAPI + * @param {Object} SUMMIT_APP_CONFIG - The Summit API SDK object used to interact with the API. + * @param {string} token - The authentication token obtained from the store. + * @returns {Promise} - Resolves when the API response is handled. + * @throws {Error} Throws an error if the API call fails. + */ + try { + customerGroupList = await getCustomerGroupListAPI(SUMMIT_APP_CONFIG, tokenFromStore.token); + console.log('customerGroupList', customerGroupList); + if (customerGroupList?.status === 200 && customerGroupList?.data?.message?.msg === 'success') { + setCustomerGroupList(customerGroupList?.data?.message?.data); + } else { + setErrMessage(customerGroupList?.data?.message?.error); + } + } catch (error) { + setErrMessage(customerGroupList?.data?.message?.error); + } finally { + setIsLoading(false); + } + }; + + useEffect(() => { + fetchCustomerGroupList(); + }, []); + + return { customerGroupList, isLoading, errorMessage }; +}; + +export default useCustomerGroupList; diff --git a/hooks/ProductListPageHooks/useDropDownFilterHook.ts b/hooks/ProductListPageHooks/useDropDownFilterHook.ts index ddb5a0fa..4792f08f 100644 --- a/hooks/ProductListPageHooks/useDropDownFilterHook.ts +++ b/hooks/ProductListPageHooks/useDropDownFilterHook.ts @@ -2,57 +2,63 @@ import { useEffect, useState } from 'react'; import { useRouter } from 'next/router'; import { useSelector } from 'react-redux'; import { get_access_token } from '../../store/slices/auth/token-login-slice'; -import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; import { CONSTANTS } from '../../services/config/app-config'; import fetchProductListingPageFilters from '../../services/api/product-listing-page-apis/get-filters-api'; -import axios from 'axios'; import fetchProductListingPageDropDownFilters from '../../services/api/product-listing-page-apis/get-dropdown-filters-api'; +import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; +import fetchProductListingPageALLFilters from '../../services/api/product-listing-page-apis/get-all-filters-api'; const useDropDownFilterHook = () => { - const router: any = useRouter(); - const { query } = useRouter(); - const { SUMMIT_APP_CONFIG }: any = CONSTANTS; - const { isLoading, setIsLoading, errorMessage, setErrMessage }: any = useHandleStateUpdate(); - const tokenFromStore: any = useSelector(get_access_token); - - const [isLoadingDropDown, setIsLoadingDropDown] = useState(false); - const [errorMessageDropDown, setErrMessageDropDown] = useState(''); - const [filtersData, setFiltersData] = useState([]); + const router = useRouter(); + const { query } = router; + const { SUMMIT_APP_CONFIG } = CONSTANTS; + const tokenFromStore = useSelector(get_access_token); + const { isLoading, setIsLoading, errorMessage, setErrMessage } = useHandleStateUpdate(); + + const [isLoadingDropDown, setIsLoadingDropDown] = useState(false); + const [errorMessageDropDown, setErrMessageDropDown] = useState(''); + const [filtersData, setFiltersData] = useState({}); const [checkBoxfiltersData, setCheckBoxfiltersData] = useState([]); - const [selectedFilters, setSelectedFilters] = useState(); - const [lastChangedSection, setLastChangedSection] = useState(null); - const [initialFiltersSet, setInitialFiltersSet] = useState(false); + const [selectedFilters, setSelectedFilters] = useState([]); - const fetchDropDownFiltersDataFunction = async (selectedValues?: any) => { - const vehicleCompany = selectedValues?.[0]; - const reqParams = vehicleCompany || '' + + // Fetch dropdown filters + const fetchDropDownFiltersDataFunction = async (paramObject?: any) => { setIsLoadingDropDown(true); try { - const response: any = await fetchProductListingPageDropDownFilters(SUMMIT_APP_CONFIG, reqParams, tokenFromStore?.token); + const response = await fetchProductListingPageDropDownFilters( + SUMMIT_APP_CONFIG, + paramObject, + tokenFromStore?.token + ); + if (response?.status === 200) { - setFiltersData(response?.data?.message || {}); + setFiltersData(response?.data?.message?.data || {}); } else { - setFiltersData([]); - setErrMessageDropDown(response?.error || 'Something went wrong'); + setFiltersData({}); + setErrMessageDropDown(response?.error || 'Failed to fetch dropdown filters'); } - - return response; } catch (error: any) { - console.error("Error fetching filters:", error); - setFiltersData([]); + setFiltersData({}); setErrMessageDropDown(error?.message || 'API error'); } finally { setIsLoadingDropDown(false); } }; + // Fetch checkbox filters const fetchFiltersDataFunction = async () => { setIsLoading(true); const reqParams = { query: query, }; try { - const getFiltersData: any = await fetchProductListingPageFilters(SUMMIT_APP_CONFIG, reqParams, tokenFromStore?.token); + let getFiltersData: any; + if (!query?.category) { + getFiltersData = await fetchProductListingPageALLFilters(SUMMIT_APP_CONFIG, tokenFromStore?.token); + } else { + getFiltersData = await fetchProductListingPageFilters(SUMMIT_APP_CONFIG, reqParams, tokenFromStore?.token); + } if (getFiltersData?.data?.message?.msg === 'success') { setCheckBoxfiltersData(getFiltersData?.data?.message?.data); setIsLoading(false); @@ -70,95 +76,123 @@ const useDropDownFilterHook = () => { } }; + // Initial fetch on mount useEffect(() => { - fetchFiltersDataFunction(); - if (!initialFiltersSet) { - fetchDropDownFiltersDataFunction(); - } - if (router.query.hasOwnProperty('vehicle_filters')) { - const encodedFilterString: any = router.query.vehicle_filters; - if (encodedFilterString !== undefined) { - const decodedFilterString = decodeURIComponent(encodedFilterString); + // fetchFiltersDataFunction(); + fetchDropDownFiltersDataFunction(); + }, []); + + // Handle query changes and update filters + useEffect(() => { + fetchFiltersDataFunction(); // Initial fetch (assuming this should be fetchDropDownFiltersDataFunction) + + if (query.vehicle_filters) { + try { + const filterParam = Array.isArray(query.vehicle_filters) + ? query.vehicle_filters[0] // Use the first value if it's an array + : query.vehicle_filters; + // const decodedFilterString = decodeURIComponent(query?.vehicle_filters); + const decodedFilterString = decodeURIComponent(filterParam); const decodedFilters = JSON.parse(decodedFilterString); setSelectedFilters(decodedFilters); - } - } - setInitialFiltersSet(true); // mark initial setup complete - }, [query]); + // Check for "Vehicle Company" and "Vehicle" in decodedFilters + const vehicleCompanyFilter = decodedFilters.find((filter: any) => filter.name === "Vehicle Company"); + const vehicleFilter = decodedFilters.find((filter: any) => filter.name === "Vehicle"); - // Watch for Vehicle Company changes (only after initial load) - useEffect(() => { - const changedFilter = selectedFilters?.length > 0 && selectedFilters.find((f: any) => f.name === lastChangedSection); - if (lastChangedSection === 'Vehicle Company' && changedFilter) { - fetchDropDownFiltersDataFunction(changedFilter.value); + // Construct paramObject with available values, default to empty array if not present + const paramObject = { + vehicle_company: vehicleCompanyFilter ? vehicleCompanyFilter.value : [], + vehicle_name: vehicleFilter ? vehicleFilter.value : [] + }; + + // Call fetchDropDownFiltersDataFunction with paramObject if at least one filter exists + if (vehicleCompanyFilter || vehicleFilter) { + fetchDropDownFiltersDataFunction(paramObject); + } else { + // If neither filter is present, fetch without additional params + fetchDropDownFiltersDataFunction(); + } + } catch (error) { + console.error('Error parsing vehicle_filters from URL:', error); + fetchDropDownFiltersDataFunction(); // Fetch default dropdown on error + } + } else { + // If no vehicle_filters in query, reset filters and fetch default dropdown + setSelectedFilters([]); + fetchDropDownFiltersDataFunction(); } - }, [selectedFilters, lastChangedSection, initialFiltersSet]); + }, [query]); + // Update URL with filters + const updateUrlWithFilters = async (filters: any[]) => { + const baseUrl = router.asPath.split('?')[0]; + const filterString = filters.length > 0 ? `&vehicle_filters=${encodeURIComponent(JSON.stringify(filters))}` : ''; + const newUrl = `${baseUrl}?page=1${filterString}`; + await router.push(newUrl); + }; - const handleFilterSelectDropDown = async (selectedOptions: any, meta: any = null, isColorFilter?: boolean, isActiveColor?: boolean, colorValue?: string) => { - let duplicateFilters: any[] = []; - const section = meta?.name || selectedOptions?.[0]?.section || ''; + // Handle dropdown filter selection + const handleFilterSelectDropDown = (option: any, meta: any) => { + const section = meta?.name || option[0]?.section || ''; + const selectedValue = option[0]?.value; + + setSelectedFilters((prevFilters) => { + const updatedFilters = [...prevFilters]; + const existingSectionIndex = updatedFilters.findIndex((filter) => filter.name === section); + + if (!selectedValue) { + // Clear filter for the section + const newFilters = updatedFilters.filter((filter) => filter.name !== section); + if (section === 'Vehicle Company') { + updateUrlWithFilters(newFilters.filter((filter) => filter.name === 'Vehicle Company')); + return newFilters.filter((filter) => filter.name === 'Vehicle Company'); + } + updateUrlWithFilters(newFilters); + return newFilters; + } - if (!selectedOptions || !Array.isArray(selectedOptions) || selectedOptions.length === 0) { - setSelectedFilters((prevFilters: any) => { - const updatedFilters = prevFilters.filter((filter: any) => filter.name !== section); - duplicateFilters = [...updatedFilters]; - setLastChangedSection(section); // track which section changed - return duplicateFilters; - }); + if (existingSectionIndex !== -1) { + const values = updatedFilters[existingSectionIndex].value; + const isSelected = values.includes(selectedValue); - } else { - const selectedValues = selectedOptions.map((opt: any) => opt.value); - setSelectedFilters((prevFilters: any) => { - const safePrevFilters = Array.isArray(prevFilters) ? prevFilters : []; - let updatedFilters = [...safePrevFilters]; - const existingSectionIndex = updatedFilters.findIndex((filter: any) => filter.name === section); - - if (existingSectionIndex !== -1) { - updatedFilters[existingSectionIndex].value = selectedValues; + if (isSelected) { + updatedFilters[existingSectionIndex].value = values.filter((v: any) => v !== selectedValue); + if (updatedFilters[existingSectionIndex].value.length === 0) { + updatedFilters.splice(existingSectionIndex, 1); + } } else { - updatedFilters.push({ name: section, value: selectedValues }); + updatedFilters[existingSectionIndex].value.push(selectedValue); } - - duplicateFilters = [...updatedFilters] - setLastChangedSection(section); // track which section changed - return duplicateFilters; - }); - } - - const filterString = duplicateFilters?.length > 0 ? `&vehicle_filters=${encodeURIComponent(JSON.stringify(duplicateFilters))}` : ''; - let url = router.asPath; - const existingFilterIndex = url.indexOf('&vehicle_filters='); - if (existingFilterIndex !== -1) { - const ampIndex = url.indexOf('&', existingFilterIndex + 1); - if (ampIndex !== -1) { - url = url.slice(0, existingFilterIndex) + url.slice(ampIndex); } else { - url = url.slice(0, existingFilterIndex); + updatedFilters.push({ name: section, value: [selectedValue] }); } - } - if (filterString) { - url = `${url.split('?')[0]}?&page=1${filterString}`; - } else { - url = `${url.split('?')[0]}?page=1`; - } + if (section === 'Vehicle Company') { + const newFilters = updatedFilters.filter((filter) => filter.name === 'Vehicle Company'); + updateUrlWithFilters(newFilters); + return newFilters; + } - await router.push(url); + updateUrlWithFilters(updatedFilters); + return updatedFilters; + }); }; - const handleFilterCheckFun = async (event: any, isColorFilter?: boolean, isActiveColor?: boolean, colorValue?: string) => { - let duplicateFilters: any; - const section = isColorFilter ? 'Color' : event.target.name; // Use "Color" for color filters, otherwise from event - const filterValue = isColorFilter ? colorValue : event.target.value; // Use `colorValue` for color filters - const isChecked = isColorFilter ? isActiveColor : event.target.checked; // Colors are selected on click, so treat them as checked - - setSelectedFilters((prevFilters: any) => { - const safePrevFilters = Array.isArray(prevFilters) ? prevFilters : []; - let updatedFilters = [...safePrevFilters]; - - const existingSectionIndex = updatedFilters.findIndex((filter: any) => filter.name === section); + // Handle checkbox filter selection + const handleFilterCheckFun = async ( + event: any, + isColorFilter?: boolean, + isActiveColor?: boolean, + colorValue?: string + ) => { + const section = isColorFilter ? 'Color' : event.target.name; + const filterValue = isColorFilter ? colorValue : event.target.value; + const isChecked = isColorFilter ? isActiveColor : event.target.checked; + + setSelectedFilters((prevFilters) => { + const updatedFilters = [...prevFilters]; + const existingSectionIndex = updatedFilters.findIndex((filter) => filter.name === section); if (existingSectionIndex !== -1) { if (isChecked) { @@ -166,46 +200,29 @@ const useDropDownFilterHook = () => { updatedFilters[existingSectionIndex].value.push(filterValue); } } else { - updatedFilters[existingSectionIndex].value = updatedFilters[existingSectionIndex].value.filter((val: any) => val !== filterValue); + updatedFilters[existingSectionIndex].value = updatedFilters[existingSectionIndex].value.filter( + (val: any) => val !== filterValue + ); if (updatedFilters[existingSectionIndex].value.length === 0) { - updatedFilters = updatedFilters.filter((filter) => filter.name !== section); + updatedFilters.splice(existingSectionIndex, 1); } } } else if (isChecked) { updatedFilters.push({ name: section, value: [filterValue] }); } - duplicateFilters = [...updatedFilters]; + updateUrlWithFilters(updatedFilters); return updatedFilters; }); - - const filterString = duplicateFilters?.length > 0 ? `&vehicle_filters=${encodeURIComponent(JSON.stringify(duplicateFilters))}` : ''; - let url = router.asPath; - const existingFilterIndex = url.indexOf('&vehicle_filters='); - if (existingFilterIndex !== -1) { - const ampIndex = url.indexOf('&', existingFilterIndex + 1); - if (ampIndex !== -1) { - url = url.slice(0, existingFilterIndex) + url.slice(ampIndex); - } else { - url = url.slice(0, existingFilterIndex); - } - } - - if (filterString) { - url = `${url.split('?')[0]}?&page=1${filterString}`; - } else { - url = `${url.split('?')[0]}?page=1`; - } - - await router.push(url); }; - + // Clear all filters const clearFilters = async () => { setSelectedFilters([]); const baseUrl = router.asPath.split('?')[0]; - await router.push(`${baseUrl}?page=1¤cy=INR`); + await router.push(`${baseUrl}?page=1`, undefined, { shallow: true }); }; + return { checkBoxfiltersData, filtersData, @@ -221,3 +238,4 @@ const useDropDownFilterHook = () => { }; export default useDropDownFilterHook; + diff --git a/hooks/WebsiteUserList/useAddMechanic.ts b/hooks/WebsiteUserList/useAddMechanic.ts new file mode 100644 index 00000000..65874e7b --- /dev/null +++ b/hooks/WebsiteUserList/useAddMechanic.ts @@ -0,0 +1,49 @@ +import { useSelector } from 'react-redux'; +import { toast } from 'react-toastify'; +import { CONSTANTS } from '../../services/config/app-config'; +import { get_access_token } from '../../store/slices/auth/token-login-slice'; +import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; +import { AddMechanicToUserAPI } from '../../services/api/user/add-mechanic-to-user-api'; + +const useAddMechanic = () => { + const { SUMMIT_APP_CONFIG }: any = CONSTANTS; + const tokenFromStore: any = useSelector(get_access_token); + const { isLoading, setIsLoading, errorMessage, setErrMessage }: any = useHandleStateUpdate(); + + + const handleAddMechanic = async ({ email_id, mechanic }: any) => { + + const param = { + version: "v2", + method: "update_mechanic_in_customer", + entity: "user", + email_id, + mechanic + }; + + setIsLoading(true); + try { + let addMechanic: any = await AddMechanicToUserAPI(SUMMIT_APP_CONFIG, param, tokenFromStore.token); + if (addMechanic?.status === 200 && addMechanic?.data?.message !== 'error') { + toast.success("Mechanic updated successfully!"); + } else { + toast.error(addMechanic?.data?.message?.error || 'Something went wrong'); + setErrMessage(addMechanic?.data?.message?.error); + } + + } catch (error) { + toast.error("Failed to update mechanic."); + console.error("API Error:", error); + } finally { + setIsLoading(false); + } + } + + + return { + handleAddMechanic, + isLoading + }; +}; + +export default useAddMechanic; diff --git a/hooks/WebsiteUserList/useMechanicList.ts b/hooks/WebsiteUserList/useMechanicList.ts new file mode 100644 index 00000000..b2044dc0 --- /dev/null +++ b/hooks/WebsiteUserList/useMechanicList.ts @@ -0,0 +1,50 @@ +import { useEffect, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { get_access_token } from '../../store/slices/auth/token-login-slice'; +import { CONSTANTS } from '../../services/config/app-config'; +import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; +import getWebsiteUserListAPI from '../../services/api/user/get-website-user-list-api'; +import getMechanicListAPI from '../../services/api/user/get-mechanic-list-api'; + +const useMechanicList = () => { + const { isLoading, setIsLoading, errorMessage, setErrMessage }: any = useHandleStateUpdate(); + const { SUMMIT_APP_CONFIG }: any = CONSTANTS; + const [mechanicList, setMechanicList] = useState({}); + const tokenFromStore: any = useSelector(get_access_token); + + const fetchMechanicList: any = async () => { + let mechanicList: any; + setIsLoading(true); + + /** + * Fetches user details from the API using the given token. + * + * @async + * @function getMechanicListAPI + * @param {Object} SUMMIT_APP_CONFIG - The Summit API SDK object used to interact with the API. + * @param {string} token - The authentication token obtained from the store. + * @returns {Promise} - Resolves when the API response is handled. + * @throws {Error} Throws an error if the API call fails. + */ + try { + mechanicList = await getMechanicListAPI(SUMMIT_APP_CONFIG, tokenFromStore.token); + if (mechanicList?.status === 200 && mechanicList?.data?.message?.msg === 'success') { + setMechanicList(mechanicList?.data?.message?.data); + } else { + setErrMessage(mechanicList?.data?.message?.error); + } + } catch (error) { + setErrMessage(mechanicList?.data?.message?.error); + } finally { + setIsLoading(false); + } + }; + + useEffect(() => { + fetchMechanicList(); + }, []); + + return { mechanicList, isLoading, errorMessage }; +}; + +export default useMechanicList; diff --git a/hooks/WebsiteUserList/useWebsiteUserList.ts b/hooks/WebsiteUserList/useWebsiteUserList.ts new file mode 100644 index 00000000..f8c838ce --- /dev/null +++ b/hooks/WebsiteUserList/useWebsiteUserList.ts @@ -0,0 +1,50 @@ +import { useEffect, useState } from 'react'; +import { useSelector } from 'react-redux'; +import { get_access_token } from '../../store/slices/auth/token-login-slice'; +import { CONSTANTS } from '../../services/config/app-config'; +import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; +import getWebsiteUserListAPI from '../../services/api/user/get-website-user-list-api'; + +const useWebsiteUserList = (type: any) => { + const { isLoading, setIsLoading, errorMessage, setErrMessage }: any = useHandleStateUpdate(); + const { SUMMIT_APP_CONFIG }: any = CONSTANTS; + const [websiteUserList, setWebsiteUserList] = useState({}); + const tokenFromStore: any = useSelector(get_access_token); + + const fetchuseWebsiteUserListList: any = async () => { + let websiteUserList: any; + setIsLoading(true); + + /** + * Fetches user details from the API using the given token. + * + * @async + * @function getUserDetailsAPI + * @param {Object} SUMMIT_APP_CONFIG - The Summit API SDK object used to interact with the API. + * @param {string} token - The authentication token obtained from the store. + * @returns {Promise} - Resolves when the API response is handled. + * @throws {Error} Throws an error if the API call fails. + */ + try { + websiteUserList = await getWebsiteUserListAPI(SUMMIT_APP_CONFIG, type, tokenFromStore.token); + console.log('websiteUserList', websiteUserList); + if (websiteUserList?.status === 200 && websiteUserList?.data?.message?.msg === 'success') { + setWebsiteUserList(websiteUserList?.data?.message?.data); + } else { + setErrMessage(websiteUserList?.data?.message?.error); + } + } catch (error) { + setErrMessage(websiteUserList?.data?.message?.error); + } finally { + setIsLoading(false); + } + }; + + useEffect(() => { + fetchuseWebsiteUserListList(); + }, [type]); + + return { websiteUserList, isLoading, errorMessage }; +}; + +export default useWebsiteUserList; diff --git a/package.json b/package.json index 44dde76a..85263fb3 100644 --- a/package.json +++ b/package.json @@ -39,11 +39,13 @@ "react-paginate": "^8.2.0", "react-redux": "^8.0.5", "react-select": "^5.10.1", + "react-select-search": "^4.1.8", "react-simple-star-rating": "^5.1.7", "react-social-login-buttons": "^4.1.0", "react-toastify": "^9.1.3", "reactjs-social-login": "^2.6.3", "redux-persist": "^6.0.0", + "swiper": "^11.2.6", "yup": "^1.3.3" }, "devDependencies": { diff --git a/pages/otp.tsx b/pages/otp.tsx new file mode 100644 index 00000000..12436d5d --- /dev/null +++ b/pages/otp.tsx @@ -0,0 +1,11 @@ +import OtpForm from "../components/CheckoutPageComponents/OtpForm"; + +const OTPForm = () => { + return ( + <> + + + ); + }; + + export default OTPForm; \ No newline at end of file diff --git a/pages/profile.tsx b/pages/profile.tsx new file mode 100644 index 00000000..624abd91 --- /dev/null +++ b/pages/profile.tsx @@ -0,0 +1,12 @@ +import ProfileMaster from "../components/profile/ProfileMaster"; + + +const Profile = () => { + return ( + <> + + + ); + }; + + export default Profile; \ No newline at end of file diff --git a/services/api/customer-group-list-apis/get-customer-group-list-api.ts b/services/api/customer-group-list-apis/get-customer-group-list-api.ts new file mode 100644 index 00000000..4a24b574 --- /dev/null +++ b/services/api/customer-group-list-apis/get-customer-group-list-api.ts @@ -0,0 +1,27 @@ +import APP_CONFIG from '../../../interfaces/app-config-interface'; +import { executeGETAPI } from '../../../utils/http-methods'; + +/** + * Fetches User Details from the API using the given parameters. + * + * @async + * @function getUserDetailsAPI + * @param {string} appConfig - The configuration of the application. + * @param {string} token - The authentication token. + * @returns {Promise} - The response from the API call. + * @throws {Error} Throws an error if the API call fails. + */ +const getCustomerGroupListAPI = async (appConfig: APP_CONFIG, token: any): Promise => { + let additionalParams = {}; + // Use executeGETAPI to handle GET Request logic + const response = await executeGETAPI( + appConfig, + 'get-customer-group-list-api', + token, + additionalParams // Pass additional parameters if needed + ); + + return response; +}; + +export default getCustomerGroupListAPI; diff --git a/services/api/product-listing-page-apis/get-all-filters-api.ts b/services/api/product-listing-page-apis/get-all-filters-api.ts new file mode 100644 index 00000000..2a641098 --- /dev/null +++ b/services/api/product-listing-page-apis/get-all-filters-api.ts @@ -0,0 +1,17 @@ +import APP_CONFIG from '../../../interfaces/app-config-interface'; +import { executeGETAPI } from '../../../utils/http-methods'; + +const fetchProductListingPageALLFilters = async (appConfig: APP_CONFIG, token: any) => { + const additionalParams = {}; // Add additional parameters if needed + // Use executeGETAPI to handle GET Request logic + const response = await executeGETAPI( + appConfig, + 'get-product-listing-all-filters-api', + token, + additionalParams // Pass additional parameters if needed + ); + + return response; +}; + +export default fetchProductListingPageALLFilters; diff --git a/services/api/product-listing-page-apis/get-dropdown-filters-api.ts b/services/api/product-listing-page-apis/get-dropdown-filters-api.ts index cb751279..f4e9afc9 100644 --- a/services/api/product-listing-page-apis/get-dropdown-filters-api.ts +++ b/services/api/product-listing-page-apis/get-dropdown-filters-api.ts @@ -2,13 +2,16 @@ import APP_CONFIG from '../../../interfaces/app-config-interface'; import { executeGETAPI } from '../../../utils/http-methods'; const fetchProductListingPageDropDownFilters = async (appConfig: APP_CONFIG, requestParams: any, token: any) => { - const additionalParams = { vehicle_company:requestParams}; // Add additional parameters if needed + const additionalParams = { + vehicle_company: requestParams?.vehicle_company || [], + vehicle_name: requestParams?.vehicle_name || [] + }; // Use executeGETAPI to handle GET Request logic const response = await executeGETAPI( appConfig, 'get-product-listing-dropdown-filters-api', token, - additionalParams // Pass additional parameters if needed + additionalParams ); return response; diff --git a/services/api/product-listing-page-apis/get-product-list-api.ts b/services/api/product-listing-page-apis/get-product-list-api.ts index fd3735df..a1a835e8 100644 --- a/services/api/product-listing-page-apis/get-product-list-api.ts +++ b/services/api/product-listing-page-apis/get-product-list-api.ts @@ -16,6 +16,7 @@ const fetchProductListingFromAPI = async (appName: any, query: any, token: any) } const category: any = query.url_params.category; + const email: any = query.url_params.email || ''; // Construct URL parameters const urlParams = Object.keys(query.url_params) @@ -55,6 +56,7 @@ const fetchProductListingFromAPI = async (appName: any, query: any, token: any) additionalParams = { ...additionalParams, category, + email }; response = await executeGETAPI(appName, 'product-list-api', token, additionalParams); } else if (query.router_origin === 'catalog') { diff --git a/services/api/user/add-mechanic-to-user-api.ts b/services/api/user/add-mechanic-to-user-api.ts new file mode 100644 index 00000000..f6a3c5b8 --- /dev/null +++ b/services/api/user/add-mechanic-to-user-api.ts @@ -0,0 +1,7 @@ +import APP_CONFIG from '../../../interfaces/app-config-interface'; +import { executePOSTAPI } from '../../../utils/http-methods'; + +export const AddMechanicToUserAPI: any = async (appConfig: APP_CONFIG, apiBody: any, token?: any) => { + const response = await executePOSTAPI(appConfig, 'add-mechanic-to-user-api', apiBody, token); + return response; +}; diff --git a/services/api/user/get-mechanic-list-api.ts b/services/api/user/get-mechanic-list-api.ts new file mode 100644 index 00000000..32a84797 --- /dev/null +++ b/services/api/user/get-mechanic-list-api.ts @@ -0,0 +1,27 @@ +import APP_CONFIG from '../../../interfaces/app-config-interface'; +import { executeGETAPI } from '../../../utils/http-methods'; + +/** + * Fetches website user list from the API using the given parameters. + * + * @async + * @function getUserDetailsAPI + * @param {string} appConfig - The configuration of the application. + * @param {string} token - The authentication token. + * @returns {Promise} - The response from the API call. + * @throws {Error} Throws an error if the API call fails. + */ +const getMechanicListAPI = async (appConfig: APP_CONFIG, token: any): Promise => { + let additionalParams = {}; + // Use executeGETAPI to handle GET Request logic + const response = await executeGETAPI( + appConfig, + 'get-mechanic-list-api', + token, + additionalParams // Pass additional parameters if needed + ); + + return response; +}; + +export default getMechanicListAPI; diff --git a/services/api/user/get-website-user-list-api.ts b/services/api/user/get-website-user-list-api.ts new file mode 100644 index 00000000..269693c5 --- /dev/null +++ b/services/api/user/get-website-user-list-api.ts @@ -0,0 +1,27 @@ +import APP_CONFIG from '../../../interfaces/app-config-interface'; +import { executeGETAPI } from '../../../utils/http-methods'; + +/** + * Fetches website user list from the API using the given parameters. + * + * @async + * @function getUserDetailsAPI + * @param {string} appConfig - The configuration of the application. + * @param {string} token - The authentication token. + * @returns {Promise} - The response from the API call. + * @throws {Error} Throws an error if the API call fails. + */ +const getWebsiteUserListAPI = async (appConfig: APP_CONFIG, type: any, token: any): Promise => { + let additionalParams = { customer_group: type || '' }; + // Use executeGETAPI to handle GET Request logic + const response = await executeGETAPI( + appConfig, + 'get-website-user-list-api', + token, + additionalParams // Pass additional parameters if needed + ); + + return response; +}; + +export default getWebsiteUserListAPI; diff --git a/store/root-reducer.ts b/store/root-reducer.ts index 3446e431..7a69d993 100644 --- a/store/root-reducer.ts +++ b/store/root-reducer.ts @@ -10,6 +10,7 @@ import LanguageReducer from './slices/language-slice/language-json-slice'; import wishlistSlice from './slices/wishlist-slices/wishlist-local-slice'; import quickOrderSlice from './slices/quick-order-slice/quick-order-slice'; import componentsReducer from './slices/general_slices/components-slice'; +import categoryBreadcrumbReducer from "./slices/category-breadcrumb-slice/category-breadcrumb-slice"; const appReducer = combineReducers({ LanguagesScreen: LanguageReducer, @@ -22,6 +23,7 @@ const appReducer = combineReducers({ cart: cartLocalSlice, catalogSlice: catalogLocalSlice, quickOrder: quickOrderSlice, + categoryBreadcrumb: categoryBreadcrumbReducer, }); const rootReducer = (state: any, action: any) => { diff --git a/store/slices/category-breadcrumb-slice/category-breadcrumb-slice.ts b/store/slices/category-breadcrumb-slice/category-breadcrumb-slice.ts new file mode 100644 index 00000000..13be9cbc --- /dev/null +++ b/store/slices/category-breadcrumb-slice/category-breadcrumb-slice.ts @@ -0,0 +1,51 @@ +// store/categoryBreadcrumbSlice.ts +import { createSlice, PayloadAction } from "@reduxjs/toolkit"; + +interface BreadcrumbState { + level: "top" | "sub" | "subsub"; + selectedCategory: any; + selectedSubCategory: any; + selectedSubSubCategory: any; +} + +const initialState: BreadcrumbState = { + level: "top", + selectedCategory: null, + selectedSubCategory: null, + selectedSubSubCategory: null, +}; + +export const categoryBreadcrumbSlice = createSlice({ + name: "categoryBreadcrumb", + initialState, + reducers: { + setLevel: (state, action: PayloadAction<"top" | "sub" | "subsub">) => { + state.level = action.payload; + }, + setSelectedCategory: (state, action: PayloadAction) => { + state.selectedCategory = action.payload; + }, + setSelectedSubCategory: (state, action: PayloadAction) => { + state.selectedSubCategory = action.payload; + }, + setSelectedSubSubCategory: (state, action: PayloadAction) => { + state.selectedSubSubCategory = action.payload; + }, + resetBreadcrumb: (state) => { + state.level = "top"; + state.selectedCategory = null; + state.selectedSubCategory = null; + state.selectedSubSubCategory = null; + }, + }, +}); + +export const { + setLevel, + setSelectedCategory, + setSelectedSubCategory, + setSelectedSubSubCategory, + resetBreadcrumb, +} = categoryBreadcrumbSlice.actions; + +export default categoryBreadcrumbSlice.reducer; diff --git a/utils/api_sdk_registry.ts b/utils/api_sdk_registry.ts index 20cca018..786bbe3a 100644 --- a/utils/api_sdk_registry.ts +++ b/utils/api_sdk_registry.ts @@ -59,6 +59,11 @@ const apiSdkRegistry: any = { 'promotional-banner-api': { method: '', entity: '' }, 'blog-api': { method: 'get_blog_post_list', entity: 'blog_post' }, 'get-product-listing-dropdown-filters-api': { method: 'get_vehicle_filters', entity: 'filter' }, + 'get-customer-group-list-api': { method: 'get_customer_group', entity: 'customer_group' }, + 'get-website-user-list-api': { method: 'get_website_user', entity: 'user' }, + 'get-mechanic-list-api': { method: 'get_mechanic', entity: 'user' }, + 'add-mechanic-to-user-api': { method: 'update_mechanic_in_customer', entity: 'user' }, + 'get-product-listing-all-filters-api': { method: 'get_filters_without_category', entity: 'filter' }, }; export default apiSdkRegistry; From 0af8a129a05e312556b52e40e6e0c332eff590c8 Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Mon, 19 May 2025 17:36:38 +0530 Subject: [PATCH 06/19] Delete hooks/ProductListPageHooks/useDropDownFilterHook.ts --- .../useDropDownFilterHook.ts | 241 ------------------ 1 file changed, 241 deletions(-) delete mode 100644 hooks/ProductListPageHooks/useDropDownFilterHook.ts diff --git a/hooks/ProductListPageHooks/useDropDownFilterHook.ts b/hooks/ProductListPageHooks/useDropDownFilterHook.ts deleted file mode 100644 index 4792f08f..00000000 --- a/hooks/ProductListPageHooks/useDropDownFilterHook.ts +++ /dev/null @@ -1,241 +0,0 @@ -import { useEffect, useState } from 'react'; -import { useRouter } from 'next/router'; -import { useSelector } from 'react-redux'; -import { get_access_token } from '../../store/slices/auth/token-login-slice'; -import { CONSTANTS } from '../../services/config/app-config'; -import fetchProductListingPageFilters from '../../services/api/product-listing-page-apis/get-filters-api'; -import fetchProductListingPageDropDownFilters from '../../services/api/product-listing-page-apis/get-dropdown-filters-api'; -import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; -import fetchProductListingPageALLFilters from '../../services/api/product-listing-page-apis/get-all-filters-api'; - -const useDropDownFilterHook = () => { - const router = useRouter(); - const { query } = router; - const { SUMMIT_APP_CONFIG } = CONSTANTS; - const tokenFromStore = useSelector(get_access_token); - const { isLoading, setIsLoading, errorMessage, setErrMessage } = useHandleStateUpdate(); - - const [isLoadingDropDown, setIsLoadingDropDown] = useState(false); - const [errorMessageDropDown, setErrMessageDropDown] = useState(''); - const [filtersData, setFiltersData] = useState({}); - const [checkBoxfiltersData, setCheckBoxfiltersData] = useState([]); - const [selectedFilters, setSelectedFilters] = useState([]); - - - // Fetch dropdown filters - const fetchDropDownFiltersDataFunction = async (paramObject?: any) => { - setIsLoadingDropDown(true); - try { - const response = await fetchProductListingPageDropDownFilters( - SUMMIT_APP_CONFIG, - paramObject, - tokenFromStore?.token - ); - - if (response?.status === 200) { - setFiltersData(response?.data?.message?.data || {}); - } else { - setFiltersData({}); - setErrMessageDropDown(response?.error || 'Failed to fetch dropdown filters'); - } - } catch (error: any) { - setFiltersData({}); - setErrMessageDropDown(error?.message || 'API error'); - } finally { - setIsLoadingDropDown(false); - } - }; - - // Fetch checkbox filters - const fetchFiltersDataFunction = async () => { - setIsLoading(true); - const reqParams = { - query: query, - }; - try { - let getFiltersData: any; - if (!query?.category) { - getFiltersData = await fetchProductListingPageALLFilters(SUMMIT_APP_CONFIG, tokenFromStore?.token); - } else { - getFiltersData = await fetchProductListingPageFilters(SUMMIT_APP_CONFIG, reqParams, tokenFromStore?.token); - } - if (getFiltersData?.data?.message?.msg === 'success') { - setCheckBoxfiltersData(getFiltersData?.data?.message?.data); - setIsLoading(false); - } else { - setCheckBoxfiltersData([]); - setIsLoading(false); - setErrMessage(getFiltersData?.data?.message?.error); - } - - return getFiltersData; - } catch (error) { - return; - } finally { - setIsLoading(false); - } - }; - - // Initial fetch on mount - useEffect(() => { - // fetchFiltersDataFunction(); - fetchDropDownFiltersDataFunction(); - }, []); - - // Handle query changes and update filters - useEffect(() => { - fetchFiltersDataFunction(); // Initial fetch (assuming this should be fetchDropDownFiltersDataFunction) - - if (query.vehicle_filters) { - try { - const filterParam = Array.isArray(query.vehicle_filters) - ? query.vehicle_filters[0] // Use the first value if it's an array - : query.vehicle_filters; - // const decodedFilterString = decodeURIComponent(query?.vehicle_filters); - const decodedFilterString = decodeURIComponent(filterParam); - const decodedFilters = JSON.parse(decodedFilterString); - setSelectedFilters(decodedFilters); - - // Check for "Vehicle Company" and "Vehicle" in decodedFilters - const vehicleCompanyFilter = decodedFilters.find((filter: any) => filter.name === "Vehicle Company"); - const vehicleFilter = decodedFilters.find((filter: any) => filter.name === "Vehicle"); - - // Construct paramObject with available values, default to empty array if not present - const paramObject = { - vehicle_company: vehicleCompanyFilter ? vehicleCompanyFilter.value : [], - vehicle_name: vehicleFilter ? vehicleFilter.value : [] - }; - - // Call fetchDropDownFiltersDataFunction with paramObject if at least one filter exists - if (vehicleCompanyFilter || vehicleFilter) { - fetchDropDownFiltersDataFunction(paramObject); - } else { - // If neither filter is present, fetch without additional params - fetchDropDownFiltersDataFunction(); - } - } catch (error) { - console.error('Error parsing vehicle_filters from URL:', error); - fetchDropDownFiltersDataFunction(); // Fetch default dropdown on error - } - } else { - // If no vehicle_filters in query, reset filters and fetch default dropdown - setSelectedFilters([]); - fetchDropDownFiltersDataFunction(); - } - }, [query]); - - // Update URL with filters - const updateUrlWithFilters = async (filters: any[]) => { - const baseUrl = router.asPath.split('?')[0]; - const filterString = filters.length > 0 ? `&vehicle_filters=${encodeURIComponent(JSON.stringify(filters))}` : ''; - const newUrl = `${baseUrl}?page=1${filterString}`; - await router.push(newUrl); - }; - - // Handle dropdown filter selection - const handleFilterSelectDropDown = (option: any, meta: any) => { - const section = meta?.name || option[0]?.section || ''; - const selectedValue = option[0]?.value; - - setSelectedFilters((prevFilters) => { - const updatedFilters = [...prevFilters]; - const existingSectionIndex = updatedFilters.findIndex((filter) => filter.name === section); - - if (!selectedValue) { - // Clear filter for the section - const newFilters = updatedFilters.filter((filter) => filter.name !== section); - if (section === 'Vehicle Company') { - updateUrlWithFilters(newFilters.filter((filter) => filter.name === 'Vehicle Company')); - return newFilters.filter((filter) => filter.name === 'Vehicle Company'); - } - updateUrlWithFilters(newFilters); - return newFilters; - } - - if (existingSectionIndex !== -1) { - const values = updatedFilters[existingSectionIndex].value; - const isSelected = values.includes(selectedValue); - - if (isSelected) { - updatedFilters[existingSectionIndex].value = values.filter((v: any) => v !== selectedValue); - if (updatedFilters[existingSectionIndex].value.length === 0) { - updatedFilters.splice(existingSectionIndex, 1); - } - } else { - updatedFilters[existingSectionIndex].value.push(selectedValue); - } - } else { - updatedFilters.push({ name: section, value: [selectedValue] }); - } - - if (section === 'Vehicle Company') { - const newFilters = updatedFilters.filter((filter) => filter.name === 'Vehicle Company'); - updateUrlWithFilters(newFilters); - return newFilters; - } - - updateUrlWithFilters(updatedFilters); - return updatedFilters; - }); - }; - - // Handle checkbox filter selection - const handleFilterCheckFun = async ( - event: any, - isColorFilter?: boolean, - isActiveColor?: boolean, - colorValue?: string - ) => { - const section = isColorFilter ? 'Color' : event.target.name; - const filterValue = isColorFilter ? colorValue : event.target.value; - const isChecked = isColorFilter ? isActiveColor : event.target.checked; - - setSelectedFilters((prevFilters) => { - const updatedFilters = [...prevFilters]; - const existingSectionIndex = updatedFilters.findIndex((filter) => filter.name === section); - - if (existingSectionIndex !== -1) { - if (isChecked) { - if (!updatedFilters[existingSectionIndex].value.includes(filterValue)) { - updatedFilters[existingSectionIndex].value.push(filterValue); - } - } else { - updatedFilters[existingSectionIndex].value = updatedFilters[existingSectionIndex].value.filter( - (val: any) => val !== filterValue - ); - if (updatedFilters[existingSectionIndex].value.length === 0) { - updatedFilters.splice(existingSectionIndex, 1); - } - } - } else if (isChecked) { - updatedFilters.push({ name: section, value: [filterValue] }); - } - - updateUrlWithFilters(updatedFilters); - return updatedFilters; - }); - }; - - // Clear all filters - const clearFilters = async () => { - setSelectedFilters([]); - const baseUrl = router.asPath.split('?')[0]; - await router.push(`${baseUrl}?page=1`, undefined, { shallow: true }); - }; - - return { - checkBoxfiltersData, - filtersData, - isLoadingDropDown, - isLoading, - errorMessage, - errorMessageDropDown, - handleFilterSelectDropDown, - handleFilterCheckFun, - selectedFilters, - clearFilters, - }; -}; - -export default useDropDownFilterHook; - From 7c26d77cde57e8df3de08a73aea5c2f782a6cee1 Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Mon, 19 May 2025 17:37:42 +0530 Subject: [PATCH 07/19] Delete hooks/WebsiteUserList/useAddMechanic.ts --- hooks/WebsiteUserList/useAddMechanic.ts | 49 ------------------------- 1 file changed, 49 deletions(-) delete mode 100644 hooks/WebsiteUserList/useAddMechanic.ts diff --git a/hooks/WebsiteUserList/useAddMechanic.ts b/hooks/WebsiteUserList/useAddMechanic.ts deleted file mode 100644 index 65874e7b..00000000 --- a/hooks/WebsiteUserList/useAddMechanic.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { useSelector } from 'react-redux'; -import { toast } from 'react-toastify'; -import { CONSTANTS } from '../../services/config/app-config'; -import { get_access_token } from '../../store/slices/auth/token-login-slice'; -import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; -import { AddMechanicToUserAPI } from '../../services/api/user/add-mechanic-to-user-api'; - -const useAddMechanic = () => { - const { SUMMIT_APP_CONFIG }: any = CONSTANTS; - const tokenFromStore: any = useSelector(get_access_token); - const { isLoading, setIsLoading, errorMessage, setErrMessage }: any = useHandleStateUpdate(); - - - const handleAddMechanic = async ({ email_id, mechanic }: any) => { - - const param = { - version: "v2", - method: "update_mechanic_in_customer", - entity: "user", - email_id, - mechanic - }; - - setIsLoading(true); - try { - let addMechanic: any = await AddMechanicToUserAPI(SUMMIT_APP_CONFIG, param, tokenFromStore.token); - if (addMechanic?.status === 200 && addMechanic?.data?.message !== 'error') { - toast.success("Mechanic updated successfully!"); - } else { - toast.error(addMechanic?.data?.message?.error || 'Something went wrong'); - setErrMessage(addMechanic?.data?.message?.error); - } - - } catch (error) { - toast.error("Failed to update mechanic."); - console.error("API Error:", error); - } finally { - setIsLoading(false); - } - } - - - return { - handleAddMechanic, - isLoading - }; -}; - -export default useAddMechanic; From e4e994f774ed73d04e6c362f855e9a8714a3cfcb Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Mon, 19 May 2025 17:37:55 +0530 Subject: [PATCH 08/19] Delete hooks/WebsiteUserList/useMechanicList.ts --- hooks/WebsiteUserList/useMechanicList.ts | 50 ------------------------ 1 file changed, 50 deletions(-) delete mode 100644 hooks/WebsiteUserList/useMechanicList.ts diff --git a/hooks/WebsiteUserList/useMechanicList.ts b/hooks/WebsiteUserList/useMechanicList.ts deleted file mode 100644 index b2044dc0..00000000 --- a/hooks/WebsiteUserList/useMechanicList.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { useEffect, useState } from 'react'; -import { useSelector } from 'react-redux'; -import { get_access_token } from '../../store/slices/auth/token-login-slice'; -import { CONSTANTS } from '../../services/config/app-config'; -import useHandleStateUpdate from '../GeneralHooks/handle-state-update-hook'; -import getWebsiteUserListAPI from '../../services/api/user/get-website-user-list-api'; -import getMechanicListAPI from '../../services/api/user/get-mechanic-list-api'; - -const useMechanicList = () => { - const { isLoading, setIsLoading, errorMessage, setErrMessage }: any = useHandleStateUpdate(); - const { SUMMIT_APP_CONFIG }: any = CONSTANTS; - const [mechanicList, setMechanicList] = useState({}); - const tokenFromStore: any = useSelector(get_access_token); - - const fetchMechanicList: any = async () => { - let mechanicList: any; - setIsLoading(true); - - /** - * Fetches user details from the API using the given token. - * - * @async - * @function getMechanicListAPI - * @param {Object} SUMMIT_APP_CONFIG - The Summit API SDK object used to interact with the API. - * @param {string} token - The authentication token obtained from the store. - * @returns {Promise} - Resolves when the API response is handled. - * @throws {Error} Throws an error if the API call fails. - */ - try { - mechanicList = await getMechanicListAPI(SUMMIT_APP_CONFIG, tokenFromStore.token); - if (mechanicList?.status === 200 && mechanicList?.data?.message?.msg === 'success') { - setMechanicList(mechanicList?.data?.message?.data); - } else { - setErrMessage(mechanicList?.data?.message?.error); - } - } catch (error) { - setErrMessage(mechanicList?.data?.message?.error); - } finally { - setIsLoading(false); - } - }; - - useEffect(() => { - fetchMechanicList(); - }, []); - - return { mechanicList, isLoading, errorMessage }; -}; - -export default useMechanicList; From 4ea10b145faae6682b7a3b1e68479d60a86999ba Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Mon, 19 May 2025 17:39:00 +0530 Subject: [PATCH 09/19] Delete pages/otp.tsx --- pages/otp.tsx | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 pages/otp.tsx diff --git a/pages/otp.tsx b/pages/otp.tsx deleted file mode 100644 index 12436d5d..00000000 --- a/pages/otp.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import OtpForm from "../components/CheckoutPageComponents/OtpForm"; - -const OTPForm = () => { - return ( - <> - - - ); - }; - - export default OTPForm; \ No newline at end of file From 3415b7083baab6b15733e18e9d5fc1d1cb0f7d63 Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Mon, 19 May 2025 17:39:19 +0530 Subject: [PATCH 10/19] Delete pages/profile.tsx --- pages/profile.tsx | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 pages/profile.tsx diff --git a/pages/profile.tsx b/pages/profile.tsx deleted file mode 100644 index 624abd91..00000000 --- a/pages/profile.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import ProfileMaster from "../components/profile/ProfileMaster"; - - -const Profile = () => { - return ( - <> - - - ); - }; - - export default Profile; \ No newline at end of file From 598670624c6ffd83d929e114d66e626b519803db Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Mon, 19 May 2025 17:42:00 +0530 Subject: [PATCH 11/19] Delete services/api/product-listing-page-apis/get-dropdown-filters-api.ts --- .../get-dropdown-filters-api.ts | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 services/api/product-listing-page-apis/get-dropdown-filters-api.ts diff --git a/services/api/product-listing-page-apis/get-dropdown-filters-api.ts b/services/api/product-listing-page-apis/get-dropdown-filters-api.ts deleted file mode 100644 index f4e9afc9..00000000 --- a/services/api/product-listing-page-apis/get-dropdown-filters-api.ts +++ /dev/null @@ -1,20 +0,0 @@ -import APP_CONFIG from '../../../interfaces/app-config-interface'; -import { executeGETAPI } from '../../../utils/http-methods'; - -const fetchProductListingPageDropDownFilters = async (appConfig: APP_CONFIG, requestParams: any, token: any) => { - const additionalParams = { - vehicle_company: requestParams?.vehicle_company || [], - vehicle_name: requestParams?.vehicle_name || [] - }; - // Use executeGETAPI to handle GET Request logic - const response = await executeGETAPI( - appConfig, - 'get-product-listing-dropdown-filters-api', - token, - additionalParams - ); - - return response; -}; - -export default fetchProductListingPageDropDownFilters; From 25546ea9b6399b38c0af037fe3d00892de6a5b30 Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Mon, 19 May 2025 17:43:15 +0530 Subject: [PATCH 12/19] Delete services/api/user/add-mechanic-to-user-api.ts --- services/api/user/add-mechanic-to-user-api.ts | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 services/api/user/add-mechanic-to-user-api.ts diff --git a/services/api/user/add-mechanic-to-user-api.ts b/services/api/user/add-mechanic-to-user-api.ts deleted file mode 100644 index f6a3c5b8..00000000 --- a/services/api/user/add-mechanic-to-user-api.ts +++ /dev/null @@ -1,7 +0,0 @@ -import APP_CONFIG from '../../../interfaces/app-config-interface'; -import { executePOSTAPI } from '../../../utils/http-methods'; - -export const AddMechanicToUserAPI: any = async (appConfig: APP_CONFIG, apiBody: any, token?: any) => { - const response = await executePOSTAPI(appConfig, 'add-mechanic-to-user-api', apiBody, token); - return response; -}; From 6f7b7365aaa4f77fbc43649ab1ba3af09823c295 Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Mon, 19 May 2025 17:43:28 +0530 Subject: [PATCH 13/19] Delete services/api/user/get-mechanic-list-api.ts --- services/api/user/get-mechanic-list-api.ts | 27 ---------------------- 1 file changed, 27 deletions(-) delete mode 100644 services/api/user/get-mechanic-list-api.ts diff --git a/services/api/user/get-mechanic-list-api.ts b/services/api/user/get-mechanic-list-api.ts deleted file mode 100644 index 32a84797..00000000 --- a/services/api/user/get-mechanic-list-api.ts +++ /dev/null @@ -1,27 +0,0 @@ -import APP_CONFIG from '../../../interfaces/app-config-interface'; -import { executeGETAPI } from '../../../utils/http-methods'; - -/** - * Fetches website user list from the API using the given parameters. - * - * @async - * @function getUserDetailsAPI - * @param {string} appConfig - The configuration of the application. - * @param {string} token - The authentication token. - * @returns {Promise} - The response from the API call. - * @throws {Error} Throws an error if the API call fails. - */ -const getMechanicListAPI = async (appConfig: APP_CONFIG, token: any): Promise => { - let additionalParams = {}; - // Use executeGETAPI to handle GET Request logic - const response = await executeGETAPI( - appConfig, - 'get-mechanic-list-api', - token, - additionalParams // Pass additional parameters if needed - ); - - return response; -}; - -export default getMechanicListAPI; From 5f89df8a383404705e7855ea9357ff1ca4453800 Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Mon, 19 May 2025 17:45:09 +0530 Subject: [PATCH 14/19] Delete store/slices/category-breadcrumb-slice directory --- .../category-breadcrumb-slice.ts | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 store/slices/category-breadcrumb-slice/category-breadcrumb-slice.ts diff --git a/store/slices/category-breadcrumb-slice/category-breadcrumb-slice.ts b/store/slices/category-breadcrumb-slice/category-breadcrumb-slice.ts deleted file mode 100644 index 13be9cbc..00000000 --- a/store/slices/category-breadcrumb-slice/category-breadcrumb-slice.ts +++ /dev/null @@ -1,51 +0,0 @@ -// store/categoryBreadcrumbSlice.ts -import { createSlice, PayloadAction } from "@reduxjs/toolkit"; - -interface BreadcrumbState { - level: "top" | "sub" | "subsub"; - selectedCategory: any; - selectedSubCategory: any; - selectedSubSubCategory: any; -} - -const initialState: BreadcrumbState = { - level: "top", - selectedCategory: null, - selectedSubCategory: null, - selectedSubSubCategory: null, -}; - -export const categoryBreadcrumbSlice = createSlice({ - name: "categoryBreadcrumb", - initialState, - reducers: { - setLevel: (state, action: PayloadAction<"top" | "sub" | "subsub">) => { - state.level = action.payload; - }, - setSelectedCategory: (state, action: PayloadAction) => { - state.selectedCategory = action.payload; - }, - setSelectedSubCategory: (state, action: PayloadAction) => { - state.selectedSubCategory = action.payload; - }, - setSelectedSubSubCategory: (state, action: PayloadAction) => { - state.selectedSubSubCategory = action.payload; - }, - resetBreadcrumb: (state) => { - state.level = "top"; - state.selectedCategory = null; - state.selectedSubCategory = null; - state.selectedSubSubCategory = null; - }, - }, -}); - -export const { - setLevel, - setSelectedCategory, - setSelectedSubCategory, - setSelectedSubSubCategory, - resetBreadcrumb, -} = categoryBreadcrumbSlice.actions; - -export default categoryBreadcrumbSlice.reducer; From 860023dbe6369a36c55bdcb179a3bed9ae820656 Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Mon, 19 May 2025 17:46:27 +0530 Subject: [PATCH 15/19] Update root-reducer.ts --- store/root-reducer.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/store/root-reducer.ts b/store/root-reducer.ts index 7a69d993..d930ebc4 100644 --- a/store/root-reducer.ts +++ b/store/root-reducer.ts @@ -10,7 +10,6 @@ import LanguageReducer from './slices/language-slice/language-json-slice'; import wishlistSlice from './slices/wishlist-slices/wishlist-local-slice'; import quickOrderSlice from './slices/quick-order-slice/quick-order-slice'; import componentsReducer from './slices/general_slices/components-slice'; -import categoryBreadcrumbReducer from "./slices/category-breadcrumb-slice/category-breadcrumb-slice"; const appReducer = combineReducers({ LanguagesScreen: LanguageReducer, @@ -23,8 +22,7 @@ const appReducer = combineReducers({ cart: cartLocalSlice, catalogSlice: catalogLocalSlice, quickOrder: quickOrderSlice, - categoryBreadcrumb: categoryBreadcrumbReducer, -}); + }); const rootReducer = (state: any, action: any) => { if (action.type === resetStore.type) { From 396005af81f0a9bb67749ef03e36568a156fd7de Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Fri, 23 May 2025 11:41:54 +0530 Subject: [PATCH 16/19] Update useCustomerGroupList.ts --- hooks/CustomerGroupHook/useCustomerGroupList.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/CustomerGroupHook/useCustomerGroupList.ts b/hooks/CustomerGroupHook/useCustomerGroupList.ts index 1bf6f440..cedecab1 100644 --- a/hooks/CustomerGroupHook/useCustomerGroupList.ts +++ b/hooks/CustomerGroupHook/useCustomerGroupList.ts @@ -16,10 +16,10 @@ const useCustomerGroupList = () => { setIsLoading(true); /** - * Fetches user details from the API using the given token. + * Fetches customer group list from the API using the given token. * * @async - * @function getUserDetailsAPI + * @function fetchCustomerGroupList * @param {Object} SUMMIT_APP_CONFIG - The Summit API SDK object used to interact with the API. * @param {string} token - The authentication token obtained from the store. * @returns {Promise} - Resolves when the API response is handled. From cdedd44f78d624a94da5aa995a194fa946d9e233 Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Fri, 23 May 2025 11:43:28 +0530 Subject: [PATCH 17/19] Update useWebsiteUserList.ts --- hooks/WebsiteUserList/useWebsiteUserList.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/WebsiteUserList/useWebsiteUserList.ts b/hooks/WebsiteUserList/useWebsiteUserList.ts index f8c838ce..6ff2a405 100644 --- a/hooks/WebsiteUserList/useWebsiteUserList.ts +++ b/hooks/WebsiteUserList/useWebsiteUserList.ts @@ -16,10 +16,10 @@ const useWebsiteUserList = (type: any) => { setIsLoading(true); /** - * Fetches user details from the API using the given token. + * Fetches user list from the API using the given token. * * @async - * @function getUserDetailsAPI + * @function fetchuseWebsiteUserListList * @param {Object} SUMMIT_APP_CONFIG - The Summit API SDK object used to interact with the API. * @param {string} token - The authentication token obtained from the store. * @returns {Promise} - Resolves when the API response is handled. From 4f2a45797e612f83f0caab56a3e3f089231d7b1c Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Fri, 23 May 2025 11:44:23 +0530 Subject: [PATCH 18/19] Update get-customer-group-list-api.ts --- .../customer-group-list-apis/get-customer-group-list-api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/api/customer-group-list-apis/get-customer-group-list-api.ts b/services/api/customer-group-list-apis/get-customer-group-list-api.ts index 4a24b574..80aa00dd 100644 --- a/services/api/customer-group-list-apis/get-customer-group-list-api.ts +++ b/services/api/customer-group-list-apis/get-customer-group-list-api.ts @@ -2,10 +2,10 @@ import APP_CONFIG from '../../../interfaces/app-config-interface'; import { executeGETAPI } from '../../../utils/http-methods'; /** - * Fetches User Details from the API using the given parameters. + * Fetches customer group list from the API using the given parameters. * * @async - * @function getUserDetailsAPI + * @function getCustomerGroupListAPI * @param {string} appConfig - The configuration of the application. * @param {string} token - The authentication token. * @returns {Promise} - The response from the API call. From f31b90ec567362ae70ebb54a1b0f7d8afcb4ffb0 Mon Sep 17 00:00:00 2001 From: seemachal-8848 <167971880+seemachal-8848@users.noreply.github.com> Date: Fri, 23 May 2025 11:44:59 +0530 Subject: [PATCH 19/19] Update get-website-user-list-api.ts --- services/api/user/get-website-user-list-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/api/user/get-website-user-list-api.ts b/services/api/user/get-website-user-list-api.ts index 269693c5..aee5e17e 100644 --- a/services/api/user/get-website-user-list-api.ts +++ b/services/api/user/get-website-user-list-api.ts @@ -5,7 +5,7 @@ import { executeGETAPI } from '../../../utils/http-methods'; * Fetches website user list from the API using the given parameters. * * @async - * @function getUserDetailsAPI + * @function getWebsiteUserListAPI * @param {string} appConfig - The configuration of the application. * @param {string} token - The authentication token. * @returns {Promise} - The response from the API call.