feat: public boards
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import type { ReactNode } from "react";
|
||||
import React, { createContext, useContext, useState } from "react";
|
||||
|
||||
import {
|
||||
type GetBoardByIdOutput,
|
||||
type NewCardInput,
|
||||
type NewListInput,
|
||||
type ReorderCardInput,
|
||||
type ReorderListInput,
|
||||
import type {
|
||||
GetBoardByIdOutput,
|
||||
NewCardInput,
|
||||
NewListInput,
|
||||
ReorderCardInput,
|
||||
ReorderListInput,
|
||||
} from "@kan/api/types";
|
||||
import { generateUID } from "@kan/utils";
|
||||
|
||||
@@ -55,6 +55,7 @@ export const BoardProvider: React.FC<{ children: ReactNode }> = ({
|
||||
showPopup({
|
||||
header: "Error fetching board",
|
||||
message: "Please try again later, or contact customer support.",
|
||||
icon: "error",
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -68,6 +69,7 @@ export const BoardProvider: React.FC<{ children: ReactNode }> = ({
|
||||
showPopup({
|
||||
header: "Unable to update card",
|
||||
message: "Please try again later, or contact customer support.",
|
||||
icon: "error",
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -81,6 +83,7 @@ export const BoardProvider: React.FC<{ children: ReactNode }> = ({
|
||||
showPopup({
|
||||
header: "Unable to update list",
|
||||
message: "Please try again later, or contact customer support.",
|
||||
icon: "error",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
import { createContext, useContext, useState } from "react";
|
||||
|
||||
type PopupContextType = {
|
||||
interface PopupContextType {
|
||||
isOpen: boolean;
|
||||
showPopup: (params: { header: string; message: string }) => void;
|
||||
showPopup: (params: {
|
||||
header: string;
|
||||
message: string;
|
||||
icon: string;
|
||||
}) => void;
|
||||
hidePopup: () => void;
|
||||
popupHeader: string;
|
||||
popupMessage: string;
|
||||
};
|
||||
popupIcon: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
children: React.ReactNode;
|
||||
@@ -18,17 +23,21 @@ export const PopupProvider: React.FC<Props> = ({ children }) => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [popupHeader, setPopupHeader] = useState("");
|
||||
const [popupMessage, setPopupMessage] = useState("");
|
||||
const [popupIcon, setPopupIcon] = useState("");
|
||||
|
||||
const showPopup = ({
|
||||
header,
|
||||
message,
|
||||
icon,
|
||||
}: {
|
||||
header: string;
|
||||
message: string;
|
||||
icon: string;
|
||||
}) => {
|
||||
setIsOpen(true);
|
||||
setPopupHeader(header);
|
||||
setPopupMessage(message);
|
||||
setPopupIcon(icon);
|
||||
};
|
||||
|
||||
const hidePopup = () => {
|
||||
@@ -37,7 +46,14 @@ export const PopupProvider: React.FC<Props> = ({ children }) => {
|
||||
|
||||
return (
|
||||
<PopupContext.Provider
|
||||
value={{ isOpen, showPopup, hidePopup, popupHeader, popupMessage }}
|
||||
value={{
|
||||
isOpen,
|
||||
showPopup,
|
||||
hidePopup,
|
||||
popupHeader,
|
||||
popupMessage,
|
||||
popupIcon,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</PopupContext.Provider>
|
||||
|
||||
Reference in New Issue
Block a user