function mapCreateDealRequestToDealCreateData(payload, userId) { const { title, description, url, price, originalPrice, sellerName, customSeller, couponCode, location, discountType, discountValue, } = payload const normalizedCouponCode = couponCode === undefined || couponCode === null ? null : String(couponCode).trim() || null const hasUrl = Boolean(url) const saleType = !hasUrl ? "OFFLINE" : normalizedCouponCode ? "CODE" : "ONLINE" const hasPrice = price != null const normalizedDiscountType = hasPrice ? null : discountType ?? null const normalizedDiscountValue = hasPrice ? null : discountValue ?? null const normalizedSellerName = sellerName ?? customSeller ?? null return { title, description: description ?? null, url: url ?? null, price: price ?? null, originalPrice: originalPrice ?? null, couponCode: normalizedCouponCode, location: location ?? null, discountType: normalizedDiscountType, discountValue: normalizedDiscountValue, saletype: saleType, // Burada customSeller yazıyoruz; servis gerektiğinde ilişkilendiriyor. customSeller: normalizedSellerName, user: { connect: { id: userId }, }, } } module.exports = { mapCreateDealRequestToDealCreateData, }