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 ae26f04
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 189 deletions.
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 ae26f04

Please sign in to comment.