enh
This commit is contained in:
parent
d95a663d97
commit
1f801f2146
1 changed files with 7 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import { ApiError } from "../lib/api-error";
|
||||||
import { imageUploadS3, getOriginalUrlFromSignedUrl } from "../lib/s3-client";
|
import { imageUploadS3, getOriginalUrlFromSignedUrl } from "../lib/s3-client";
|
||||||
import { deleteS3Image } from "../lib/delete-image";
|
import { deleteS3Image } from "../lib/delete-image";
|
||||||
import type { SpecialDeal } from "../db/types";
|
import type { SpecialDeal } from "../db/types";
|
||||||
|
import { initializeAllStores } from '../stores/store-initializer';
|
||||||
|
|
||||||
type CreateDeal = {
|
type CreateDeal = {
|
||||||
quantity: number;
|
quantity: number;
|
||||||
|
|
@ -106,6 +107,9 @@ export const createProduct = async (req: Request, res: Response) => {
|
||||||
await db.insert(productTags).values(tagAssociations);
|
await db.insert(productTags).values(tagAssociations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reinitialize stores to reflect changes
|
||||||
|
await initializeAllStores();
|
||||||
|
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
product: newProduct,
|
product: newProduct,
|
||||||
deals: createdDeals,
|
deals: createdDeals,
|
||||||
|
|
@ -290,6 +294,9 @@ export const updateProduct = async (req: Request, res: Response) => {
|
||||||
await db.insert(productTags).values(tagAssociations);
|
await db.insert(productTags).values(tagAssociations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reinitialize stores to reflect changes
|
||||||
|
await initializeAllStores();
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
product: updatedProduct,
|
product: updatedProduct,
|
||||||
message: "Product updated successfully",
|
message: "Product updated successfully",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue