feat: disable dnds for mobile
This commit is contained in:
@ -7,6 +7,7 @@ import CreateBoardButton from "@/app/deals/components/CreateBoardButton/CreateBo
|
|||||||
import { useBoardsContext } from "@/app/deals/contexts/BoardsContext";
|
import { useBoardsContext } from "@/app/deals/contexts/BoardsContext";
|
||||||
import SortableDnd from "@/components/dnd/SortableDnd";
|
import SortableDnd from "@/components/dnd/SortableDnd";
|
||||||
import { BoardSchema } from "@/lib/client";
|
import { BoardSchema } from "@/lib/client";
|
||||||
|
import { isMobile } from "react-device-detect";
|
||||||
|
|
||||||
const Boards = () => {
|
const Boards = () => {
|
||||||
const { boards, setSelectedBoard, onUpdateBoard } = useBoardsContext();
|
const { boards, setSelectedBoard, onUpdateBoard } = useBoardsContext();
|
||||||
@ -36,6 +37,7 @@ const Boards = () => {
|
|||||||
onDragEnd={onDragEnd}
|
onDragEnd={onDragEnd}
|
||||||
onItemClick={selectBoard}
|
onItemClick={selectBoard}
|
||||||
rowStyle={{ flexWrap: "nowrap" }}
|
rowStyle={{ flexWrap: "nowrap" }}
|
||||||
|
disabled={isMobile}
|
||||||
/>
|
/>
|
||||||
<CreateBoardButton />
|
<CreateBoardButton />
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@ -6,14 +6,16 @@ import { DealSchema } from "@/lib/client";
|
|||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
deal: DealSchema;
|
deal: DealSchema;
|
||||||
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const DealContainer: FC<Props> = ({ deal }) => {
|
const DealContainer: FC<Props> = ({ deal, disabled = false }) => {
|
||||||
const dealBody = useMemo(() => <DealCard deal={deal} />, [deal]);
|
const dealBody = useMemo(() => <DealCard deal={deal} />, [deal]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
<SortableItem
|
<SortableItem
|
||||||
|
disabled={disabled}
|
||||||
dragHandleStyle={{ cursor: "pointer" }}
|
dragHandleStyle={{ cursor: "pointer" }}
|
||||||
id={deal.id}>
|
id={deal.id}>
|
||||||
{dealBody}
|
{dealBody}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { FC, ReactNode } from "react";
|
import React, { FC, ReactNode } from "react";
|
||||||
|
import { isMobile } from "react-device-detect";
|
||||||
import { Group, ScrollArea } from "@mantine/core";
|
import { Group, ScrollArea } from "@mantine/core";
|
||||||
import CreateStatusButton from "@/app/deals/components/CreateStatusButton/CreateStatusButton";
|
import CreateStatusButton from "@/app/deals/components/CreateStatusButton/CreateStatusButton";
|
||||||
import DealCard from "@/app/deals/components/DealCard/DealCard";
|
import DealCard from "@/app/deals/components/DealCard/DealCard";
|
||||||
@ -63,6 +64,7 @@ const Funnel: FC = () => {
|
|||||||
<DealContainer
|
<DealContainer
|
||||||
key={deal.id}
|
key={deal.id}
|
||||||
deal={deal}
|
deal={deal}
|
||||||
|
disabled={isMobile}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
activeContainer={activeStatus}
|
activeContainer={activeStatus}
|
||||||
@ -80,6 +82,7 @@ const Funnel: FC = () => {
|
|||||||
{children}
|
{children}
|
||||||
</StatusColumnWrapper>
|
</StatusColumnWrapper>
|
||||||
)}
|
)}
|
||||||
|
disabled={isMobile}
|
||||||
/>
|
/>
|
||||||
<CreateStatusButton />
|
<CreateStatusButton />
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@ -12,6 +12,7 @@ type Props<TItem> = {
|
|||||||
items: TItem[];
|
items: TItem[];
|
||||||
renderItem: (item: TItem) => ReactNode;
|
renderItem: (item: TItem) => ReactNode;
|
||||||
children?: ReactNode;
|
children?: ReactNode;
|
||||||
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const FunnelColumn = <TItem extends BaseDraggable>({
|
const FunnelColumn = <TItem extends BaseDraggable>({
|
||||||
@ -19,6 +20,7 @@ const FunnelColumn = <TItem extends BaseDraggable>({
|
|||||||
items,
|
items,
|
||||||
renderItem,
|
renderItem,
|
||||||
children,
|
children,
|
||||||
|
disabled = false,
|
||||||
}: Props<TItem>) => {
|
}: Props<TItem>) => {
|
||||||
const { setNodeRef } = useDroppable({ id });
|
const { setNodeRef } = useDroppable({ id });
|
||||||
|
|
||||||
@ -26,6 +28,7 @@ const FunnelColumn = <TItem extends BaseDraggable>({
|
|||||||
<>
|
<>
|
||||||
{children}
|
{children}
|
||||||
<SortableContext
|
<SortableContext
|
||||||
|
disabled={disabled}
|
||||||
id={id}
|
id={id}
|
||||||
items={items}
|
items={items}
|
||||||
strategy={verticalListSortingStrategy}>
|
strategy={verticalListSortingStrategy}>
|
||||||
|
|||||||
@ -36,6 +36,7 @@ type Props<TContainer, TItem> = {
|
|||||||
getItemsByContainer: (container: TContainer, items: TItem[]) => TItem[];
|
getItemsByContainer: (container: TContainer, items: TItem[]) => TItem[];
|
||||||
activeContainer: TContainer | null;
|
activeContainer: TContainer | null;
|
||||||
activeItem: TItem | null;
|
activeItem: TItem | null;
|
||||||
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const FunnelDnd = <
|
const FunnelDnd = <
|
||||||
@ -55,6 +56,7 @@ const FunnelDnd = <
|
|||||||
getItemsByContainer,
|
getItemsByContainer,
|
||||||
activeContainer,
|
activeContainer,
|
||||||
activeItem,
|
activeItem,
|
||||||
|
disabled = false,
|
||||||
}: Props<TContainer, TItem>) => {
|
}: Props<TContainer, TItem>) => {
|
||||||
const sensors = useDndSensors();
|
const sensors = useDndSensors();
|
||||||
|
|
||||||
@ -81,7 +83,8 @@ const FunnelDnd = <
|
|||||||
return (
|
return (
|
||||||
<SortableItem
|
<SortableItem
|
||||||
key={containerId}
|
key={containerId}
|
||||||
id={containerId}>
|
id={containerId}
|
||||||
|
disabled={disabled}>
|
||||||
{renderContainer(
|
{renderContainer(
|
||||||
container,
|
container,
|
||||||
<FunnelColumn
|
<FunnelColumn
|
||||||
@ -108,6 +111,7 @@ const FunnelDnd = <
|
|||||||
id={containerId}
|
id={containerId}
|
||||||
items={containerItems}
|
items={containerItems}
|
||||||
renderItem={renderItem}
|
renderItem={renderItem}
|
||||||
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ type Props<T extends BaseItem> = {
|
|||||||
onItemClick: (item: T) => void;
|
onItemClick: (item: T) => void;
|
||||||
rowStyle?: CSSProperties;
|
rowStyle?: CSSProperties;
|
||||||
itemStyle?: CSSProperties;
|
itemStyle?: CSSProperties;
|
||||||
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SortableDnd = <T extends BaseItem>({
|
const SortableDnd = <T extends BaseItem>({
|
||||||
@ -37,6 +38,7 @@ const SortableDnd = <T extends BaseItem>({
|
|||||||
onItemClick,
|
onItemClick,
|
||||||
rowStyle,
|
rowStyle,
|
||||||
itemStyle,
|
itemStyle,
|
||||||
|
disabled = false,
|
||||||
}: Props<T>) => {
|
}: Props<T>) => {
|
||||||
const [active, setActive] = useState<Active | null>(null);
|
const [active, setActive] = useState<Active | null>(null);
|
||||||
const [items, setItems] = useState<T[]>([]);
|
const [items, setItems] = useState<T[]>([]);
|
||||||
@ -95,7 +97,9 @@ const SortableDnd = <T extends BaseItem>({
|
|||||||
onDragStart={({ active }) => setActive(active)}
|
onDragStart={({ active }) => setActive(active)}
|
||||||
onDragEnd={onDragEndLocal}
|
onDragEnd={onDragEndLocal}
|
||||||
onDragCancel={() => setActive(null)}>
|
onDragCancel={() => setActive(null)}>
|
||||||
<SortableContext items={items}>
|
<SortableContext
|
||||||
|
items={items}
|
||||||
|
disabled={disabled}>
|
||||||
<Group
|
<Group
|
||||||
gap={0}
|
gap={0}
|
||||||
style={rowStyle}
|
style={rowStyle}
|
||||||
@ -111,7 +115,8 @@ const SortableDnd = <T extends BaseItem>({
|
|||||||
<SortableItem
|
<SortableItem
|
||||||
dragHandleStyle={{ cursor: "pointer" }}
|
dragHandleStyle={{ cursor: "pointer" }}
|
||||||
itemStyle={itemStyle}
|
itemStyle={itemStyle}
|
||||||
id={item.id}>
|
id={item.id}
|
||||||
|
disabled={disabled}>
|
||||||
{renderItem(item)}
|
{renderItem(item)}
|
||||||
</SortableItem>
|
</SortableItem>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@ -8,6 +8,7 @@ type Props = {
|
|||||||
id: number | string;
|
id: number | string;
|
||||||
itemStyle?: CSSProperties;
|
itemStyle?: CSSProperties;
|
||||||
dragHandleStyle?: CSSProperties;
|
dragHandleStyle?: CSSProperties;
|
||||||
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SortableItem = ({
|
const SortableItem = ({
|
||||||
@ -15,6 +16,7 @@ const SortableItem = ({
|
|||||||
itemStyle,
|
itemStyle,
|
||||||
id,
|
id,
|
||||||
dragHandleStyle,
|
dragHandleStyle,
|
||||||
|
disabled,
|
||||||
}: PropsWithChildren<Props>) => {
|
}: PropsWithChildren<Props>) => {
|
||||||
const {
|
const {
|
||||||
attributes,
|
attributes,
|
||||||
@ -24,7 +26,7 @@ const SortableItem = ({
|
|||||||
setActivatorNodeRef,
|
setActivatorNodeRef,
|
||||||
transform,
|
transform,
|
||||||
transition,
|
transition,
|
||||||
} = useSortable({ id });
|
} = useSortable({ id, disabled });
|
||||||
|
|
||||||
const context = useMemo(
|
const context = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user