mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-05-12 09:12:40 +02:00
fix: Always show price selection modal and use browser for JS-heavy sites
- Always show price selection modal when adding a product so users can verify - Use browser rendering for known JS-heavy sites (Best Buy, Target, Walmart, Costco) - Update modal text to say "Confirm Price" for single candidates Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
4fd04cd160
commit
cf23ac9db1
4 changed files with 67 additions and 31 deletions
|
|
@ -89,24 +89,40 @@ router.post('/', async (req: AuthRequest, res: Response) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// If needsReview is true and there are multiple candidates, return them for user selection
|
||||
if (scrapedData.needsReview && scrapedData.priceCandidates.length > 1) {
|
||||
res.status(200).json({
|
||||
needsReview: true,
|
||||
name: scrapedData.name,
|
||||
imageUrl: scrapedData.imageUrl,
|
||||
stockStatus: scrapedData.stockStatus,
|
||||
priceCandidates: scrapedData.priceCandidates.map(c => ({
|
||||
price: c.price,
|
||||
currency: c.currency,
|
||||
method: c.method,
|
||||
context: c.context,
|
||||
confidence: c.confidence,
|
||||
})),
|
||||
suggestedPrice: scrapedData.price,
|
||||
url,
|
||||
});
|
||||
return;
|
||||
// Always show price selection modal when adding a product so user can verify
|
||||
// Show if we have at least one candidate with a price
|
||||
if (scrapedData.priceCandidates.length > 0 || scrapedData.price) {
|
||||
// Make sure we have at least one candidate to show
|
||||
const candidates = scrapedData.priceCandidates.length > 0
|
||||
? scrapedData.priceCandidates
|
||||
: scrapedData.price
|
||||
? [{
|
||||
price: scrapedData.price.price,
|
||||
currency: scrapedData.price.currency,
|
||||
method: scrapedData.selectedMethod || 'ai' as const,
|
||||
context: 'Extracted price',
|
||||
confidence: 0.8
|
||||
}]
|
||||
: [];
|
||||
|
||||
if (candidates.length > 0) {
|
||||
res.status(200).json({
|
||||
needsReview: true,
|
||||
name: scrapedData.name,
|
||||
imageUrl: scrapedData.imageUrl,
|
||||
stockStatus: scrapedData.stockStatus,
|
||||
priceCandidates: candidates.map(c => ({
|
||||
price: c.price,
|
||||
currency: c.currency,
|
||||
method: c.method,
|
||||
context: c.context,
|
||||
confidence: c.confidence,
|
||||
})),
|
||||
suggestedPrice: scrapedData.price,
|
||||
url,
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Create product with stock status
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue