Skip to content

Commit

Permalink
fix: sonarqube issues
Browse files Browse the repository at this point in the history
- fixed various issues spotted by sonarqube
  • Loading branch information
cgawron committed Oct 7, 2024
1 parent 6c8e66d commit ee50d47
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 513 deletions.
6 changes: 4 additions & 2 deletions client/public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
"careful_misty_bullock_splash": "Schritt 3: Teilen Sie Ihren Link",
"game_frail_vole_treasure": "Erledigt! Glückwunsch!",
"still_helpful_koala_trust": "Sobald ein Benutzer einen Termin bucht, wird das Ereignis Ihrem Kalender hinzugefügt.",
"steep_fine_lobster_inspire": "Terminart konnte nicht gespeichert werden",
"best_due_parakeet_zip": "Terminart angelegt",
"Name": "Name",
"Please provide your name": "Bitte geben Sie Ihren Namen an",
"Email": "E-Mail-Adresse",
Expand All @@ -66,6 +68,6 @@
"Choose date": "Datum wählen",
"Choose time": "Uhrzeit wählen",
"Provide details": "Details angeben",
"steep_fine_lobster_inspire": "Terminart konnte nicht gespeichert werden",
"best_due_parakeet_zip": "Terminart angelegt"
"happy_caring_fox_spur": "Terminart gespeichert",
"tasty_witty_stingray_hope": "Fehler beim Speichern der Terminart"
}
4 changes: 3 additions & 1 deletion client/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,7 @@
"game_frail_vole_treasure": "Done! Congrats!",
"still_helpful_koala_trust": "Once a user books an appointment, the event is added to your calendar.",
"steep_fine_lobster_inspire": "Failed to save event type",
"best_due_parakeet_zip": "Event type created!"
"best_due_parakeet_zip": "Event type created!",
"happy_caring_fox_spur": "Event saved",
"tasty_witty_stingray_hope": "Error saving event"
}
5 changes: 0 additions & 5 deletions client/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import Login from "./pages/Login";
import Landing from "./pages/Landing";
import AddEvent from "./pages/AddEvent";
import Planning from "./pages/Planning";
import Schedule from "./pages/Schedule";
import NotFound from "./pages/NotFound";
import Booking from "./pages/Booking";
import EditEvent from "./pages/EditEvent";
Expand Down Expand Up @@ -142,10 +141,6 @@ root.render(
path="/landing"
element={<Landing />}
/>
<Route
path="/schedule/:user_url/:url"
element={<Schedule />}
/>
<Route
path="/users/:user_url"
element={<Planning />}
Expand Down
12 changes: 4 additions & 8 deletions client/src/pages/Booking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ const Booking = (props: any) => {
const [skipped, setSkipped] = React.useState(new Set());
const [event, setEvent] = useState<Event>(EMPTY_EVENT);
const [selectedDate, setDate] = useState<Date>();
const [beginDate, setBeginDate] = useState<Date>(new Date());
const [beginDate] = useState<Date>(new Date());
const [slots, setSlots] = useState<IntervalSet>();
const [selectedTime, setTime] = useState<Date>();
const [selectedTime, setSelectedTime] = useState<Date>();
const [details, setDetails] = useState<Details>();
const [isPending, startTransition] = useTransition()
const [, startTransition] = useTransition()

const updateSlots = (startDate: Date) => {
getAvailableTimes(
Expand Down Expand Up @@ -180,9 +180,7 @@ const Booking = (props: any) => {
};

const handleMonthChange = (date: Date) => {
//setBeginDate(date);
console.log("handleMonthChange: %o", date);
//updateSlots(date);
};

const handleDateChange = (newValue: Date) => {
Expand All @@ -194,7 +192,6 @@ const Booking = (props: any) => {
const steps = ["Choose date", "Choose time", "Provide details"].map((label) => t(label));

const checkDay = (date: Date) => {
//console.log("checkDay: %o %o", slots, event.available);
if (!event.available) {
return false;
} else {
Expand All @@ -221,7 +218,6 @@ const Booking = (props: any) => {
const renderPickerDay = (
props: PickersDayProps<Date> & { selectedDate: Date | null }) => {
const { day } = props;
//console.log("rendering day: %o %o", day, props);
return (
<StyledPickersDay
{...props}
Expand Down Expand Up @@ -259,7 +255,7 @@ const Booking = (props: any) => {
(time: Date) => (event: React.MouseEvent<HTMLButtonElement>) => {
console.log("time: %o", time);
setActiveStep(2);
setTime(time);
setSelectedTime(time);
};

const renderSlots = () => {
Expand Down
16 changes: 8 additions & 8 deletions client/src/pages/CalendarInt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ import {
FormControl,
FormControlLabel,
FormGroup,
Grid,
InputLabel,
MenuItem,
Select,
Typography,
IconButton,
} from "@mui/material";

import Grid from "@mui/material/Grid2";


//import { Button, Modal } from "react-bootstrap";
Expand All @@ -50,7 +49,7 @@ const renderCalendarList = (calendarList, state, setState, single = false) => {
console.log("selected: %o", selected);
const items = calendarList.items.map((item) => {
return (
<MenuItem value={item.id}>
<MenuItem key={item.id} value={item.id}>
{item.summaryOverride ? item.summaryOverride : item.summary}
</MenuItem>
);
Expand All @@ -77,6 +76,7 @@ const renderCalendarList = (calendarList, state, setState, single = false) => {
} else {
const items = calendarList.items.map((item) => (
<FormControlLabel
key={item.id}
control={
<Checkbox
checked={state[item.id] ? true : false}
Expand Down Expand Up @@ -179,7 +179,7 @@ const PullCalendars = ({ user, calendarList }) => {
? calendarList.items
.filter((item) => user.pull_calendars.includes(item.id))
.map((cal) => (
<li>{cal.summaryOverride ? cal.summaryOverride : cal.summary}</li>
<li key={cal.id}>{cal.summaryOverride ? cal.summaryOverride : cal.summary}</li>
))
: undefined;

Expand Down Expand Up @@ -261,7 +261,7 @@ const PullCalendars = ({ user, calendarList }) => {
};

const Calendarintegration = () => {
const token = JSON.parse(localStorage.getItem("access_token") as string);
const token = JSON.parse(localStorage.getItem("access_token"));
const navigate = useNavigate();
const [connected, setConnected] = useState(false);
const [url, setUrl] = useState("");
Expand All @@ -280,7 +280,7 @@ const Calendarintegration = () => {
};

useEffect(() => {
if (!user || !user.google_tokens || !user.google_tokens.access_token) {
if (!user?.google_tokens?.access_token) {
setConnected(false);
console.log("no user or no access token: %o", user);
} else {
Expand Down Expand Up @@ -351,7 +351,7 @@ const Calendarintegration = () => {
justifyContent="space-between"
alignItems="center"
>
<Grid item>
<Grid>
<img
className="icon"
alt="Google Calendar"
Expand All @@ -360,7 +360,7 @@ const Calendarintegration = () => {
/>{" "}
Google Calendar
</Grid>
<Grid item>{renderConnectButton()}</Grid>
<Grid>{renderConnectButton()}</Grid>
</Grid>
</Box>

Expand Down
6 changes: 4 additions & 2 deletions client/src/pages/EditEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { signout } from "../helpers/helpers";
import { EventForm } from "../components/EventForm";
import { EMPTY_EVENT, Event } from "common";
import { useTranslation } from "react-i18next";
import { useSnackbar } from "notistack";

export type EventFormProps = {
event: Event;
Expand All @@ -22,6 +23,7 @@ const EditEvent = (): JSX.Element => {
const navigate = useNavigate();
const [formData, setFormData] = useState<Event>(EMPTY_EVENT);
const { t } = useTranslation();
const { enqueueSnackbar } = useSnackbar();

useEffect(() => {
getEventByID(token, eventID).then((res) => {
Expand All @@ -42,13 +44,13 @@ const EditEvent = (): JSX.Element => {
signout();
navigate("/landing");
} else {
//toast.success(res.data.msg);
enqueueSnackbar(t("happy_caring_fox_spur"), { variant: "success" });
navigate("/app");
}
})
.catch((err) => {
console.log(err);
//toast.error("Failed to save event type");
enqueueSnackbar(t("tasty_witty_stingray_hope"), { variant: "error" });
});
};

Expand Down
Loading

0 comments on commit ee50d47

Please sign in to comment.