Compare commits
2 Commits
d82afe5a5f
...
develop/tr
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e791b01160 | ||
![]() |
8383be13bc |
@@ -21,11 +21,11 @@ export async function GET(req: NextRequest) {
|
|||||||
return response({ results: [] }, STATUS.OK);
|
return response({ results: [] }, STATUS.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
const testResult = await getProductBySkuOrName(query);
|
const results = await getProductBySkuOrName(query);
|
||||||
|
|
||||||
logger('[Product] search-results', testResult?.length);
|
logger('[Product] search-results', results?.length);
|
||||||
|
|
||||||
return response({ testResult }, STATUS.OK);
|
return response({ results }, STATUS.OK);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return handleError('Product - Get search', error);
|
return handleError('Product - Get search', error);
|
||||||
}
|
}
|
||||||
|
@@ -3,3 +3,6 @@ GET http://localhost:7272/api/product/search?query=B
|
|||||||
|
|
||||||
###
|
###
|
||||||
GET http://localhost:7272/api/product/search?query=Classic
|
GET http://localhost:7272/api/product/search?query=Classic
|
||||||
|
|
||||||
|
###
|
||||||
|
GET http://localhost:7272/api/product/search?query=zzzzzz
|
||||||
|
@@ -99,7 +99,9 @@ export async function createProduct(productData: IProductItem) {
|
|||||||
* Work on server
|
* Work on server
|
||||||
*/
|
*/
|
||||||
const data = { productData };
|
const data = { productData };
|
||||||
await axiosInstance.post(endpoints.product.create, data);
|
const {
|
||||||
|
data: { id },
|
||||||
|
} = await axiosInstance.post(endpoints.product.create, data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Work in local
|
* Work in local
|
||||||
@@ -109,7 +111,7 @@ export async function createProduct(productData: IProductItem) {
|
|||||||
(currentData: any) => {
|
(currentData: any) => {
|
||||||
const currentProducts: IProductItem[] = currentData?.products;
|
const currentProducts: IProductItem[] = currentData?.products;
|
||||||
|
|
||||||
const products = [...currentProducts, productData];
|
const products = [...currentProducts, { ...productData, id }];
|
||||||
|
|
||||||
return { ...currentData, products };
|
return { ...currentData, products };
|
||||||
},
|
},
|
||||||
|
@@ -17,13 +17,15 @@ export function ProductList({ products, loading, sx, ...other }: Props) {
|
|||||||
const renderLoading = () => <ProductItemSkeleton />;
|
const renderLoading = () => <ProductItemSkeleton />;
|
||||||
|
|
||||||
const renderList = () =>
|
const renderList = () =>
|
||||||
products.map((product) => (
|
products.map((product) => {
|
||||||
|
return (
|
||||||
<ProductItem
|
<ProductItem
|
||||||
key={product.id}
|
key={product.id}
|
||||||
product={product}
|
product={product}
|
||||||
detailsHref={paths.product.details(product.id)}
|
detailsHref={paths.product.details(product.id)}
|
||||||
/>
|
/>
|
||||||
));
|
);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
Reference in New Issue
Block a user