-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from ajaynegi45/home-page
Home page
- Loading branch information
Showing
7 changed files
with
99 additions
and
115 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from 'react'; | ||
import { getUpcomingFestival } from "@/utils/festivals"; | ||
import SectionCard from "@/components/ui/SectionCard"; | ||
import Nanda_Sunanda from "/public/Nanda-Sunanda.webp"; | ||
|
||
|
||
const Festivals: React.FC = () => { | ||
const upcomingFestival = getUpcomingFestival(); // Get the upcoming festival | ||
|
||
// Function to format a date in DD-MM-YYYY format | ||
const formatFestivalDate = (festivalDate: string): string => { | ||
const [day, month] = festivalDate.split('-'); | ||
const currentYear = new Date().getFullYear(); | ||
return `${day}-${month}-${currentYear}`; // Convert to DD-MM-YYYY format | ||
}; | ||
|
||
return ( | ||
<div> | ||
<h1>Upcoming Festivals in Uttarakhand</h1> | ||
{upcomingFestival ? ( | ||
<div> | ||
<strong>{upcomingFestival.name}</strong> - {formatFestivalDate(upcomingFestival.date)} | ||
</div> | ||
) : ( | ||
<p>No upcoming festivals</p> | ||
)} | ||
|
||
<SectionCard cardTitle={"UPCOMING FESTIVAL"} title={upcomingFestival.name} subTitle={formatFestivalDate(upcomingFestival.date)} description={"Egaas Bagwal is a unique festival celebrated 11 days after Diwali in the hilly regions of Uttarakhand. According to local belief, Lord Rama returned from exile late to these areas, which is why people here celebrate Egaas with great enthusiasm. The festival involves preparing traditional delicacies, performing joyful folk dances, and lighting up homes, much like Diwali. A standout tradition is spinning a flaming rope called \"Bhailo\", where villagers twirl a fire-lit rope, creating a mesmerizing display symbolizing light’s triumph over darkness. Egaas Bagwal reflects Uttarakhand’s rich cultural heritage, offering a glimpse into the community’s deep-rooted traditions and festive spirit. For the people of Uttarakhand, it’s not just a festival, but a meaningful tribute to their ancestors and the vibrant life of the hills."} | ||
image={Nanda_Sunanda} readMoreLink={""} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Festivals; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Define an interface 'Festival' that represents the structure of a festival object | ||
// This interface ensures that every festival object will have two properties: | ||
// 1. 'name' - a string that stores the name of the festival. | ||
// 2. 'date' - a string that represents the date of the festival (in DD-MM format). | ||
export interface Festival { | ||
name: string; // The name of the festival, e.g., "Harela". | ||
date: string; // The date of the festival in DD-MM format, e.g., "16-07". | ||
} | ||
|
||
// Define a constant 'festivals', which is an array of objects, each object conforming | ||
// to the 'Festival' interface. This array contains details about several Uttarakhand festivals. | ||
export const festivals: Festival[] = [ | ||
{ name: "Harela", date: "16-07" }, | ||
{ name: "Phool Dei", date: "14-03" }, | ||
{ name: "Nanda Devi Raj Jat", date: "05-09" }, | ||
{ name: "Bikhauti", date: "14-04" }, | ||
{ name: "Kauthig", date: "22-02" }, | ||
{ name: "Ghee Sankranti", date: "17-02" }, | ||
{ name: "Egaas Bhagwal", date: "12-03" } | ||
]; | ||
|
||
// Define a function 'getUpcomingFestival' which returns the festival happening today or the next upcoming festival, | ||
// and if all festivals for the current year have passed, it returns the first festival of the next year. | ||
export const getUpcomingFestival = (): Festival => { | ||
|
||
// Get the current date. | ||
const currentDate = new Date(); | ||
const currentDay = currentDate.getDate(); | ||
const currentMonth = currentDate.getMonth() + 1; // Months are zero-indexed in JS, so add 1. | ||
|
||
// Function to compare festival date with current date, accounting for annual recurrence. | ||
const compareDate = (festivalDate: string): number => { | ||
const [day, month] = festivalDate.split('-').map(Number); | ||
|
||
// Create date objects with the current year. | ||
const festivalThisYear = new Date(currentDate.getFullYear(), month - 1, day); | ||
const today = new Date(currentDate.getFullYear(), currentMonth - 1, currentDay); | ||
|
||
// Calculate the difference in time (in milliseconds). | ||
return festivalThisYear.getTime() - today.getTime(); | ||
}; | ||
|
||
// Filter the 'festivals' array to only keep future festivals or today's festival. | ||
const upcomingFestivals = festivals | ||
.filter(festival => compareDate(festival.date) >= 0) | ||
.sort((a, b) => compareDate(a.date) - compareDate(b.date)); | ||
|
||
// If there are upcoming festivals for the current year, return the first one. | ||
if (upcomingFestivals.length > 0) { | ||
return upcomingFestivals[0]; | ||
} | ||
|
||
// If no festivals are left for this year, return the first festival of the next year. | ||
// Assume the festivals repeat annually. | ||
return festivals.sort((a, b) => compareDate(a.date) - compareDate(b.date))[0]; | ||
}; | ||
|
||
|