mirror of
https://github.com/clucraft/PriceGhost.git
synced 2026-05-12 01:02:54 +02:00
Add Swiss franc (CHF) and improve Euro currency support
- Add CHF to currency detection patterns in priceParser - Add getCurrencySymbol helper in notifications service - Update all frontend price formatting to support CHF - Swiss francs display as "CHF 29.99" format Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
c2cec6d4f1
commit
4928d6b9d3
5 changed files with 25 additions and 9 deletions
|
|
@ -1,5 +1,17 @@
|
|||
import axios from 'axios';
|
||||
|
||||
// Helper to get currency symbol for display
|
||||
function getCurrencySymbol(currency?: string): string {
|
||||
switch (currency) {
|
||||
case 'EUR': return '€';
|
||||
case 'GBP': return '£';
|
||||
case 'CHF': return 'CHF ';
|
||||
case 'JPY': return '¥';
|
||||
case 'INR': return '₹';
|
||||
default: return '$';
|
||||
}
|
||||
}
|
||||
|
||||
export interface NotificationPayload {
|
||||
productName: string;
|
||||
productUrl: string;
|
||||
|
|
@ -12,7 +24,7 @@ export interface NotificationPayload {
|
|||
}
|
||||
|
||||
function formatMessage(payload: NotificationPayload): string {
|
||||
const currencySymbol = payload.currency === 'EUR' ? '€' : payload.currency === 'GBP' ? '£' : '$';
|
||||
const currencySymbol = getCurrencySymbol(payload.currency);
|
||||
|
||||
if (payload.type === 'price_drop') {
|
||||
const oldPriceStr = payload.oldPrice ? `${currencySymbol}${payload.oldPrice.toFixed(2)}` : 'N/A';
|
||||
|
|
@ -78,7 +90,7 @@ export async function sendDiscordNotification(
|
|||
payload: NotificationPayload
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
const currencySymbol = payload.currency === 'EUR' ? '€' : payload.currency === 'GBP' ? '£' : '$';
|
||||
const currencySymbol = getCurrencySymbol(payload.currency);
|
||||
|
||||
let embed;
|
||||
if (payload.type === 'price_drop') {
|
||||
|
|
@ -145,7 +157,7 @@ export async function sendPushoverNotification(
|
|||
payload: NotificationPayload
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
const currencySymbol = payload.currency === 'EUR' ? '€' : payload.currency === 'GBP' ? '£' : '$';
|
||||
const currencySymbol = getCurrencySymbol(payload.currency);
|
||||
|
||||
let title: string;
|
||||
let message: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue