w-aura/src/services/zodiac-sign/index.ts
2025-04-07 07:03:12 +00:00

37 lines
817 B
TypeScript

import { AssetCategory } from "@/api/resources/AssetCategories";
export const ZODIACS = [
"Capricorn",
"Aquarius",
"Pisces",
"Aries",
"Taurus",
"Gemini",
"Cancer",
"Leo",
"Virgo",
"Libra",
"Scorpio",
"Sagittarius",
"Capricorn",
];
export const getZodiacSignByDate = (birthDate: string): string => {
const date = new Date(birthDate);
const day = date.getDate();
const month = date.getMonth() + 1;
const last_day = [19, 18, 20, 19, 20, 20, 22, 22, 22, 22, 21, 21];
return day > last_day[month - 1] ? ZODIACS[month * 1] : ZODIACS[month - 1];
};
export const getCategoryIdByZodiacSign = (
zodiacSign: string,
categories: AssetCategory[]
) => {
const categoryId = categories.find(
(category) => category.slug === zodiacSign?.toLowerCase()
)?.id;
return categoryId;
};