Skip to content

Commit

Permalink
Small update to Event Form and CC Approval Page
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavberi committed Oct 4, 2024
1 parent 7226ea4 commit 7b95f82
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/actions/events/edit/server_action.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function editEventAction(details, eventid) {
const response = { ok: false, data: null, error: null };

const {
data: { editEvent },
data,
error,
} = await getClient().mutation(EDIT_EVENT, {
details: { ...details, eventid },
Expand All @@ -19,7 +19,7 @@ export async function editEventAction(details, eventid) {
};
} else {
response.ok = true;
response.data = editEvent;
response.data = data.editEvent;
}

return response;
Expand Down
4 changes: 2 additions & 2 deletions src/actions/events/venues/server_action.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function eventsVenues(data) {
const { startDate, endDate, eventid } = data;

const {
data: { availableRooms },
data: outputData,
error,
} = await getClient().query(GET_AVAILABLE_LOCATIONS, {
timeslot: [startDate, endDate],
Expand All @@ -21,7 +21,7 @@ export async function eventsVenues(data) {
};
} else {
response.ok = true;
response.data = availableRooms;
response.data = outputData.availableRooms;
}

return response;
Expand Down
10 changes: 5 additions & 5 deletions src/components/FileUpload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ export default function FileUpload({
}

function getIsTypeofFileRejected(fileRejections, type) {
console.log(
fileRejections.some(({ errors }) =>
errors.some((error) => error.code == type),
),
);
// console.log(
// fileRejections.some(({ errors }) =>
// errors.some((error) => error.code == type),
// ),
// );
return fileRejections.some(({ errors }) =>
errors.some((error) => error.code == type),
);
Expand Down
4 changes: 3 additions & 1 deletion src/components/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ function Bar({ onOpenDrawer }) {

<Stack
direction="row"
alignItems="center"
spacing={{
xs: 0.5,
sm: 1,
}}
sx={{
alignItems: "center",
}}
>
<AccountPopover />
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion src/components/events/EventActionTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ function EventRejectForm({ eventid }) {

const { control, handleSubmit } = useForm({
defaultValues: {
reason: "As requested by the Club to make more edits.",
reason: "Some logical & valid reason...",
},
});

Expand Down
3 changes: 0 additions & 3 deletions src/components/events/EventActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import { Button } from "@mui/material";

import Icon from "components/Icon";
import ConfirmDialog from "components/ConfirmDialog";

import { useToast } from "components/Toast";
import { useAuth } from "components/AuthProvider";

import { deleteEventAction } from "actions/events/delete/server_action";
import { eventProgress } from "actions/events/progress/server_action";
Expand Down Expand Up @@ -213,7 +211,6 @@ export function ApproveEvent({ sx }) {
}

export function ProgressEvent({ sx }) {
const router = useRouter();
const { id } = useParams();
return (
<Button
Expand Down
13 changes: 12 additions & 1 deletion src/components/events/EventForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default function EventForm({
})();
}, []);

const { control, handleSubmit, watch, resetField } = useForm({
const { control, handleSubmit, watch, resetField, setValue } = useForm({
defaultValues,
});
const { triggerToast } = useToast();
Expand Down Expand Up @@ -372,6 +372,7 @@ export default function EventForm({
<EventDatetimeInput
control={control}
watch={watch}
setValue={setValue}
disabled={
!admin_roles.includes(user?.role) &&
defaultValues?.status?.state != undefined &&
Expand Down Expand Up @@ -752,6 +753,7 @@ function filterEvents(events, startTime, endTime) {
function EventDatetimeInput({
control,
watch,
setValue,
disabled = true,
role = "public",
existingEvents = [],
Expand All @@ -776,6 +778,15 @@ function EventDatetimeInput({
}
}, [error]);

useEffect(() => {
if (
startDateInput &&
endDateInput &&
dayjs(startDateInput).isAfter(dayjs(endDateInput))
)
setValue("datetimeperiod.1", null);
}, [startDateInput]);

return (
<Grid container spacing={2}>
<Grid item xs={12} md={6} xl={4}>
Expand Down

0 comments on commit 7b95f82

Please sign in to comment.