Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load calendar data #100

Merged
merged 9 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ thumbs.db
# turbo build log
**/.turbo/*

.env
.turbo
.env
79 changes: 41 additions & 38 deletions apps/api/package.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
{
"name": "api",
"scripts": {
"lint": "eslint . --fix",
"format": "prettier --write \"**/*.{js,cjs,mjs,ts,tsx,md,json}\"",
"dev": "wrangler dev src/index.ts",
"deploy": "wrangler deploy --minify src/index.ts",
"db:generate": "drizzle-kit generate:sqlite",
"db:migrate": "wrangler d1 migrations apply demo --local",
"db:migrate:prod": "wrangler d1 migrations apply demo --remote",
"db:studio": "drizzle-kit studio",
"db:studio:local": "cross-env LOCAL_DB_PATH=$(find .wrangler/state/v3/d1/miniflare-D1DatabaseObject -type f -name '*.sqlite' -print -quit) drizzle-kit studio"
},
"dependencies": {
"@hono/zod-validator": "^0.2.1",
"@oslojs/crypto": "^1.0.1",
"@oslojs/encoding": "^1.1.0",
"@tsndr/cloudflare-worker-jwt": "^2.5.3",
"arctic": "^1.7.0",
"better-sqlite3": "^9.6.0",
"cross-env": "^7.0.3",
"drizzle-orm": "^0.30.9",
"hono": "^4.2.8",
"oslo": "^1.2.0",
"zod": "^3.23.4"
},
"devDependencies": {
"@miti/eslint-config": "workspace:*",
"@miti/prettier-config": "workspace:*",
"@miti/tsconfig": "workspace:*",
"@cloudflare/workers-types": "^4.20240423.0",
"drizzle-kit": "^0.20.17",
"wrangler": "^3.52.0"
},
"eslintConfig": {
"root": true,
"extends": ["@miti/eslint-config/base", "@miti/eslint-config/react"]
},
"prettier": "@miti/prettier-config"
"name": "api",
"scripts": {
"lint": "eslint . --fix",
"format": "prettier --write \"**/*.{js,cjs,mjs,ts,tsx,md,json}\"",
"dev": "wrangler dev src/index.ts",
"deploy": "wrangler deploy --minify src/index.ts",
"db:generate": "drizzle-kit generate:sqlite",
"db:migrate": "wrangler d1 migrations apply demo --local",
"db:migrate:prod": "wrangler d1 migrations apply demo --remote",
"db:studio": "drizzle-kit studio",
"db:studio:local": "cross-env LOCAL_DB_PATH=$(find .wrangler/state/v3/d1/miniflare-D1DatabaseObject -type f -name '*.sqlite' -print -quit) drizzle-kit studio"
},
"dependencies": {
"@hono/zod-validator": "^0.2.1",
"@oslojs/crypto": "^1.0.1",
"@oslojs/encoding": "^1.1.0",
"@tsndr/cloudflare-worker-jwt": "^2.5.3",
"arctic": "^1.7.0",
"better-sqlite3": "^9.6.0",
"cross-env": "^7.0.3",
"drizzle-orm": "^0.30.9",
"hono": "^4.2.8",
"oslo": "^1.2.0",
"zod": "^3.23.4"
},
"devDependencies": {
"@miti/eslint-config": "workspace:*",
"@miti/prettier-config": "workspace:*",
"@miti/tsconfig": "workspace:*",
"@cloudflare/workers-types": "^4.20240423.0",
"drizzle-kit": "^0.20.17",
"wrangler": "^3.52.0"
},
"eslintConfig": {
"root": true,
"extends": [
"@miti/eslint-config/base",
"@miti/eslint-config/react"
]
},
"prettier": "@miti/prettier-config"
}
20 changes: 20 additions & 0 deletions apps/vite/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "new-york",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"css": "src/index.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
}
41 changes: 25 additions & 16 deletions apps/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,58 @@
"dependencies": {
"@headlessui/react": "^1.7.15",
"@heroicons/react": "^2.0.18",
"@miti/query": "*",
"@miti/types": "*",
Comment on lines +15 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use explicit versions for workspace dependencies

Using "*" for workspace dependencies (@miti/query, @miti/types) can lead to unexpected breaking changes and non-deterministic builds. Consider using explicit versions or workspace: protocol.

-    "@miti/query": "*",
-    "@miti/types": "*",
+    "@miti/query": "workspace:*",
+    "@miti/types": "workspace:*",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@miti/query": "*",
"@miti/types": "*",
"@miti/query": "workspace:*",
"@miti/types": "workspace:*",

"@radix-ui/react-dialog": "^1.1.2",
"@radix-ui/react-icons": "^1.3.0",
"@tanstack/react-query": "^4.29.15",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"date-fns": "^2.30.0",
"dexie": "^3.2.4",
"i18next": "^23.2.3",
"i18next-browser-languagedetector": "^7.0.2",
"i18next-http-backend": "^2.2.1",
"lucide-react": "^0.453.0",
"nepali-date-converter": "^3.3.2",
"nepali-datetime": "^1.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hot-toast": "^2.4.1",
"react-router-dom": "^6.12.1",
"workbox-window": "^7.0.0",
"@miti/query": "*",
"@miti/types": "*"
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7",
"vaul": "^1.1.0",
"workbox-window": "^7.0.0"
},
"devDependencies": {
"@eslint/js": "^9.11.1",
"@types/node": "^22.7.9",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@typescript-eslint/eslint-plugin": "^5.59.0",
"@typescript-eslint/parser": "^5.59.0",
"@vitejs/plugin-react": "^4.3.2",
"@vitejs/plugin-react-swc": "^3.0.0",
"autoprefixer": "^10.4.14",
"eslint": "^9.11.1",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

ESLint v9.11.1 is an incorrect version - this appears to be an error

The specified ESLint version (^9.11.1) in apps/vite/package.json is incorrect as ESLint's current stable version is in the 8.x range. Additionally, there are incompatible dependency versions:

  • @typescript-eslint/eslint-plugin and @typescript-eslint/parser are at v5.59.0 which are not compatible with ESLint 9.x
  • The workspace's shared ESLint config package (@miti/eslint-config) uses ESLint 8.56.0

The version should be downgraded to match the workspace's ESLint version (^8.56.0) to maintain compatibility across the monorepo.

🔗 Analysis chain

Verify compatibility with major version updates

The significant version updates to ESLint (^9.11.1), TypeScript (^5.5.3), and Vite (^5.4.8) may require additional configuration changes or code modifications.

Also applies to: 58-58, 60-60


Let me gather more information about the ESLint configuration and potential compatibility issues.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential TypeScript and ESLint compatibility issues

# Look for tsconfig.json and verify its contents are compatible with TS 5.5
echo "Checking TypeScript configuration..."
if [ -f "tsconfig.json" ]; then
  cat tsconfig.json
fi

# Check for ESLint configuration
echo "Checking ESLint configuration..."
for config in .eslintrc.* .eslintrc; do
  if [ -f "$config" ]; then
    cat "$config"
  fi
done

# Look for Vite configuration
echo "Checking Vite configuration..."
for config in vite.config.ts vite.config.js; do
  if [ -f "$config" ]; then
    cat "$config"
  fi
done

Length of output: 612


Script:

#!/bin/bash
# Search for ESLint config files recursively and check package dependencies
echo "Searching for ESLint config files..."
fd -e .eslintrc.js -e .eslintrc.json -e .eslintrc.yaml -e .eslintrc.yml

echo -e "\nChecking package.json files for ESLint related dependencies..."
fd package.json --exec grep -l "eslint"

echo -e "\nChecking content of found package.json files..."
fd package.json --exec cat {} \; | grep -A 5 -B 5 "eslint"

echo -e "\nChecking for TypeScript related files..."
fd tsconfig.json

Length of output: 5390

"eslint-plugin-react-hooks": "^5.1.0-rc.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Avoid using release candidate versions in production

The ESLint React Hooks plugin is using a release candidate version (^5.1.0-rc.0), which may not be stable for production use.

-    "eslint-plugin-react-hooks": "^5.1.0-rc.0",
+    "eslint-plugin-react-hooks": "^4.6.0",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-hooks": "^4.6.0",

"eslint-plugin-react-refresh": "^0.4.12",
"globals": "^15.9.0",
"postcss": "^8.4.24",
"prettier": "^2.8.8",
"prettier-plugin-tailwindcss": "^0.3.0",
"react-i18next": "^13.0.1",
"tailwindcss": "^3.4.14",
"typescript": "^5.5.3",
"typescript-eslint": "^8.7.0",
"vite": "^5.4.8",
"vite-plugin-pwa": "^0.16.4",
"workbox-cacheable-response": "^7.0.0",
"workbox-expiration": "^7.0.0",
"workbox-google-analytics": "^7.0.0",
"workbox-precaching": "^7.0.0",
"workbox-routing": "^7.0.0",
"workbox-strategies": "^7.0.0",
"@eslint/js": "^9.11.1",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.2",
"eslint": "^9.11.1",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.12",
"globals": "^15.9.0",
"tailwindcss": "^3.4.14",
"typescript": "^5.5.3",
"typescript-eslint": "^8.7.0",
"vite": "^5.4.8"
"workbox-strategies": "^7.0.0"
}
}
38 changes: 21 additions & 17 deletions apps/vite/src/Body.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
import { useContext } from 'react'
import { Route, Routes } from 'react-router-dom'
import AnnouncementAlert from './components/AnnouncementAlert'
import { DarkModeContext } from './components/DarkModeProvider'
import Footer from './components/Footer'
import Navbar from './components/Navbar'
import About from './pages/About'
import DateConverter from './pages/DateConverter'
import GoogleApiDisclosure from './pages/GoogleApiDisclosure'
import Home from './pages/Home'
import PrivacyPolicy from './pages/PrivacyPolicy'
import Calendar2 from './pages/Calendar2'
import { useContext } from "react"
import { Route, Routes } from "react-router-dom"
import AnnouncementAlert from "./components/AnnouncementAlert"
import { DarkModeContext } from "./components/DarkModeProvider"
import Footer from "./components/Footer"
import Navbar from "./components/Navbar"
import About from "./pages/About"
import DateConverter from "./pages/DateConverter"
import GoogleApiDisclosure from "./pages/GoogleApiDisclosure"
import Home from "./pages/Home"
import PrivacyPolicy from "./pages/PrivacyPolicy"
import Calendar2 from "./pages/Calendar2"

const Body = () => {
const { darkMode } = useContext(DarkModeContext)

return (
<div className={(darkMode ? 'dark' : '') + ' flex min-h-screen flex-col'}>
<AnnouncementAlert />
<div className={(darkMode ? "dark" : "") + " flex min-h-screen flex-col"}>
{/* <AnnouncementAlert /> */}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Remove unused import and commented component

The AnnouncementAlert component is imported but only appears as a commented-out component in Body.tsx. Since there are no other active usages of this component in the codebase, you should:

  • Remove the import statement import AnnouncementAlert from "./components/AnnouncementAlert" from Body.tsx
  • Remove the commented-out component {/* <AnnouncementAlert /> */}
  • Consider removing the unused component file apps/vite/src/components/AnnouncementAlert.tsx if it's no longer needed
🔗 Analysis chain

Verify if AnnouncementAlert should be removed

The AnnouncementAlert component is imported but commented out. Please verify if this was intentional.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if AnnouncementAlert is used elsewhere in the codebase
rg -l "AnnouncementAlert"

Length of output: 279


Script:

#!/bin/bash
# Check for AnnouncementAlert in the codebase with ripgrep
rg "AnnouncementAlert" -A 2

# Also check imports specifically
rg "import.*AnnouncementAlert"

# Check if the component file exists
fd "AnnouncementAlert"

Length of output: 891

<Navbar />
<div className="flex-grow">
<Routes>
<Route path="/:pageType?/:BSYear?/:BSMonth?" element={<Home />} />
<Route path="/calendar2" element={<Calendar2 />} />
{/* <Route path="/:pageType?/:BSYear?/:BSMonth?" element={<Home />} /> */}
<Route path="/" element={<Calendar2 />} />
<Route path="/calendar/:BSYear?/:BSMonth?" element={<Calendar2 />} />
<Route path="/privacy" element={<PrivacyPolicy />} />
<Route path="/converter" element={<DateConverter />} />
<Route path="/about" element={<About />} />
<Route path="/google-api-disclosure" element={<GoogleApiDisclosure />} />
<Route
path="/google-api-disclosure"
element={<GoogleApiDisclosure />}
/>
</Routes>
</div>
<Footer />
Expand Down
2 changes: 0 additions & 2 deletions apps/vite/src/components/AddEventModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ function AddEventModal({ startDate }: { startDate: Date }) {
const { data: calendarList, isLoading: isCalendarListLoading } =
useCalendarList(apiBaseUrl)

useEffect(() => {}, [])

useEffect(() => {
if (!calendarList) return
setSelectedCalendar(calendarList[0]?.value || "")
Expand Down
58 changes: 37 additions & 21 deletions apps/vite/src/components/DropDown.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,68 @@
import { Dispatch, Fragment } from "react";
import { Listbox, Transition } from "@headlessui/react";
import { ChevronUpDownIcon, CheckIcon } from "@heroicons/react/20/solid";
import { Dispatch, Fragment } from "react"
import { Listbox, Transition } from "@headlessui/react"
import { ChevronUpDownIcon, CheckIcon } from "@heroicons/react/20/solid"

interface DropDownProps {
selected: string | number;
className?: string;
setSelected: Dispatch<React.SetStateAction<string | number>>;
selected: string | number
className?: string
setSelected: Dispatch<React.SetStateAction<string | number>>
items:
| string[]
| {
label: string;
value: string | number;
}[];
label: string
value: string | number
}[]
}

const DropDown = ({ selected, setSelected, items, className }: DropDownProps) => {
const DropDown = ({
selected,
setSelected,
items,
className,
}: DropDownProps) => {
const formattedItems = items.map((item) =>
typeof item === "string" ? { label: item, value: item } : item
);
const selectedValue = formattedItems.find((item) => item.value === selected);
)
const selectedValue = formattedItems.find((item) => item.value === selected)
return (
<div className={className}>
<Listbox value={selected} onChange={(value) => setSelected(value)}>
<div className="relative mt-1">
<Listbox.Button className="relative w-auto cursor-default rounded-md bg-white py-2 pl-3 pr-10 text-left shadow-sm focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-orange-300 dark:bg-gray-800 dark:text-white sm:text-sm">
<Listbox.Button className="w-28 relative cursor-default rounded-md bg-white py-2 pl-3 pr-10 text-left shadow-sm focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-orange-300 dark:bg-gray-800 dark:text-white sm:text-sm">
<span className="block truncate">{selectedValue?.label}</span>
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
<ChevronUpDownIcon className="h-5 w-5 text-gray-400" aria-hidden="true" />
<ChevronUpDownIcon
className="h-5 w-5 text-gray-400"
aria-hidden="true"
/>
</span>
</Listbox.Button>
<Transition
as={Fragment}
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0">
leaveTo="opacity-0"
>
<Listbox.Options className="scrollbar-hide absolute z-50 mt-1 max-h-60 w-auto overflow-auto rounded-md border bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:border-gray-600 dark:bg-gray-800 sm:text-sm">
{formattedItems.map((item, idx) => (
<Listbox.Option
key={idx}
className={({ active }) =>
`relative cursor-default select-none py-2 pl-8 pr-4 ${
active ? "bg-amber-100 text-amber-900" : "text-gray-900 dark:text-white"
active
? "bg-amber-100 text-amber-900"
: "text-gray-900 dark:text-white"
}`
}
value={item.value}>
value={item.value}
>
{({ selected }) => (
<>
<span className={`block truncate ${selected ? "font-medium" : "font-normal"}`}>
<span
className={`block truncate ${
selected ? "font-medium" : "font-normal"
}`}
>
{item.label}
</span>
{selected ? (
Expand All @@ -63,7 +79,7 @@ const DropDown = ({ selected, setSelected, items, className }: DropDownProps) =>
</div>
</Listbox>
</div>
);
};
)
}

export default DropDown;
export default DropDown
10 changes: 4 additions & 6 deletions apps/vite/src/components/MonthCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import nepaliNumber from "../helper/nepaliNumber"
import useLanguage from "../helper/useLanguage"
import { useUser } from "@miti/query/user"
import { classNames } from "../helper/utils"
import { cn } from "@/lib/utils"
import type { DayData } from "@miti/types"
import type { CalendarEventsResult } from "@miti/types"
import AddEventModal from "./AddEventModal"
Expand Down Expand Up @@ -101,7 +101,7 @@ export default function MonthCalendar({
setSelectedDay(dayInNepaliDate)
}}
style={dayIdx === 0 ? { gridColumnStart: day.week_day + 1 } : {}}
className={classNames(
className={cn(
"p-1 font-mukta leading-3 hover:bg-gray-100 focus:z-10",
(isSelectedDay || isToday) && "font-semibold",
isToday && "bg-indigo-200 font-semibold text-indigo-600",
Expand Down Expand Up @@ -130,14 +130,12 @@ export default function MonthCalendar({
style={{
backgroundColor: color ? colors[color] : "#475569",
}}
className={classNames(
`mx-[1px] inline-block h-1 w-1 rounded-full`
)}
className={cn(`mx-[1px] inline-block h-1 w-1 rounded-full`)}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Simplify template literal usage.

The template literal is unnecessary when no interpolation is needed.

-    className={cn(`mx-[1px] inline-block h-1 w-1 rounded-full`)}
+    className={cn('mx-[1px] inline-block h-1 w-1 rounded-full')}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
className={cn(`mx-[1px] inline-block h-1 w-1 rounded-full`)}
className={cn('mx-[1px] inline-block h-1 w-1 rounded-full')}
🧰 Tools
🪛 Biome

[error] 133-133: Do not use template literals if interpolation and special-character handling are not needed.

Unsafe fix: Replace with string literal

(lint/style/noUnusedTemplateLiteral)

></span>
))}
<time
dateTime={day.AD_date.ad}
className={classNames(
className={cn(
"mx-auto mt-0 flex items-center justify-center rounded-full pt-0 text-xl"
)}
>
Expand Down
Loading