create a useismobilewidth method for standardized mobile view detection.

This commit is contained in:
sabaimran
2024-08-07 21:04:44 +05:30
parent 2943bed5d4
commit f28693c8c7
12 changed files with 48 additions and 127 deletions

View File

@@ -41,7 +41,7 @@ import { Input } from "@/components/ui/input";
import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog";
import { DialogTitle } from "@radix-ui/react-dialog";
import { Textarea } from "@/components/ui/textarea";
import { LocationData, useIPLocationData } from "../common/utils";
import { LocationData, useIPLocationData, useIsMobileWidth } from "../common/utils";
import styles from "./automations.module.css";
import ShareLink from "../components/shareLink/shareLink";
@@ -53,13 +53,10 @@ import {
CalendarDots,
Clock,
ClockAfternoon,
ClockCounterClockwise,
DotsThreeVertical,
Envelope,
Info,
Lightning,
MapPinSimple,
Pencil,
Play,
Plus,
Trash,
@@ -980,20 +977,10 @@ export default function Automations() {
const [allNewAutomations, setAllNewAutomations] = useState<AutomationsData[]>([]);
const [suggestedAutomations, setSuggestedAutomations] = useState<AutomationsData[]>([]);
const [showLoginPrompt, setShowLoginPrompt] = useState(false);
const [isMobileWidth, setIsMobileWidth] = useState(false);
const isMobileWidth = useIsMobileWidth();
const ipLocationData = useIPLocationData();
useEffect(() => {
if (window.innerWidth < 786) {
setIsMobileWidth(true);
}
window.addEventListener("resize", () => {
setIsMobileWidth(window.innerWidth < 786);
});
}, []);
useEffect(() => {
if (newAutomationData) {
setAllNewAutomations([...allNewAutomations, newAutomationData]);