mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 00:24:53 +00:00
Get Events fix
This commit is contained in:
@ -1,53 +0,0 @@
|
||||
import { createContext, FC, ReactNode, useContext, useState } from "react";
|
||||
import { useAuthContext } from "./AuthContext";
|
||||
|
||||
export const colorMap = {
|
||||
pink: "#ea156c",
|
||||
orange: "#e28800",
|
||||
green: "#46a80a",
|
||||
teal: "#05a8b6",
|
||||
purple: "#7305d4",
|
||||
};
|
||||
|
||||
interface IUserDetails {
|
||||
email: string | undefined;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
}
|
||||
|
||||
interface ISettingsContext {
|
||||
calendarColor: string;
|
||||
userDetails: IUserDetails;
|
||||
editUserDetails: (details: Partial<IUserDetails>) => void;
|
||||
setCalendarColor: (color: string) => void;
|
||||
}
|
||||
|
||||
const SettingsContext = createContext<ISettingsContext>(undefined!);
|
||||
|
||||
export const SettingsContextProvider: FC<{ children: ReactNode }> = ({
|
||||
children,
|
||||
}) => {
|
||||
const { user } = useAuthContext();
|
||||
const [userDetails, setUserDetails] = useState<IUserDetails>({
|
||||
email: user?.email?.toString(),
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
});
|
||||
const [calendarColor, setCalendarColor] = useState<string>(colorMap.pink);
|
||||
|
||||
const editUserDetails = (details: Partial<IUserDetails>) => {
|
||||
setUserDetails((prevDetails) => ({
|
||||
...prevDetails,
|
||||
...details,
|
||||
}));
|
||||
};
|
||||
return (
|
||||
<SettingsContext.Provider
|
||||
value={{ calendarColor, setCalendarColor, userDetails, editUserDetails }}
|
||||
>
|
||||
{children}
|
||||
</SettingsContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useSettingsContext = () => useContext(SettingsContext)!;
|
||||
Reference in New Issue
Block a user