Skip to content
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
6 changes: 3 additions & 3 deletions firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ service cloud.firestore {
match /hosts/{hostId} {
allow read: if request.auth != null;
allow write: if request.auth != null &&
(('admin' in request.auth.token.roles) || ('host' in request.auth.token.roles));
request.auth.token.roles.hasAny(['admin', 'host']);
}

// Club settings - admin and host roles can manage
match /club/{clubId} {
allow read: if request.auth != null;
allow write: if request.auth != null &&
(('admin' in request.auth.token.roles) || ('host' in request.auth.token.roles));
request.auth.token.roles.hasAny(['admin', 'host']);
}

// Default rule for all other documents
match /{document=**} {
allow read: if request.auth != null;
allow write: if request.auth != null &&
(('admin' in request.auth.token.roles) || ('host' in request.auth.token.roles));
request.auth.token.roles.hasAny(['admin', 'host']);
}
}
}
6 changes: 3 additions & 3 deletions webapp/src/features/event/EventRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const EventRoot = () => {
const [lineupPosterPreviewUrl, setLineupPosterPreviewUrl] = useState<string | null>(null);
const { eventId } = useParams();

const { saveEvent, getReconcicledEvent} = useEventStore();
const { saveEvent, getReconciledEvent} = useEventStore();

// Listen for changes to the event and reset our actual event when they change.
useEffect(() => {
Expand Down Expand Up @@ -78,7 +78,7 @@ const EventRoot = () => {

const proposeEventChange = (event: Event) => {
let newEvent = { ...event };
newEvent = getReconcicledEvent(newEvent);
newEvent = getReconciledEvent(newEvent);
setHasChanges(true);
setEventScratchpad(newEvent);
};
Expand Down Expand Up @@ -145,7 +145,7 @@ const EventRoot = () => {

// Ensure the event (including lineup poster fields) is fully reconciled
// before saving so that image-only changes are also persisted.
eventToSave = getReconcicledEvent(eventToSave);
eventToSave = getReconciledEvent(eventToSave);

await saveEvent(eventToSave, event);

Expand Down
2 changes: 2 additions & 0 deletions webapp/src/features/event/basic/EventBasicDetailsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Props = {

const EventBasicDetailsForm = ({ event: eventScratchpad, onEventChange: proposeEventChange, onLineupPosterFileChange }: Props) => {

// Note: The Host argument is intentionally unused here; it remains in the
// signature to stay compatible with the HostSearchSelect callback API.
const handleHostSelect = (_: Host | null, hostRef: DocumentReference | null) => {
proposeEventChange({
...eventScratchpad,
Expand Down
5 changes: 4 additions & 1 deletion webapp/src/features/host/CreateHostModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Modal, Button, Stack } from "react-bootstrap";
import { useState } from "react";
import { Host } from "../../util/types";
import HostForm from "./HostForm";
import { createHost } from "../../store/host";
import { createHost, updateHost } from "../../store/host";
import { toast } from "react-hot-toast";
import { ref, uploadBytes, getDownloadURL } from "firebase/storage";
import { storage } from "../../util/firebase";
Expand Down Expand Up @@ -42,6 +42,9 @@ const CreateHostModal = ({ show, onHide, onHostCreated }: Props) => {

host.host_poster_path = storagePath;
host.host_poster_url = downloadUrl;

// Update the host document in Firestore with the poster information
await updateHost(hostRef.id, host);
}

const createdHost = { ...host, id: hostRef.id };
Expand Down
16 changes: 8 additions & 8 deletions webapp/src/hooks/useEventStore/useEventStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useCallback } from "react";
export const useEventStore = () => {
const { djCache, hostCache } = useEventDjCache();

const getReconcicledEvent = useCallback((event: Event) => reconcileEventData(event, djCache, hostCache), [djCache, hostCache]);
const getReconciledEvent = useCallback((event: Event) => reconcileEventData(event, djCache, hostCache), [djCache, hostCache]);

const getNextEvent = useCallback(async () => {
const q = query(collection(db, "events"), where("end_datetime", ">", Timestamp.now()), orderBy("start_datetime", "asc"));
Expand All @@ -19,10 +19,10 @@ export const useEventStore = () => {
const events: Event[] = querySnapshot.docs
.map((doc) => docToEvent(doc))
.filter((event): event is Exclude<typeof event, null> => event !== null)
.map(event => getReconcicledEvent(event));
.map(event => getReconciledEvent(event));

return events[0] ?? null;
}, [getReconcicledEvent]);
}, [getReconciledEvent]);

const getCurrentEvent = useCallback(async () => {
const q = query(
Expand All @@ -36,10 +36,10 @@ export const useEventStore = () => {
const events: Event[] = querySnapshot.docs
.map((doc) => docToEvent(doc))
.filter((event): event is Exclude<typeof event, null> => event !== null)
.map(event => getReconcicledEvent(event));
.map(event => getReconciledEvent(event));

return events[0] ?? null;
}, [getReconcicledEvent]);
}, [getReconciledEvent]);

const createEvent = useCallback(async (event: Event) => {
// lastUpdated is derived from Firestore snapshot metadata and should not
Expand All @@ -51,7 +51,7 @@ export const useEventStore = () => {
}, []);

const saveEvent = useCallback(async (event: Event, previousEvent?: Event) => {
event = getReconcicledEvent(event);
event = getReconciledEvent(event);

const eventId = event.id;

Expand Down Expand Up @@ -87,12 +87,12 @@ export const useEventStore = () => {
});
}
});
}, [getReconcicledEvent]);
}, [getReconciledEvent]);

return {
createEvent,
saveEvent,
getReconcicledEvent,
getReconciledEvent,
getCurrentEvent,
getNextEvent
};
Expand Down
1 change: 1 addition & 0 deletions webapp/src/store/clubSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const getClubSettings = async (): Promise<Club> => {
console.warn(`Club settings document at path "${CLUB_SETTINGS_PATH}" does not exist. Returning default empty settings.`);
// Return default empty settings if document doesn't exist
return {};
}
}

export const updateClubSettings = async (settings: Club) => {
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/store/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ function extractDateOrAny(date: Date | Timestamp | TimestampShell | string | und
/**
* Converts a firebase doc to a host
*
* @param doc
* @returns
* @param doc - The Firestore document containing host data
* @returns A Host object with the document data and ID
*/
export const docToHost = (doc: DocumentData): Host => {
const data = doc.data();
Expand Down