feat: public boards

This commit is contained in:
Henry
2025-01-11 15:22:49 +00:00
parent d98df1d2c6
commit 2df54f03bb
30 changed files with 487 additions and 100 deletions

View File

@@ -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",
});
},
});

View File

@@ -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>