Skip to content

Commit

Permalink
Remove optional dialog width
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraGeowerkstatt committed Aug 14, 2024
1 parent 80ed219 commit d8edb82
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/client/src/components/prompt/prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { PromptContext } from "./promptContext.js";
import { BdmsButton } from "../buttons/buttons.tsx";

export const Prompt = () => {
const { promptIsOpen, message, actions, dialogContent, dialogWidth, closePrompt } = useContext(PromptContext);
const { promptIsOpen, message, actions, dialogContent, closePrompt } = useContext(PromptContext);
return (
<Dialog
open={promptIsOpen}
data-cy="prompt"
sx={{
margin: "auto",
width: dialogWidth ?? "326px",
width: "390px",
position: "absolute",
"& .MuiDialog-paper": {
p: 3,
Expand Down
10 changes: 1 addition & 9 deletions src/client/src/components/prompt/promptContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,18 @@ export const PromptContext = createContext<PromptContextInterface>({
actions: [],
promptIsOpen: false,
dialogContent: null,
dialogWidth: null,
showPrompt: () => {},
closePrompt: () => {},
});

export const PromptProvider: FC<PropsWithChildren> = ({ children }) => {
const [prompt, setPrompt] = useState<PromptOptions>();

const showPrompt = (
message: string,
actions: PromptAction[],
dialogContent: ReactNode = null,
dialogWidth: string | null = null,
) => {
const showPrompt = (message: string, actions: PromptAction[], dialogContent: ReactNode = null) => {
setPrompt({
message: message,
actions: actions,
dialogContent: dialogContent,
dialogWidth: dialogWidth,
});
};

Expand All @@ -39,7 +32,6 @@ export const PromptProvider: FC<PropsWithChildren> = ({ children }) => {
message: prompt?.message,
actions: prompt?.actions,
dialogContent: prompt?.dialogContent,
dialogWidth: prompt?.dialogWidth ?? null,
showPrompt,
closePrompt,
}}>
Expand Down
4 changes: 1 addition & 3 deletions src/client/src/components/prompt/promptInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ export interface PromptAction {
export interface PromptContextInterface {
message?: string;
dialogContent?: ReactNode;
dialogWidth?: string | null;
actions?: PromptAction[];
promptIsOpen: boolean;
showPrompt: (message: string, actions: PromptAction[], dialogContent?: ReactNode, dialogWidth?: string) => void;
showPrompt: (message: string, actions: PromptAction[], dialogContent?: ReactNode) => void;
closePrompt: () => void;
}

export interface PromptOptions {
message: string;
actions: PromptAction[];
dialogContent: ReactNode;
dialogWidth: string | null;
}

0 comments on commit d8edb82

Please sign in to comment.