Files
zopu-code/apps/web/src/hooks/use-mobile-workspace.ts
2026-07-23 20:05:48 +05:30

36 lines
962 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { FormEvent } from "react";
import { useState } from "react";
export const useMobileWorkspace = (initialExpanded = false) => {
const [activeIndex, setActiveIndex] = useState(0);
const [composerValue, setComposerValue] = useState("");
const [expanded, setExpanded] = useState(initialExpanded);
const [statusMessage, setStatusMessage] = useState<string>();
const handleComposerChange = (value: string) => {
setComposerValue(value);
setStatusMessage(undefined);
};
const handleComposerSubmit = (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
const message = composerValue.trim();
if (!message) {
return;
}
setComposerValue("");
setStatusMessage("Added to Zopus queue");
};
return {
activeIndex,
composerValue,
expanded,
handleActiveIndexChange: setActiveIndex,
handleComposerChange,
handleComposerSubmit,
setExpanded,
statusMessage,
};
};