🆙 Fix Catalog editor

This commit is contained in:
duckietm
2026-04-17 13:51:46 +02:00
parent b0967d7eaf
commit 88117d937f
6 changed files with 23 additions and 10 deletions
+5
View File
@@ -117,4 +117,9 @@ export class FurnitureOffer implements IPurchasableOffer
{
return true;
}
public get itemIds(): string
{
return String(this._furniData?.id ?? '');
}
}
+1
View File
@@ -22,4 +22,5 @@ export interface IPurchasableOffer
localizationDescription: string;
isLazy: boolean;
products: IProduct[];
itemIds: string;
}
+9 -2
View File
@@ -30,8 +30,9 @@ export class Offer implements IPurchasableOffer
private _products: IProduct[];
private _badgeCode: string;
private _bundlePurchaseAllowed: boolean = false;
private _itemIds: string = '';
constructor(offerId: number, localizationId: string, isRentOffer: boolean, priceInCredits: number, priceInActivityPoints: number, activityPointType: number, giftable: boolean, clubLevel: number, products: IProduct[], bundlePurchaseAllowed: boolean)
constructor(offerId: number, localizationId: string, isRentOffer: boolean, priceInCredits: number, priceInActivityPoints: number, activityPointType: number, giftable: boolean, clubLevel: number, products: IProduct[], bundlePurchaseAllowed: boolean, itemIds: string = '')
{
this._offerId = offerId;
this._localizationId = localizationId;
@@ -43,6 +44,7 @@ export class Offer implements IPurchasableOffer
this._clubLevel = clubLevel;
this._products = products;
this._bundlePurchaseAllowed = bundlePurchaseAllowed;
this._itemIds = itemIds || '';
this.setPricingModelForProducts();
this.setPricingType();
@@ -174,6 +176,11 @@ export class Offer implements IPurchasableOffer
return this._products;
}
public get itemIds(): string
{
return this._itemIds;
}
private setPricingModelForProducts(): void
{
const products = Product.stripAddonProducts(this._products);
@@ -236,7 +243,7 @@ export class Offer implements IPurchasableOffer
products.push(new Product(product.productType, product.productClassId, product.extraParam, product.productCount, productData, furnitureData));
}
const offer = new Offer(this.offerId, this.localizationId, this.isRentOffer, this.priceInCredits, this.priceInActivityPoints, this.activityPointType, this.giftable, this.clubLevel, products, this.bundlePurchaseAllowed);
const offer = new Offer(this.offerId, this.localizationId, this.isRentOffer, this.priceInCredits, this.priceInActivityPoints, this.activityPointType, this.giftable, this.clubLevel, products, this.bundlePurchaseAllowed, this.itemIds);
offer.page = this.page;
@@ -207,7 +207,7 @@ export const CatalogAdminProvider: FC<{ children: ReactNode }> = ({ children })
setLastError(null);
pendingActionRef.current = 'saveOffer';
SendMessageComposer(new CatalogAdminSaveOfferComposer(
data.offerId || 0, data.pageId, parseInt(data.itemIds) || 0,
data.offerId || 0, data.pageId, data.itemIds || '',
data.catalogName, data.costCredits, data.costPoints, data.pointsType,
data.amount, data.clubOnly === '1' ? 1 : 0, data.extradata,
data.haveOffer === '1', data.offerId_group, data.limitedStack, data.orderNumber, currentType
@@ -220,7 +220,7 @@ export const CatalogAdminProvider: FC<{ children: ReactNode }> = ({ children })
setLastError(null);
pendingActionRef.current = 'createOffer';
SendMessageComposer(new CatalogAdminCreateOfferComposer(
data.pageId, parseInt(data.itemIds) || 0,
data.pageId, data.itemIds || '',
data.catalogName, data.costCredits, data.costPoints, data.pointsType,
data.amount, data.clubOnly === '1' ? 1 : 0, data.extradata,
data.haveOffer === '1', data.offerId_group, data.limitedStack, data.orderNumber, currentType
@@ -16,7 +16,7 @@ export const CatalogAdminOfferEditView: FC<{}> = () =>
const createOffer = catalogAdmin?.createOffer;
const loading = catalogAdmin?.loading ?? false;
const [ itemIds, setItemIds ] = useState('0');
const [ itemIds, setItemIds ] = useState('');
const [ catalogName, setCatalogName ] = useState('');
const [ costCredits, setCostCredits ] = useState(0);
const [ costPoints, setCostPoints ] = useState(0);
@@ -37,7 +37,7 @@ export const CatalogAdminOfferEditView: FC<{}> = () =>
if(editingOffer.offerId === -1)
{
setIsNew(true);
setItemIds('0');
setItemIds('');
setCatalogName('');
setCostCredits(0);
setCostPoints(0);
@@ -53,7 +53,7 @@ export const CatalogAdminOfferEditView: FC<{}> = () =>
else
{
setIsNew(false);
setItemIds(String(editingOffer.product?.productClassId || 0));
setItemIds(editingOffer.itemIds || '');
setCatalogName(editingOffer.localizationName || '');
setCostCredits(editingOffer.priceInCredits);
setCostPoints(editingOffer.priceInActivityPoints);
@@ -140,7 +140,7 @@ export const CatalogAdminOfferEditView: FC<{}> = () =>
<div className="grid grid-cols-3 gap-1.5">
<div className="flex flex-col gap-0.5">
<label className="text-[9px] text-muted">Item IDs</label>
<input className={ inputClass } placeholder="1234" type="text" value={ itemIds } onChange={ e => setItemIds(e.target.value) } />
<input className={ inputClass } placeholder="1234 or 100;200" type="text" value={ itemIds } onChange={ e => setItemIds(e.target.value) } />
</div>
<div className="flex flex-col gap-0.5">
<label className="text-[9px] text-muted">{ LocalizeText('catalog.admin.offer.quantity') }</label>
+2 -2
View File
@@ -542,7 +542,7 @@ const useCatalogState = () =>
if(!products.length) continue;
const purchasableOffer = new Offer(offer.offerId, offer.localizationId, offer.rent, offer.priceCredits, offer.priceActivityPoints, offer.priceActivityPointsType, offer.giftable, offer.clubLevel, products, offer.bundlePurchaseAllowed);
const purchasableOffer = new Offer(offer.offerId, offer.localizationId, offer.rent, offer.priceCredits, offer.priceActivityPoints, offer.priceActivityPointsType, offer.giftable, offer.clubLevel, products, offer.bundlePurchaseAllowed, offer.itemIds);
if((currentType === CatalogType.NORMAL) || ((purchasableOffer.pricingModel !== Offer.PRICING_MODEL_BUNDLE) && (purchasableOffer.pricingModel !== Offer.PRICING_MODEL_MULTI))) purchasableOffers.push(purchasableOffer);
}
@@ -609,7 +609,7 @@ const useCatalogState = () =>
products.push(new Product(product.productType, product.furniClassId, product.extraParam, product.productCount, productData, furnitureData, product.uniqueLimitedItem, product.uniqueLimitedSeriesSize, product.uniqueLimitedItemsLeft));
}
const offer = new Offer(offerData.offerId, offerData.localizationId, offerData.rent, offerData.priceCredits, offerData.priceActivityPoints, offerData.priceActivityPointsType, offerData.giftable, offerData.clubLevel, products, offerData.bundlePurchaseAllowed);
const offer = new Offer(offerData.offerId, offerData.localizationId, offerData.rent, offerData.priceCredits, offerData.priceActivityPoints, offerData.priceActivityPointsType, offerData.giftable, offerData.clubLevel, products, offerData.bundlePurchaseAllowed, offerData.itemIds);
if(!((currentType === CatalogType.NORMAL) || ((offer.pricingModel !== Offer.PRICING_MODEL_BUNDLE) && (offer.pricingModel !== Offer.PRICING_MODEL_MULTI)))) return;