Skip to content

Commit

Permalink
fix: events and organization persist removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ZL-Asica committed Dec 6, 2024
1 parent 219b2e6 commit c63ea97
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 190 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/firebase-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,63 @@ jobs:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout the code
- name: 📥 Checkout Code
uses: actions/checkout@v4

# Step 2: Setup Node.js and enable caching
- name: 🛠️ Setup Node
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'

# Step 3: Restore dependencies cache
- name: 📂 Restore npm cache
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-npm-cache-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-cache-
# Step 4: Install dependencies
- name: 📂 Install Packages
run: npm ci

# Step 5: Run linter
- name: 🚨 Lint Code
run: npm run lint:fix

# Step 6: Format code
- name: 🎨 Format Code
run: npm run format

# Step 7: Build the project
- name: 🧱 Build Project
run: npm run build

# Step 8: Cache the build output
- name: 📦 Cache build output
uses: actions/cache@v4
with:
path: |
dist
key: ${{ runner.os }}-build-cache-${{ hashFiles('src/**', 'public/**') }}
restore-keys: |
${{ runner.os }}-build-cache-
# Step 9: Run tests
- name: 🧪 Run Tests with Vitest
if: success()
run: npm run test:ci

# Step 10: Install Firebase CLI (use cache for global installs)
- name: 🌍 Install Firebase Tools
if: success()
run: npm install -g firebase-tools

# Step 11: Deploy to Firebase
- name: 🚀 Deploy to Firebase
if: success()
env:
Expand Down
76 changes: 34 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@
"@emotion/styled": "^11.13.0",
"@mui/icons-material": "^6.1.10",
"@mui/material": "^6.1.10",
"@mui/x-date-pickers": "^7.23.0",
"@mui/x-date-pickers": "^7.23.1",
"@zl-asica/react": "^0.3.10",
"dayjs": "^1.11.13",
"es-toolkit": "^1.29.0",
"firebase": "^11.0.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-router-dom": "^7.0.2",
"sonner": "^1.7.0",
"zustand": "^5.0.2"
},
"devDependencies": {
"@types/react": "^18.3.13",
"@types/react-dom": "^18.3.1",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.1",
"@types/react-router-dom": "^5.3.3",
"@vitejs/plugin-react-swc": "^3.7.2",
"@vitest/ui": "^2.1.8",
Expand All @@ -54,9 +54,9 @@
"lint-staged": "^15.2.10",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"vite": "^6.0.2",
"vite": "^6.0.3",
"vite-plugin-checker": "^0.8.0",
"vite-tsconfig-paths": "^5.1.2",
"vite-tsconfig-paths": "^5.1.4",
"vitest": "^2.1.8"
},
"engines": {
Expand Down
7 changes: 5 additions & 2 deletions src/components/Home/DonorDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import { useState, useMemo } from 'react';

import OrganizationCard from './OrganizationCard';

import { useOrganizationStore } from '@/stores';
import { useOrganizationStore, useUserStore } from '@/stores';

import { SearchBar, Filters } from '@/components/common';
import { SearchBar, Filters, LoadingCircle } from '@/components/common';

const DonorDashboard = () => {
const [searchQuery, setSearchQuery] = useState('');
const [needsQuery, setNeedsQuery] = useState('');
const [descriptionQuery, setDescriptionQuery] = useState('');
const [locationQuery, setLocationQuery] = useState('');

const loading = useUserStore((state) => state.loading);
if (loading) return <LoadingCircle />;

const organizationProfiles = useOrganizationStore(
(state) => state.organizationProfiles
);
Expand Down
7 changes: 5 additions & 2 deletions src/components/Schedule/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@ import dayjs from 'dayjs';

import EventsCalendar from './EventsCalendar';

import { useEventStore } from '@/stores';

import {
generateICSFile,
generateCombinedICSFile,
} from '@/utils/generateICSFile';

interface ScheduleBaseProps {
events: DonationEvent[];
title: string;
description: string;
}

const ScheduleBase = ({ events, title, description }: ScheduleBaseProps) => {
const ScheduleBase = ({ title, description }: ScheduleBaseProps) => {
const events = useEventStore((store) => store.events);

const [selectedDate, setSelectedDate] = useState<Dayjs | null>(dayjs());
const [selectedEvent, setSelectedEvent] = useState<DonationEvent | null>(
null
Expand Down
5 changes: 1 addition & 4 deletions src/pages/Schedule.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useUserStore, useEventStore } from '@/stores';
import { useUserStore } from '@/stores';

import ScheduleBase from '@/components/Schedule';

Expand All @@ -7,8 +7,6 @@ const DonorSchedule = () => {

if (!user) return null;

const events = useEventStore((store) => store.events);

const title =
user.role === 'donor'
? 'Your Donation Schedule'
Expand All @@ -20,7 +18,6 @@ const DonorSchedule = () => {

return (
<ScheduleBase
events={events}
title={title}
description={description}
/>
Expand Down
7 changes: 6 additions & 1 deletion src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Schedule from '@/pages/Schedule';
import Saved from '@/pages/Saved';
import Alerts from '@/pages/Alerts';

import { ProtectedRoute, Layout } from '@/components/common';
import { ProtectedRoute, Layout, LoadingCircle } from '@/components/common';

const AppRoutes = () => {
const routeConfig = [
Expand All @@ -20,13 +20,16 @@ const AppRoutes = () => {

const loading = useUserStore((state) => state.loading);
const user = useUserStore((state) => state.user);
const fetchProfiles = useOrganizationStore((state) => state.fetchProfiles);
const subscribeToProfiles = useOrganizationStore(
(state) => state.subscribeToProfiles
);
const error = useOrganizationStore((state) => state.error);

useEffect(() => {
if (!loading && (!user || user.role !== 'organization')) {
fetchProfiles();

const unsubscribe = subscribeToProfiles;

return () => unsubscribe && unsubscribe();
Expand All @@ -39,6 +42,8 @@ const AppRoutes = () => {
}
}, [error]);

if (loading) return <LoadingCircle />;

return (
<Routes>
<Route
Expand Down
Loading

0 comments on commit c63ea97

Please sign in to comment.