Skip to content

Commit

Permalink
feat(addon-commerce): add currencies (#4910)
Browse files Browse the repository at this point in the history
  • Loading branch information
LordOfTheMoon228 authored Jul 13, 2023
1 parent a268064 commit 405314e
Show file tree
Hide file tree
Showing 5 changed files with 409 additions and 0 deletions.
151 changes: 151 additions & 0 deletions projects/addon-commerce/enums/currency-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,155 @@ export enum TuiCurrencyCode {
* @description Currency symbol: Dh
*/
Dirham = `784`,

/**
* Tajikistani somoni
*
* @description Numeric code: 972
* @description Alphabetic code: TJS
* @description Countries and territories: Tajikistan
* @description Currency symbol: SM
*/
TajikistaniSomoni = `972`,

/**
* Malaysian ringgit
*
* @description Numeric code: 458
* @description Alphabetic code: MYR
* @description Countries and territories: Malaysia
* @description Currency symbol: RM
*/

MalaysianRinggit = `458`,
/**
*
* Belarusian ruble
*
* @description Numeric code: 933
* @description Alphabetic code: BYN
* @description Countries and territories: Belarus
* @description Currency symbol: Rbl
*/

BelarusianRuble = `933`,
/**
* Georgian lari
*
* @description Numeric code: 981
* @description Alphabetic code: GEL
* @description Countries and territories: Georgia
* @description Currency symbol: ₾
*/

GeorgianLari = `981`,
/**
* Azerbaijani manat
*
* @description Numeric code: 944
* @description Alphabetic code: AZN
* @description Countries and territories: Azerbaijan
* @description Currency symbol: ₼
*/

AzerbaijaniManat = `944`,
/**
* Sri Lankan rupee
*
* @description Numeric code: 144
* @description Alphabetic code: LKR
* @description Countries and territories: Sri Lanka
* @description Currency symbol: Rs.
*/

SriLankanRupee = `144`,
/**
* Serbian dinar
*
* @description Numeric code: 941
* @description Alphabetic code: RSD
* @description Countries and territories: Serbia
* @description Currency symbol: DIN
*/

SerbianDinar = `941`,
/**
* Saudi Riyal
*
* @description Numeric code: 682
* @description Alphabetic code: SAR
* @description Countries and territories: Saudi Arabia
* @description Currency symbol: SR
*/

SaudiRiyal = `682`,
/**
* Mongolian tugrik
*
* @description Numeric code: 496
* @description Alphabetic code: MNT
* @description Countries and territories: Mongolia
* @description Currency symbol: ₮
*/

MongolianTugrik = `496`,
/**
* South African rand
*
* @description Numeric code: 710
* @description Alphabetic code: ZAR
* @description Countries and territories: South Africa
* @description Currency symbol: R
*/

SouthAfricanRand = `710`,
/**
* Iranian rial
*
* @description Numeric code: 364
* @description Alphabetic code: IRR
* @description Countries and territories: Iran
* @description Currency symbol: IR
*/

IranianRial = `364`,
/**
* Indonesian rupiah
*
* @description Numeric code: 360
* @description Alphabetic code: IDR
* @description Countries and territories: Indonesia
* @description Currency symbol: Rp
*/

IndonesianRupiah = `360`,
/**
* Vietnamese dong
*
* @description Numeric code: 704
* @description Alphabetic code: VND
* @description Countries and territories: Vietnam
* @description Currency symbol: đ
*/

VietnameseDong = `704`,
/**
* New Turkmen manat
*
* @description Numeric code: 934
* @description Alphabetic code: TMT
* @description Countries and territories: Turkmenistan
* @description Currency symbol: TMT
*/

NewTurkmenManat = `934`,
/**
* Brazilian Real
*
* @description Numeric code: 986
* @description Alphabetic code: BRL
* @description Countries and territories: Brazilia
* @description Currency symbol: R$
*/
BrazilianReal = `986`,
}
151 changes: 151 additions & 0 deletions projects/addon-commerce/enums/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,4 +239,155 @@ export enum TuiCurrency {
* @description Currency symbol: Dh
*/
Dirham = `AED`,

/**
* Tajikistani somoni
*
* @description Numeric code: 972
* @description Alphabetic code: TJS
* @description Countries and territories: Tajikistan
* @description Currency symbol: SM
*/
TajikistaniSomoni = `TJS`,

/**
* Malaysian ringgit
*
* @description Numeric code: 458
* @description Alphabetic code: MYR
* @description Countries and territories: Malaysia
* @description Currency symbol: RM
*/

MalaysianRinggit = `MYR`,
/**
*
* Belarusian ruble
*
* @description Numeric code: 933
* @description Alphabetic code: BYN
* @description Countries and territories: Belarus
* @description Currency symbol: Rbl
*/

BelarusianRuble = `BYN`,
/**
* Georgian lari
*
* @description Numeric code: 981
* @description Alphabetic code: GEL
* @description Countries and territories: Georgia
* @description Currency symbol: ₾
*/

GeorgianLari = `GEL`,
/**
* Azerbaijani manat
*
* @description Numeric code: 944
* @description Alphabetic code: AZN
* @description Countries and territories: Azerbaijan
* @description Currency symbol: ₼
*/

AzerbaijaniManat = `AZN`,
/**
* Sri Lankan rupee
*
* @description Numeric code: 144
* @description Alphabetic code: LKR
* @description Countries and territories: Sri Lanka
* @description Currency symbol: Rs.
*/

SriLankanRupee = `LKR`,
/**
* Serbian dinar
*
* @description Numeric code: 941
* @description Alphabetic code: RSD
* @description Countries and territories: Serbia
* @description Currency symbol: DIN
*/

SerbianDinar = `RSD`,
/**
* Saudi Riyal
*
* @description Numeric code: 682
* @description Alphabetic code: SAR
* @description Countries and territories: Saudi Arabia
* @description Currency symbol: SR
*/

SaudiRiyal = `SAR`,
/**
* Mongolian tugrik
*
* @description Numeric code: 496
* @description Alphabetic code: MNT
* @description Countries and territories: Mongolia
* @description Currency symbol: ₮
*/

MongolianTugrik = `MNT`,
/**
* South African rand
*
* @description Numeric code: 710
* @description Alphabetic code: ZAR
* @description Countries and territories: South Africa
* @description Currency symbol: R
*/

SouthAfricanRand = `ZAR`,
/**
* Iranian rial
*
* @description Numeric code: 364
* @description Alphabetic code: IRR
* @description Countries and territories: Iran
* @description Currency symbol: IR
*/

IranianRial = `IRR`,
/**
* Indonesian rupiah
*
* @description Numeric code: 360
* @description Alphabetic code: IDR
* @description Countries and territories: Indonesia
* @description Currency symbol: Rp
*/

IndonesianRupiah = `IDR`,
/**
* Vietnamese dong
*
* @description Numeric code: 704
* @description Alphabetic code: VND
* @description Countries and territories: Vietnam
* @description Currency symbol: đ
*/

VietnameseDong = `VND`,
/**
* New Turkmen manat
*
* @description Numeric code: 934
* @description Alphabetic code: TMT
* @description Countries and territories: Turkmenistan
* @description Currency symbol: TMT
*/

NewTurkmenManat = `TMT`,
/**
* Brazilian Real
*
* @description Numeric code: 986
* @description Alphabetic code: BRL
* @description Countries and territories: Brazilia
* @description Currency symbol: R$
*/
BrazilianReal = `BRL`,
}
47 changes: 47 additions & 0 deletions projects/addon-commerce/utils/get-code-by-currency.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// cspell:disable
import {TuiCurrency, TuiCurrencyCode} from '@taiga-ui/addon-commerce';

export const TUI_CODE_DICTIONARY: Record<TuiCurrency, TuiCurrencyCode> = {
[TuiCurrency.Ruble]: TuiCurrencyCode.Ruble,
[TuiCurrency.Dollar]: TuiCurrencyCode.Dollar,
[TuiCurrency.MexicanPeso]: TuiCurrencyCode.MexicanPeso,
[TuiCurrency.SingaporeDollar]: TuiCurrencyCode.SingaporeDollar,
[TuiCurrency.AustralianDollar]: TuiCurrencyCode.AustralianDollar,
[TuiCurrency.HongKongDollar]: TuiCurrencyCode.HongKongDollar,
[TuiCurrency.CanadianDollar]: TuiCurrencyCode.CanadianDollar,
[TuiCurrency.Euro]: TuiCurrencyCode.Euro,
[TuiCurrency.Pound]: TuiCurrencyCode.Pound,
[TuiCurrency.Baht]: TuiCurrencyCode.Baht,
[TuiCurrency.TurkishLira]: TuiCurrencyCode.TurkishLira,
[TuiCurrency.YuanRenminbi]: TuiCurrencyCode.YuanRenminbi,
[TuiCurrency.Yen]: TuiCurrencyCode.Yen,
[TuiCurrency.IsraeliShekel]: TuiCurrencyCode.IsraeliShekel,
[TuiCurrency.IndianRupee]: TuiCurrencyCode.IndianRupee,
[TuiCurrency.SwissFranc]: TuiCurrencyCode.SwissFranc,
[TuiCurrency.ArmenianDram]: TuiCurrencyCode.ArmenianDram,
[TuiCurrency.Won]: TuiCurrencyCode.Won,
[TuiCurrency.Tenge]: TuiCurrencyCode.Tenge,
[TuiCurrency.Hryvnia]: TuiCurrencyCode.Hryvnia,
[TuiCurrency.UzbekSum]: TuiCurrencyCode.UzbekSum,
[TuiCurrency.KyrgyzstanSom]: TuiCurrencyCode.KyrgyzstanSom,
[TuiCurrency.Dirham]: TuiCurrencyCode.Dirham,
[TuiCurrency.TajikistaniSomoni]: TuiCurrencyCode.TajikistaniSomoni,
[TuiCurrency.MalaysianRinggit]: TuiCurrencyCode.MalaysianRinggit,
[TuiCurrency.BelarusianRuble]: TuiCurrencyCode.BelarusianRuble,
[TuiCurrency.GeorgianLari]: TuiCurrencyCode.GeorgianLari,
[TuiCurrency.AzerbaijaniManat]: TuiCurrencyCode.AzerbaijaniManat,
[TuiCurrency.SriLankanRupee]: TuiCurrencyCode.SriLankanRupee,
[TuiCurrency.SerbianDinar]: TuiCurrencyCode.SerbianDinar,
[TuiCurrency.SaudiRiyal]: TuiCurrencyCode.SaudiRiyal,
[TuiCurrency.MongolianTugrik]: TuiCurrencyCode.MongolianTugrik,
[TuiCurrency.SouthAfricanRand]: TuiCurrencyCode.SouthAfricanRand,
[TuiCurrency.IranianRial]: TuiCurrencyCode.IranianRial,
[TuiCurrency.IndonesianRupiah]: TuiCurrencyCode.IndonesianRupiah,
[TuiCurrency.VietnameseDong]: TuiCurrencyCode.VietnameseDong,
[TuiCurrency.NewTurkmenManat]: TuiCurrencyCode.NewTurkmenManat,
[TuiCurrency.BrazilianReal]: TuiCurrencyCode.BrazilianReal,
};

export function tuiGetCodeByCurrency(code: TuiCurrency): TuiCurrencyCode | null {
return TUI_CODE_DICTIONARY[code] ?? null;
}
15 changes: 15 additions & 0 deletions projects/addon-commerce/utils/get-currency-by-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ export const TUI_CURRENCY_DICTIONARY: Record<TuiCurrencyCode, TuiCurrency> = {
[TuiCurrencyCode.UzbekSum]: TuiCurrency.UzbekSum,
[TuiCurrencyCode.KyrgyzstanSom]: TuiCurrency.KyrgyzstanSom,
[TuiCurrencyCode.Dirham]: TuiCurrency.Dirham,
[TuiCurrencyCode.TajikistaniSomoni]: TuiCurrency.TajikistaniSomoni,
[TuiCurrencyCode.MalaysianRinggit]: TuiCurrency.MalaysianRinggit,
[TuiCurrencyCode.BelarusianRuble]: TuiCurrency.BelarusianRuble,
[TuiCurrencyCode.GeorgianLari]: TuiCurrency.GeorgianLari,
[TuiCurrencyCode.AzerbaijaniManat]: TuiCurrency.AzerbaijaniManat,
[TuiCurrencyCode.SriLankanRupee]: TuiCurrency.SriLankanRupee,
[TuiCurrencyCode.SerbianDinar]: TuiCurrency.SerbianDinar,
[TuiCurrencyCode.SaudiRiyal]: TuiCurrency.SaudiRiyal,
[TuiCurrencyCode.MongolianTugrik]: TuiCurrency.MongolianTugrik,
[TuiCurrencyCode.SouthAfricanRand]: TuiCurrency.SouthAfricanRand,
[TuiCurrencyCode.IranianRial]: TuiCurrency.IranianRial,
[TuiCurrencyCode.IndonesianRupiah]: TuiCurrency.IndonesianRupiah,
[TuiCurrencyCode.VietnameseDong]: TuiCurrency.VietnameseDong,
[TuiCurrencyCode.NewTurkmenManat]: TuiCurrency.NewTurkmenManat,
[TuiCurrencyCode.BrazilianReal]: TuiCurrency.BrazilianReal,
};

export function tuiGetCurrencyByCode(currency: TuiCurrencyCode): TuiCurrency | null {
Expand Down
Loading

0 comments on commit 405314e

Please sign in to comment.