feat: enhance purchase intentions with chat integration and offer tracking
- Added MongoDB chat/message integration for seller responses - Improved seller response validation and default messaging - Integrated automatic chat creation/update when responding to intentions - Added highest custom offer fields to listing queries and models - Enhanced listing data with top offer information for buyers
This commit is contained in:
1 parent
d27526e026
commit
d8e7d5d7e6
19 files changed
+806
-58
No files matched your search
@@ -61,6 +61,8 @@ interface Listing {
|
||||
image_url?: string | null;
|
||||
item_category?: string | null;
|
||||
seller_character_name?: string | null;
|
||||
highest_custom_offer_amount?: number | string | null;
|
||||
highest_custom_offer_currency?: string | null;
|
||||
}
|
||||
|
||||
interface ListingDetailsModalProps {
|
||||
@@ -165,14 +167,14 @@ export function ListingDetailsModal({
|
||||
if (listing.price_tibia_coins) {
|
||||
const price = typeof listing.price_tibia_coins === "string" ? parseInt(listing.price_tibia_coins, 10) : listing.price_tibia_coins;
|
||||
if (!isNaN(price)) {
|
||||
prices.push({ type: "tc", label: "Tibia Coins", value: `${price.toLocaleString()} TC` });
|
||||
prices.push({ type: "tibia_coins", label: "Tibia Coins", value: `${price.toLocaleString()} TC` });
|
||||
}
|
||||
}
|
||||
|
||||
if (listing.price_gold_coins) {
|
||||
const price = typeof listing.price_gold_coins === "string" ? parseInt(listing.price_gold_coins, 10) : listing.price_gold_coins;
|
||||
if (!isNaN(price)) {
|
||||
prices.push({ type: "gp", label: "Gold Coins", value: `${price.toLocaleString()} GP` });
|
||||
prices.push({ type: "gold_coins", label: "Gold Coins", value: `${price.toLocaleString()} GP` });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +190,32 @@ export function ListingDetailsModal({
|
||||
};
|
||||
|
||||
const prices = getAvailablePrices();
|
||||
const highestOfferLabel = (() => {
|
||||
if (
|
||||
listing.highest_custom_offer_amount === null ||
|
||||
listing.highest_custom_offer_amount === undefined ||
|
||||
!listing.highest_custom_offer_currency
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const amount =
|
||||
typeof listing.highest_custom_offer_amount === "string"
|
||||
? Number(listing.highest_custom_offer_amount)
|
||||
: listing.highest_custom_offer_amount;
|
||||
if (Number.isNaN(amount)) {
|
||||
return null;
|
||||
}
|
||||
switch (listing.highest_custom_offer_currency) {
|
||||
case "pix":
|
||||
return `Maior oferta registrada: R$ ${amount.toFixed(2)}`;
|
||||
case "tibia_coins":
|
||||
return `Maior oferta registrada: ${Math.round(amount).toLocaleString()} TC`;
|
||||
case "gold_coins":
|
||||
return `Maior oferta registrada: ${Math.round(amount).toLocaleString()} GP`;
|
||||
default:
|
||||
return `Maior oferta registrada: ${amount}`;
|
||||
}
|
||||
})();
|
||||
// Apenas o dono pode realizar ações
|
||||
const canPause = isOwner && listing.listing_status === "active";
|
||||
const canActivate = isOwner && listing.listing_status === "cancelled";
|
||||
@@ -314,9 +342,9 @@ export function ListingDetailsModal({
|
||||
className={`p-3 rounded-lg border ${
|
||||
price.type === "pix"
|
||||
? "bg-green-500/10 border-green-500/20"
|
||||
: price.type === "tc"
|
||||
: price.type === "tibia_coins"
|
||||
? "bg-blue-500/10 border-blue-500/20"
|
||||
: price.type === "gp"
|
||||
: price.type === "gold_coins"
|
||||
? "bg-yellow-500/10 border-yellow-500/20"
|
||||
: "bg-purple-500/10 border-purple-500/20"
|
||||
}`}
|
||||
@@ -326,6 +354,11 @@ export function ListingDetailsModal({
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{highestOfferLabel && (
|
||||
<div className="rounded-lg border border-primary/30 bg-primary/5 px-3 py-2 text-sm font-medium text-primary">
|
||||
{highestOfferLabel}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Informações de leilão */}
|
||||
|
||||
Reference in new issue
Block a user