Skip to content

Commit

Permalink
Merge pull request #4 from Wemotive-POC/feature/homepage
Browse files Browse the repository at this point in the history
Feature/homepage
  • Loading branch information
RohaanAnsari authored Aug 28, 2023
2 parents 1e7fe26 + 40b2fa5 commit fcd0ebb
Show file tree
Hide file tree
Showing 16 changed files with 911 additions and 447 deletions.
53 changes: 53 additions & 0 deletions src/api/product.api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { getCall } from "./axios";

/**
* function to get all products
* @returns
*/
export const getAllProductRequest = (data) => {
const pageNumber = data.page+1;
const limit = data.pageSize;
const productName = data?.searchData?.productName || "";
const subCategoryName = data?.searchData?.subCategoryName || "";
return new Promise(async (resolve, reject) => {
try {
const quaryParams = `?limit=${limit}&pageNumber=${pageNumber}${subCategoryName?`&categoryIds=${subCategoryName}`:''}${productName?`&productName=${productName}`:""}`
const data = await getCall(`/clientApis/v2/search${quaryParams}`);
return resolve(data.response);
} catch (err) {
return reject(err);
}
});
};

/**
* function to get all filters
* @returns
*/
export const getAllFiltersRequest = (subCatName) => {
return new Promise(async (resolve, reject) => {
try {
const quaryParams = `?category=${subCatName}`
const data = await getCall(`/clientApis/v2/attributes${quaryParams}`);
return resolve(data.response);
} catch (err) {
return reject(err);
}
});
};

/**
* function to get all filters
* @returns
*/
export const getAllFilterValuesRequest = (attributeCode, subCatName) => {
return new Promise(async (resolve, reject) => {
try {
const quaryParams = `?attribute_code=${attributeCode}&category=${subCatName}`
const data = await getCall(`/clientApis/v2/attributeValues${quaryParams}`);
return resolve(data.response);
} catch (err) {
return reject(err);
}
});
};
Loading

0 comments on commit fcd0ebb

Please sign in to comment.