[offers][feat] Allowing showing income based on selected salary

pull/408/head
Bryann Yeap Kok Keong 2 years ago
parent 587e80b1bf
commit d200793d20

@ -15,6 +15,7 @@ import { trpc } from '~/utils/trpc';
import OffersRow from './OffersRow'; import OffersRow from './OffersRow';
import type { DashboardOffer, GetOffersResponse, Paging } from '~/types/offers'; import type { DashboardOffer, GetOffersResponse, Paging } from '~/types/offers';
import { Currency } from '~/utils/offers/currency/CurrencyEnum';
const NUMBER_OF_OFFERS_IN_PAGE = 10; const NUMBER_OF_OFFERS_IN_PAGE = 10;
export type OffersTableProps = Readonly<{ export type OffersTableProps = Readonly<{
@ -25,7 +26,7 @@ export default function OffersTable({
companyFilter, companyFilter,
jobTitleFilter, jobTitleFilter,
}: OffersTableProps) { }: OffersTableProps) {
const [currency, setCurrency] = useState('SGD'); // TODO: Detect location const [currency, setCurrency] = useState(Currency.SGD.toString()); // TODO: Detect location
const [selectedTab, setSelectedTab] = useState(YOE_CATEGORY.ENTRY); const [selectedTab, setSelectedTab] = useState(YOE_CATEGORY.ENTRY);
const [pagination, setPagination] = useState<Paging>({ const [pagination, setPagination] = useState<Paging>({
currentPage: 0, currentPage: 0,
@ -44,12 +45,13 @@ export default function OffersTable({
numOfPages: 0, numOfPages: 0,
totalItems: 0, totalItems: 0,
}); });
}, [selectedTab]); }, [selectedTab, currency]);
const offersQuery = trpc.useQuery( const offersQuery = trpc.useQuery(
[ [
'offers.list', 'offers.list',
{ {
companyId: companyFilter, companyId: companyFilter,
currency,
limit: NUMBER_OF_OFFERS_IN_PAGE, limit: NUMBER_OF_OFFERS_IN_PAGE,
location: 'Singapore, Singapore', // TODO: Geolocation location: 'Singapore, Singapore', // TODO: Geolocation
offset: pagination.currentPage, offset: pagination.currentPage,

@ -6,11 +6,12 @@ function Test() {
const data = trpc.useQuery([ const data = trpc.useQuery([
'offers.list', 'offers.list',
{ {
currency: "aed",
limit: 100, limit: 100,
location: 'Singapore, Singapore', location: 'Singapore, Singapore',
offset: 0, offset: 0,
sortBy: '+totalCompensation', sortBy: '+totalCompensation',
yoeCategory: 1, yoeCategory: 2,
}, },
]); ]);

@ -26,26 +26,27 @@ export const offersCommentsRouter = createRouter()
user: true, user: true,
}, },
orderBy: { orderBy: {
createdAt: 'desc' createdAt: 'desc',
} },
}, },
replyingTo: true, replyingTo: true,
user: true, user: true,
}, },
orderBy: { orderBy: {
createdAt: 'desc' createdAt: 'desc',
} },
}, },
}, },
where: { where: {
id: input.profileId, id: input.profileId,
} },
}); });
const discussions: OffersDiscussion = { const discussions: OffersDiscussion = {
data: result?.discussion data:
result?.discussion
.filter((x) => { .filter((x) => {
return x.replyingToId === null return x.replyingToId === null;
}) })
.map((x) => { .map((x) => {
if (x.user == null) { if (x.user == null) {
@ -81,18 +82,18 @@ export const offersCommentsRouter = createRouter()
message: reply.message, message: reply.message,
replies: [], replies: [],
replyingToId: reply.replyingToId, replyingToId: reply.replyingToId,
user: reply.user user: reply.user,
} };
}), }),
replyingToId: x.replyingToId, replyingToId: x.replyingToId,
user: x.user user: x.user,
} };
return replyType return replyType;
}) ?? [] }) ?? [],
} };
return discussions return discussions;
}, },
}) })
.mutation('create', { .mutation('create', {
@ -101,7 +102,7 @@ export const offersCommentsRouter = createRouter()
profileId: z.string(), profileId: z.string(),
replyingToId: z.string().optional(), replyingToId: z.string().optional(),
token: z.string().optional(), token: z.string().optional(),
userId: z.string().optional() userId: z.string().optional(),
}), }),
async resolve({ ctx, input }) { async resolve({ ctx, input }) {
const profile = await ctx.prisma.offersProfile.findFirst({ const profile = await ctx.prisma.offersProfile.findFirst({
@ -156,7 +157,7 @@ export const offersCommentsRouter = createRouter()
const created = await ctx.prisma.offersReply.findFirst({ const created = await ctx.prisma.offersReply.findFirst({
include: { include: {
user: true user: true,
}, },
where: { where: {
id: createdReply.id, id: createdReply.id,
@ -175,10 +176,10 @@ export const offersCommentsRouter = createRouter()
id: '', id: '',
image: '', image: '',
name: profile?.profileName ?? '<missing name>', name: profile?.profileName ?? '<missing name>',
} },
} };
return result return result;
} }
throw new trpc.TRPCError({ throw new trpc.TRPCError({
@ -223,10 +224,10 @@ export const offersCommentsRouter = createRouter()
include: { include: {
replies: { replies: {
include: { include: {
user: true user: true,
} },
}, },
user: true user: true,
}, },
where: { where: {
id: input.id, id: input.id,
@ -250,8 +251,8 @@ export const offersCommentsRouter = createRouter()
id: '', id: '',
image: '', image: '',
name: profile?.profileName ?? '<missing name>', name: profile?.profileName ?? '<missing name>',
} },
} };
}), }),
replyingToId: updated!.replyingToId, replyingToId: updated!.replyingToId,
user: updated!.user ?? { user: updated!.user ?? {
@ -260,10 +261,10 @@ export const offersCommentsRouter = createRouter()
id: '', id: '',
image: '', image: '',
name: profile?.profileName ?? '<missing name>', name: profile?.profileName ?? '<missing name>',
} },
} };
return result return result;
} }
throw new trpc.TRPCError({ throw new trpc.TRPCError({

@ -1,12 +1,9 @@
import { z } from 'zod'; import { TRPCError } from "@trpc/server";
import { TRPCError } from '@trpc/server'; import { z } from "zod";
import { dashboardOfferDtoMapper, getOffersResponseMapper } from "~/mappers/offers-mappers";
import { import { convert } from "~/utils/offers/currency/currency-exchange";
dashboardOfferDtoMapper, import { Currency } from "~/utils/offers/currency/CurrencyEnum";
getOffersResponseMapper, import { createRouter } from "../context";
} from '~/mappers/offers-mappers';
import { createRouter } from '../context';
const yoeCategoryMap: Record<number, string> = { const yoeCategoryMap: Record<number, string> = {
0: 'Internship', 0: 'Internship',
@ -38,6 +35,7 @@ const createSortByValidationRegex = () => {
export const offersRouter = createRouter().query('list', { export const offersRouter = createRouter().query('list', {
input: z.object({ input: z.object({
companyId: z.string().nullish(), companyId: z.string().nullish(),
currency: z.string().nullish(),
dateEnd: z.date().nullish(), dateEnd: z.date().nullish(),
dateStart: z.date().nullish(), dateStart: z.date().nullish(),
limit: z.number().positive(), limit: z.number().positive(),
@ -80,6 +78,9 @@ export const offersRouter = createRouter().query('list', {
}, },
}, },
}, },
orderBy: {
monthYearReceived: 'desc',
},
where: { where: {
AND: [ AND: [
{ {
@ -121,6 +122,9 @@ export const offersRouter = createRouter().query('list', {
}, },
}, },
}, },
orderBy: {
monthYearReceived: 'desc',
},
where: { where: {
AND: [ AND: [
{ {
@ -150,6 +154,36 @@ export const offersRouter = createRouter().query('list', {
}, },
}); });
// CONVERTING
const currency = input.currency?.toUpperCase()
if (currency != null && currency in Currency) {
data = await Promise.all(
data.map(async (offer) => {
if (offer.offersFullTime?.totalCompensation) {
offer.offersFullTime.totalCompensation.value = await convert(offer.offersFullTime.totalCompensation.value, offer.offersFullTime.totalCompensation.currency, currency);
offer.offersFullTime.totalCompensation.currency = currency;
offer.offersFullTime.baseSalary.value = await convert(offer.offersFullTime.totalCompensation.value, offer.offersFullTime.totalCompensation.currency, currency);
offer.offersFullTime.baseSalary.currency = currency;
offer.offersFullTime.stocks.value = await convert(offer.offersFullTime.totalCompensation.value, offer.offersFullTime.totalCompensation.currency, currency);
offer.offersFullTime.stocks.currency = currency;
offer.offersFullTime.bonus.value = await convert(offer.offersFullTime.totalCompensation.value, offer.offersFullTime.totalCompensation.currency, currency);
offer.offersFullTime.bonus.currency = currency;
} else if (offer.offersIntern?.monthlySalary) {
offer.offersIntern.monthlySalary.value = await convert(offer.offersIntern.monthlySalary.value, offer.offersIntern.monthlySalary.currency, currency);
offer.offersIntern.monthlySalary.currency = currency;
} else {
throw new TRPCError({
code: 'NOT_FOUND',
message: 'Total Compensation or Salary not found',
});
}
return offer;
}),
);
}
// FILTERING // FILTERING
data = data.filter((offer) => { data = data.filter((offer) => {
let validRecord = true; let validRecord = true;

@ -1,167 +1,170 @@
// eslint-disable-next-line no-shadow // eslint-disable-next-line no-shadow
export enum Currency { export enum Currency {
AED = 'AED', // United Arab Emirates Dirham AED = "AED", // 'UNITED ARAB EMIRATES DIRHAM'
AFN = 'AFN', // Afghanistan Afghani AFN = "AFN", // 'AFGHAN AFGHANI'
ALL = 'ALL', // Albania Lek ALL = "ALL", // 'ALBANIAN LEK'
AMD = 'AMD', // Armenia Dram AMD = "AMD", // 'ARMENIAN DRAM'
ANG = 'ANG', // Netherlands Antilles Guilder ANG = "ANG", // 'NETHERLANDS ANTILLEAN GUILDER'
AOA = 'AOA', // Angola Kwanza AOA = "AOA", // 'ANGOLAN KWANZA'
ARS = 'ARS', // Argentina Peso ARS = "ARS", // 'ARGENTINE PESO'
AUD = 'AUD', // Australia Dollar AUD = "AUD", // 'AUSTRALIAN DOLLAR'
AWG = 'AWG', // Aruba Guilder AWG = "AWG", // 'ARUBAN FLORIN'
AZN = 'AZN', // Azerbaijan New Manat AZN = "AZN", // 'AZERBAIJANI MANAT'
BAM = 'BAM', // Bosnia and Herzegovina Convertible Marka BAM = "BAM", // 'BOSNIA-HERZEGOVINA CONVERTIBLE MARK'
BBD = 'BBD', // Barbados Dollar BBD = "BBD", // 'BAJAN DOLLAR'
BDT = 'BDT', // Bangladesh Taka BDT = "BDT", // 'BANGLADESHI TAKA'
BGN = 'BGN', // Bulgaria Lev BGN = "BGN", // 'BULGARIAN LEV'
BHD = 'BHD', // Bahrain Dinar BHD = "BHD", // 'BAHRAINI DINAR'
BIF = 'BIF', // Burundi Franc BIF = "BIF", // 'BURUNDIAN FRANC'
BMD = 'BMD', // Bermuda Dollar BMD = "BMD", // 'BERMUDAN DOLLAR'
BND = 'BND', // Brunei Darussalam Dollar BND = "BND", // 'BRUNEI DOLLAR'
BOB = 'BOB', // Bolivia Bolíviano BOB = "BOB", // 'BOLIVIAN BOLIVIANO'
BRL = 'BRL', // Brazil Real BRL = "BRL", // 'BRAZILIAN REAL'
BSD = 'BSD', // Bahamas Dollar BSD = "BSD", // 'BAHAMIAN DOLLAR'
BTN = 'BTN', // Bhutan Ngultrum BTN = "BTN", // 'BHUTAN CURRENCY'
BWP = 'BWP', // Botswana Pula BWP = "BWP", // 'BOTSWANAN PULA'
BYR = 'BYR', // Belarus Ruble BYN = "BYN", // 'NEW BELARUSIAN RUBLE'
BZD = 'BZD', // Belize Dollar BYR = "BYR", // 'BELARUSIAN RUBLE'
CAD = 'CAD', // Canada Dollar BZD = "BZD", // 'BELIZE DOLLAR'
CDF = 'CDF', // Congo/Kinshasa Franc CAD = "CAD", // 'CANADIAN DOLLAR'
CHF = 'CHF', // Switzerland Franc CDF = "CDF", // 'CONGOLESE FRANC'
CLP = 'CLP', // Chile Peso CHF = "CHF", // 'SWISS FRANC'
CNY = 'CNY', // China Yuan Renminbi CLF = "CLF", // 'CHILEAN UNIT OF ACCOUNT (UF)'
COP = 'COP', // Colombia Peso CLP = "CLP", // 'CHILEAN PESO'
CRC = 'CRC', // Costa Rica Colon CNY = "CNY", // 'CHINESE YUAN'
CUC = 'CUC', // Cuba Convertible Peso COP = "COP", // 'COLOMBIAN PESO'
CUP = 'CUP', // Cuba Peso CRC = "CRC", // 'COSTA RICAN COLÓN'
CVE = 'CVE', // Cape Verde Escudo CUC = "CUC", // 'CUBAN CONVERTIBLE PESO'
CZK = 'CZK', // Czech Republic Koruna CUP = "CUP", // 'CUBAN PESO'
DJF = 'DJF', // Djibouti Franc CVE = "CVE", // 'CAPE VERDEAN ESCUDO'
DKK = 'DKK', // Denmark Krone CVX = "CVX", // 'CONVEX FINANCE'
DOP = 'DOP', // Dominican Republic Peso CZK = "CZK", // 'CZECH KORUNA'
DZD = 'DZD', // Algeria Dinar DJF = "DJF", // 'DJIBOUTIAN FRANC'
EGP = 'EGP', // Egypt Pound DKK = "DKK", // 'DANISH KRONE'
ERN = 'ERN', // Eritrea Nakfa DOP = "DOP", // 'DOMINICAN PESO'
ETB = 'ETB', // Ethiopia Birr DZD = "DZD", // 'ALGERIAN DINAR'
EUR = 'EUR', // Euro Member Countries EGP = "EGP", // 'EGYPTIAN POUND'
FJD = 'FJD', // Fiji Dollar ERN = "ERN", // 'ERITREAN NAKFA'
FKP = 'FKP', // Falkland Islands (Malvinas) Pound ETB = "ETB", // 'ETHIOPIAN BIRR'
GBP = 'GBP', // United Kingdom Pound ETC = "ETC", // 'ETHEREUM CLASSIC'
GEL = 'GEL', // Georgia Lari EUR = "EUR", // 'EURO'
GGP = 'GGP', // Guernsey Pound FEI = "FEI", // 'FEI USD'
GHS = 'GHS', // Ghana Cedi FJD = "FJD", // 'FIJIAN DOLLAR'
GIP = 'GIP', // Gibraltar Pound FKP = "FKP", // 'FALKLAND ISLANDS POUND'
GMD = 'GMD', // Gambia Dalasi GBP = "GBP", // 'POUND STERLING'
GNF = 'GNF', // Guinea Franc GEL = "GEL", // 'GEORGIAN LARI'
GTQ = 'GTQ', // Guatemala Quetzal GHS = "GHS", // 'GHANAIAN CEDI'
GYD = 'GYD', // Guyana Dollar GIP = "GIP", // 'GIBRALTAR POUND'
HKD = 'HKD', // Hong Kong Dollar GMD = "GMD", // 'GAMBIAN DALASI'
HNL = 'HNL', // Honduras Lempira GNF = "GNF", // 'GUINEAN FRANC'
HRK = 'HRK', // Croatia Kuna GTQ = "GTQ", // 'GUATEMALAN QUETZAL'
HTG = 'HTG', // Haiti Gourde GYD = "GYD", // 'GUYANAESE DOLLAR'
HUF = 'HUF', // Hungary Forint HKD = "HKD", // 'HONG KONG DOLLAR'
IDR = 'IDR', // Indonesia Rupiah HNL = "HNL", // 'HONDURAN LEMPIRA'
ILS = 'ILS', // Israel Shekel HRK = "HRK", // 'CROATIAN KUNA'
IMP = 'IMP', // Isle of Man Pound HTG = "HTG", // 'HAITIAN GOURDE'
INR = 'INR', // India Rupee HUF = "HUF", // 'HUNGARIAN FORINT'
IQD = 'IQD', // Iraq Dinar ICP = "ICP", // 'INTERNET COMPUTER'
IRR = 'IRR', // Iran Rial IDR = "IDR", // 'INDONESIAN RUPIAH'
ISK = 'ISK', // Iceland Krona ILS = "ILS", // 'ISRAELI NEW SHEKEL'
JEP = 'JEP', // Jersey Pound INR = "INR", // 'INDIAN RUPEE'
JMD = 'JMD', // Jamaica Dollar IQD = "IQD", // 'IRAQI DINAR'
JOD = 'JOD', // Jordan Dinar IRR = "IRR", // 'IRANIAN RIAL'
JPY = 'JPY', // Japan Yen ISK = "ISK", // 'ICELANDIC KRÓNA'
KES = 'KES', // Kenya Shilling JEP = "JEP", // 'JERSEY POUND'
KGS = 'KGS', // Kyrgyzstan Som JMD = "JMD", // 'JAMAICAN DOLLAR'
KHR = 'KHR', // Cambodia Riel JOD = "JOD", // 'JORDANIAN DINAR'
KMF = 'KMF', // Comoros Franc JPY = "JPY", // 'JAPANESE YEN'
KPW = 'KPW', // Korea (North) Won KES = "KES", // 'KENYAN SHILLING'
KRW = 'KRW', // Korea (South) Won KGS = "KGS", // 'KYRGYSTANI SOM'
KWD = 'KWD', // Kuwait Dinar KHR = "KHR", // 'CAMBODIAN RIEL'
KYD = 'KYD', // Cayman Islands Dollar KMF = "KMF", // 'COMORIAN FRANC'
KZT = 'KZT', // Kazakhstan Tenge KPW = "KPW", // 'NORTH KOREAN WON'
LAK = 'LAK', // Laos Kip KRW = "KRW", // 'SOUTH KOREAN WON'
LBP = 'LBP', // Lebanon Pound KWD = "KWD", // 'KUWAITI DINAR'
LKR = 'LKR', // Sri Lanka Rupee KYD = "KYD", // 'CAYMAN ISLANDS DOLLAR'
LRD = 'LRD', // Liberia Dollar KZT = "KZT", // 'KAZAKHSTANI TENGE'
LSL = 'LSL', // Lesotho Loti LAK = "LAK", // 'LAOTIAN KIP'
LYD = 'LYD', // Libya Dinar LBP = "LPB", // 'LEBANESE POUND'
MAD = 'MAD', // Morocco Dirham LKR = "LKR", // 'SRI LANKAN RUPEE'
MDL = 'MDL', // Moldova Leu LRD = "LRD", // 'LIBERIAN DOLLAR'
MGA = 'MGA', // Madagascar Ariary LSL = "LSL", // 'LESOTHO LOTI'
MKD = 'MKD', // Macedonia Denar LTL = "LTL", // 'LITHUANIAN LITAS'
MMK = 'MMK', // Myanmar (Burma) Kyat LVL = "LVL", // 'LATVIAN LATS'
MNT = 'MNT', // Mongolia Tughrik LYD = "LYD", // 'LIBYAN DINAR'
MOP = 'MOP', // Macau Pataca MAD = "MAD", // 'MOROCCAN DIRHAM'
MRO = 'MRO', // Mauritania Ouguiya MDL = "MDL", // 'MOLDOVAN LEU'
MUR = 'MUR', // Mauritius Rupee MGA = "MGA", // 'MALAGASY ARIARY'
MVR = 'MVR', // Maldives (Maldive Islands) Rufiyaa MKD = "MKD", // 'MACEDONIAN DENAR'
MWK = 'MWK', // Malawi Kwacha MMK = "MMK", // 'MYANMAR KYAT'
MXN = 'MXN', // Mexico Peso MNT = "MNT", // 'MONGOLIAN TUGRIK'
MYR = 'MYR', // Malaysia Ringgit MOP = "MOP", // 'MACANESE PATACA'
MZN = 'MZN', // Mozambique Metical MRO = "MRO", // 'MAURITANIAN OUGUIYA'
NAD = 'NAD', // Namibia Dollar MUR = "MUR", // 'MAURITIAN RUPEE'
NGN = 'NGN', // Nigeria Naira MVR = "MVR", // 'MALDIVIAN RUFIYAA'
NIO = 'NIO', // Nicaragua Cordoba MWK = "MWK", // 'MALAWIAN KWACHA'
NOK = 'NOK', // Norway Krone MXN = "MXN", // 'MEXICAN PESO'
NPR = 'NPR', // Nepal Rupee MYR = "MYR", // 'MALAYSIAN RINGGIT'
NZD = 'NZD', // New Zealand Dollar MZN = "MZN", // 'MOZAMBICAN METICAL'
OMR = 'OMR', // Oman Rial NAD = "NAD", // 'NAMIBIAN DOLLAR'
PAB = 'PAB', // Panama Balboa NGN = "NGN", // 'NIGERIAN NAIRA'
PEN = 'PEN', // Peru Sol NIO = "NIO", // 'NICARAGUAN CÓRDOBA'
PGK = 'PGK', // Papua New Guinea Kina NOK = "NOK", // 'NORWEGIAN KRONE'
PHP = 'PHP', // Philippines Peso NPR = "NPR", // 'NEPALESE RUPEE'
PKR = 'PKR', // Pakistan Rupee NZD = "NZD", // 'NEW ZEALAND DOLLAR'
PLN = 'PLN', // Poland Zloty OMR = "OMR", // 'OMANI RIAL'
PYG = 'PYG', // Paraguay Guarani ONE = "ONE", // 'MENLO ONE'
QAR = 'QAR', // Qatar Riyal PAB = "PAB", // 'PANAMANIAN BALBOA'
RON = 'RON', // Romania New Leu PGK = "PGK", // 'PAPUA NEW GUINEAN KINA'
RSD = 'RSD', // Serbia Dinar PHP = "PHP", // 'PHILIPPINE PESO'
RUB = 'RUB', // Russia Ruble PKR = "PKR", // 'PAKISTANI RUPEE'
RWF = 'RWF', // Rwanda Franc PLN = "PLN", // 'POLAND ZŁOTY'
SAR = 'SAR', // Saudi Arabia Riyal PYG = "PYG", // 'PARAGUAYAN GUARANI'
SBD = 'SBD', // Solomon Islands Dollar QAR = "QAR", // 'QATARI RIAL'
SCR = 'SCR', // Seychelles Rupee RON = "RON", // 'ROMANIAN LEU'
SDG = 'SDG', // Sudan Pound RSD = "RSD", // 'SERBIAN DINAR'
SEK = 'SEK', // Sweden Krona RUB = "RUB", // 'RUSSIAN RUBLE'
SGD = 'SGD', // Singapore Dollar RWF = "RWF", // 'RWANDAN FRANC'
SHP = 'SHP', // Saint Helena Pound SAR = "SAR", // 'SAUDI RIYAL'
SLL = 'SLL', // Sierra Leone Leone SBD = "SBD", // 'SOLOMON ISLANDS DOLLAR'
SOS = 'SOS', // Somalia Shilling SCR = "SCR", // 'SEYCHELLOIS RUPEE'
SPL = 'SPL', // Seborga Luigino SDG = "SDG", // 'SUDANESE POUND'
SRD = 'SRD', // Suriname Dollar SEK = "SEK", // 'SWEDISH KRONA'
STD = 'STD', // São Tomé and Príncipe Dobra SGD = "SGD", // 'SINGAPORE DOLLAR'
SVC = 'SVC', // El Salvador Colon SHIB = "SHIB", // 'SHIBA INU'
SYP = 'SYP', // Syria Pound SHP = "SHP", // 'SAINT HELENA POUND'
SZL = 'SZL', // Swaziland Lilangeni SLL = "SLL", // 'SIERRA LEONEAN LEONE'
THB = 'THB', // Thailand Baht SOS = "SOS", // 'SOMALI SHILLING'
TJS = 'TJS', // Tajikistan Somoni SRD = "SRD", // 'SURINAMESE DOLLAR'
TMT = 'TMT', // Turkmenistan Manat STD = "STD", // 'SÃO TOMÉ AND PRÍNCIPE DOBRA (PRE-2018)'
TND = 'TND', // Tunisia Dinar SVC = "SVC", // 'SALVADORAN COLÓN'
TOP = 'TOP', // Tonga Pa'anga SYP = "SYP", // 'SYRIAN POUND'
TRY = 'TRY', // Turkey Lira SZL = "SZL", // 'SWAZI LILANGENI'
TTD = 'TTD', // Trinidad and Tobago Dollar THB = "THB", // 'THAI BAHT'
TVD = 'TVD', // Tuvalu Dollar TJS = "TJS", // 'TAJIKISTANI SOMONI'
TWD = 'TWD', // Taiwan New Dollar TMT = "TMT", // 'TURKMENISTANI MANAT'
TZS = 'TZS', // Tanzania Shilling TND = "TND", // 'TUNISIAN DINAR'
UAH = 'UAH', // Ukraine Hryvnia TOP = "TOP", // "TONGAN PA'ANGA"
UGX = 'UGX', // Uganda Shilling TRY = "TRY", // 'TURKISH LIRA'
USD = 'USD', // United States Dollar TTD = "TTD", // 'TRINIDAD & TOBAGO DOLLAR'
UYU = 'UYU', // Uruguay Peso TWD = "TWD", // 'NEW TAIWAN DOLLAR'
UZS = 'UZS', // Uzbekistan Som TZS = "TZS", // 'TANZANIAN SHILLING'
VEF = 'VEF', // Venezuela Bolivar UAH = "UAH", // 'UKRAINIAN HRYVNIA'
VND = 'VND', // Viet Nam Dong UGX = "UGX", // 'UGANDAN SHILLING'
VUV = 'VUV', // Vanuatu Vatu USD = "USD", // 'UNITED STATES DOLLAR'
WST = 'WST', // Samoa Tala UYU = "UYU", // 'URUGUAYAN PESO'
XAF = 'XAF', // Communauté Financière Africaine (BEAC) CFA Franc BEAC UZS = "UZS", // 'UZBEKISTANI SOM'
XCD = 'XCD', // East Caribbean Dollar VND = "VND", // 'VIETNAMESE DONG'
XDR = 'XDR', // International Monetary Fund (IMF) Special Drawing Rights VUV = "VUV", // 'VANUATU VATU'
XOF = 'XOF', // Communauté Financière Africaine (BCEAO) Franc WST = "WST", // 'SAMOAN TALA'
XPF = 'XPF', // Comptoirs Français du Pacifique (CFP) Franc XAF = "XAF", // 'CENTRAL AFRICAN CFA FRANC'
YER = 'YER', // Yemen Rial XCD = "XCD", // 'EAST CARIBBEAN DOLLAR'
ZAR = 'ZAR', // South Africa Rand XOF = "XOF", // 'WEST AFRICAN CFA FRANC'
ZMW = 'ZMW', // Zambia Kwacha XPF = "XPF", // 'CFP FRANC'
ZWD = 'ZWD', // Zimbabwe Dollar YER = "YER", // 'YEMENI RIAL'
ZAR = "ZAR", // 'SOUTH AFRICAN RAND'
ZMW = "ZMW", // 'ZAMBIAN KWACHA'
ZWL = "ZWL", // 'ZIMBABWEAN DOLLAR'
} }
export const CURRENCY_OPTIONS = Object.entries(Currency).map( export const CURRENCY_OPTIONS = Object.entries(Currency).map(

@ -0,0 +1,14 @@
// API from https://github.com/fawazahmed0/currency-api#readme
export const convert = async (
value: number,
fromCurrency: string,
toCurrency: string,
) => {
fromCurrency = fromCurrency.trim().toLowerCase();
toCurrency = toCurrency.trim().toLowerCase();
const url = ['https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies', fromCurrency, toCurrency].join('/');
return await fetch(url + '.json')
.then((res) => res.json())
.then((data) => value * data[toCurrency]);
};

@ -4607,7 +4607,7 @@ atob@^2.1.2:
attr-accept@^2.2.2: attr-accept@^2.2.2:
version "2.2.2" version "2.2.2"
resolved "https://registry.yarnpkg.com/attr-accept/-/attr-accept-2.2.2.tgz#646613809660110749e92f2c10833b70968d929b" resolved "https://registry.npmjs.org/attr-accept/-/attr-accept-2.2.2.tgz"
integrity sha512-7prDjvt9HmqiZ0cl5CRjtS84sEyhsHP2coDkaZKRKVfCDo9s7iw7ChVmar78Gu9pC4SoR/28wFu/G5JJhTnqEg== integrity sha512-7prDjvt9HmqiZ0cl5CRjtS84sEyhsHP2coDkaZKRKVfCDo9s7iw7ChVmar78Gu9pC4SoR/28wFu/G5JJhTnqEg==
autoprefixer@^10.3.7, autoprefixer@^10.4.12, autoprefixer@^10.4.7: autoprefixer@^10.3.7, autoprefixer@^10.4.12, autoprefixer@^10.4.7:
@ -7740,7 +7740,7 @@ file-loader@^6.0.0, file-loader@^6.2.0:
file-selector@^0.6.0: file-selector@^0.6.0:
version "0.6.0" version "0.6.0"
resolved "https://registry.yarnpkg.com/file-selector/-/file-selector-0.6.0.tgz#fa0a8d9007b829504db4d07dd4de0310b65287dc" resolved "https://registry.npmjs.org/file-selector/-/file-selector-0.6.0.tgz"
integrity sha512-QlZ5yJC0VxHxQQsQhXvBaC7VRJ2uaxTf+Tfpu4Z/OcVQJVpZO+DGU0rkoVW5ce2SccxugvpBJoMvUs59iILYdw== integrity sha512-QlZ5yJC0VxHxQQsQhXvBaC7VRJ2uaxTf+Tfpu4Z/OcVQJVpZO+DGU0rkoVW5ce2SccxugvpBJoMvUs59iILYdw==
dependencies: dependencies:
tslib "^2.4.0" tslib "^2.4.0"
@ -12176,7 +12176,7 @@ react-dom@18.2.0, react-dom@^18.2.0:
react-dropzone@^14.2.3: react-dropzone@^14.2.3:
version "14.2.3" version "14.2.3"
resolved "https://registry.yarnpkg.com/react-dropzone/-/react-dropzone-14.2.3.tgz#0acab68308fda2d54d1273a1e626264e13d4e84b" resolved "https://registry.npmjs.org/react-dropzone/-/react-dropzone-14.2.3.tgz"
integrity sha512-O3om8I+PkFKbxCukfIR3QAGftYXDZfOE2N1mr/7qebQJHs7U+/RSL/9xomJNpRg9kM5h9soQSdf0Gc7OHF5Fug== integrity sha512-O3om8I+PkFKbxCukfIR3QAGftYXDZfOE2N1mr/7qebQJHs7U+/RSL/9xomJNpRg9kM5h9soQSdf0Gc7OHF5Fug==
dependencies: dependencies:
attr-accept "^2.2.2" attr-accept "^2.2.2"
@ -14163,47 +14163,47 @@ tty-browserify@0.0.0:
resolved "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz" resolved "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz"
integrity sha512-JVa5ijo+j/sOoHGjw0sxw734b1LhBkQ3bvUGNdxnVXDCX81Yx7TFgnZygxrIIWn23hbfTaMYLwRmAxFyDuFmIw== integrity sha512-JVa5ijo+j/sOoHGjw0sxw734b1LhBkQ3bvUGNdxnVXDCX81Yx7TFgnZygxrIIWn23hbfTaMYLwRmAxFyDuFmIw==
turbo-darwin-64@1.5.5: turbo-darwin-64@1.5.6:
version "1.5.5" version "1.5.6"
resolved "https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-1.5.5.tgz#710d4e7999066bd4f500456f7cd1c30f6e6205ed" resolved "https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-1.5.6.tgz#2e0e14343c84dde33b5a09ea5389ee6a9565779c"
integrity sha512-HvEn6P2B+NXDekq9LRpRgUjcT9/oygLTcK47U0qsAJZXRBSq/2hvD7lx4nAwgY/4W3rhYJeWtHTzbhoN6BXqGQ== integrity sha512-CWdXMwenBS2+QXIR2Czx7JPnAcoMzWx/QwTDcHVxZyeayMHgz8Oq5AHCtfaHDSfV8YhD3xa0GLSk6+cFt+W8BQ==
turbo-darwin-arm64@1.5.5: turbo-darwin-arm64@1.5.6:
version "1.5.5" version "1.5.6"
resolved "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-1.5.5.tgz" resolved "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-1.5.6.tgz"
integrity sha512-Dmxr09IUy6M0nc7/xWod9galIO2DD500B75sJSkHeT+CCdJOWnlinux0ZPF8CSygNqymwYO8AO2l15/6yxcycg== integrity sha512-c/aXgW9JuXT2bJSKf01pdSDQKnrdcdj3WFKmKiVldb9We6eqFzI0fLHBK97k5LM/OesmRMfCMQ2Cv2DU8RqBAA==
turbo-linux-64@1.5.5: turbo-linux-64@1.5.6:
version "1.5.5" version "1.5.6"
resolved "https://registry.yarnpkg.com/turbo-linux-64/-/turbo-linux-64-1.5.5.tgz#f31eb117a9b605f5731048c50473bff903850047" resolved "https://registry.yarnpkg.com/turbo-linux-64/-/turbo-linux-64-1.5.6.tgz#e7ddaf7a87084dfdd9c6d79efb41084d75439b31"
integrity sha512-wd07TZ4zXXWjzZE00FcFMLmkybQQK/NV9ff66vvAV0vdiuacSMBCNLrD6Mm4ncfrUPW/rwFW5kU/7hyuEqqtDw== integrity sha512-y/jNF7SG+XJEwk2GxIqy3g4dj/a0PgZKDGyOkp24qp4KBRcHBl6dI1ZEfNed30EhEqmW4F5Dr7IpeCZoqgbrMg==
turbo-linux-arm64@1.5.5: turbo-linux-arm64@1.5.6:
version "1.5.5" version "1.5.6"
resolved "https://registry.yarnpkg.com/turbo-linux-arm64/-/turbo-linux-arm64-1.5.5.tgz#b9ce6912ae6477e829355d6f012500bfef58669d" resolved "https://registry.yarnpkg.com/turbo-linux-arm64/-/turbo-linux-arm64-1.5.6.tgz#6445f00f84e0f356a6a369ba2d75ede43aaeb796"
integrity sha512-q3q33tuo74R7gicnfvFbnZZvqmlq7Vakcvx0eshifnJw4PR+oMnTCb4w8ElVFx070zsb8DVTibq99y8NJH8T1Q== integrity sha512-FRcxPtW7eFrbR3QaYBVX8cK7i+2Cerqi6F0t5ulcq+d1OGSdSW3l35rPPyJdwCzCy+k/S9sBcyCV0RtbS6RKCQ==
turbo-windows-64@1.5.5: turbo-windows-64@1.5.6:
version "1.5.5" version "1.5.6"
resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.5.5.tgz#609098de3bc6178f733615d21b06d5c1602637eb" resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.5.6.tgz#3638d5297319157031e4dc906dbae53a1db8562c"
integrity sha512-lPp9kHonNFfqgovbaW+UAPO5cLmoAN+m3G3FzqcrRPnlzt97vXYsDhDd/4Zy3oAKoAcprtP4CGy0ddisqsKTVw== integrity sha512-/5KIExY7zbrbeL5fhKGuO85u5VtJ3Ue4kI0MbYCNnTGe7a10yTYkwswgtGihsgEF4AW0Nm0159aHmXZS2Le8IA==
turbo-windows-arm64@1.5.5: turbo-windows-arm64@1.5.6:
version "1.5.5" version "1.5.6"
resolved "https://registry.yarnpkg.com/turbo-windows-arm64/-/turbo-windows-arm64-1.5.5.tgz#60522e1e347a54c64bdddb68089fc322ee19c3d7" resolved "https://registry.yarnpkg.com/turbo-windows-arm64/-/turbo-windows-arm64-1.5.6.tgz#9eff9d13721be0b905b0aad07667507380f738fe"
integrity sha512-3AfGULKNZiZVrEzsIE+W79ZRW1+f5r4nM4wLlJ1PTBHyRxBZdD6KTH1tijGfy/uTlcV5acYnKHEkDc6Q9PAXGQ== integrity sha512-p+LQN9O39+rZuOAyc6BzyVGvdEKo+v+XmtdeyZsZpfj4xuOLtsEptW1w6cUD439u0YcPknuccGq1MQ0lXQ6Xuw==
turbo@latest: turbo@latest:
version "1.5.5" version "1.5.6"
resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.5.5.tgz#9fc3a917c914ffa113c260a4eadb4bc632eee227" resolved "https://registry.npmjs.org/turbo/-/turbo-1.5.6.tgz"
integrity sha512-PVQSDl0STC9WXIyHcYUWs9gXsf8JjQig/FuHfuB8N6+XlgCGB3mPbfMEE6zrChGz2hufH4/guKRX1XJuNL6XTA== integrity sha512-xJO/fhiMo4lI62iGR9OgUfJTC9tnnuoMwNC52IfvvBDEPlA8RWGMS8SFpDVG9bNCXvVRrtUTNJXMe6pJWBiOTA==
optionalDependencies: optionalDependencies:
turbo-darwin-64 "1.5.5" turbo-darwin-64 "1.5.6"
turbo-darwin-arm64 "1.5.5" turbo-darwin-arm64 "1.5.6"
turbo-linux-64 "1.5.5" turbo-linux-64 "1.5.6"
turbo-linux-arm64 "1.5.5" turbo-linux-arm64 "1.5.6"
turbo-windows-64 "1.5.5" turbo-windows-64 "1.5.6"
turbo-windows-arm64 "1.5.5" turbo-windows-arm64 "1.5.6"
type-check@^0.4.0, type-check@~0.4.0: type-check@^0.4.0, type-check@~0.4.0:
version "0.4.0" version "0.4.0"
@ -14641,7 +14641,7 @@ uuid-browser@^3.1.0:
uuid@^3.3.2: uuid@^3.3.2:
version "3.4.0" version "3.4.0"
resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
uuid@^8.3.2: uuid@^8.3.2:

Loading…
Cancel
Save