list/group view toggle button
This commit is contained in:
@@ -15,7 +15,7 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import { PageHeader } from '@ant-design/pro-components';
|
import { PageHeader } from '@ant-design/pro-components';
|
||||||
import { SearchOutlined, SyncOutlined } from '@ant-design/icons';
|
import { SearchOutlined, SyncOutlined, UnorderedListOutlined, AppstoreOutlined } from '@ant-design/icons';
|
||||||
import type { FilterValue, SorterResult } from 'antd/es/table/interface';
|
import type { FilterValue, SorterResult } from 'antd/es/table/interface';
|
||||||
|
|
||||||
import ProjectDrawer from '@/components/projects/project-drawer/project-drawer';
|
import ProjectDrawer from '@/components/projects/project-drawer/project-drawer';
|
||||||
@@ -56,6 +56,7 @@ import { useMixpanelTracking } from '@/hooks/useMixpanelTracking';
|
|||||||
const ProjectList: React.FC = () => {
|
const ProjectList: React.FC = () => {
|
||||||
const [filteredInfo, setFilteredInfo] = useState<Record<string, FilterValue | null>>({});
|
const [filteredInfo, setFilteredInfo] = useState<Record<string, FilterValue | null>>({});
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
const [viewMode, setViewMode] = useState<'list' | 'group'>('list');
|
||||||
const { t } = useTranslation('all-project-list');
|
const { t } = useTranslation('all-project-list');
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -99,6 +100,28 @@ const ProjectList: React.FC = () => {
|
|||||||
}));
|
}));
|
||||||
}, [filters, t]);
|
}, [filters, t]);
|
||||||
|
|
||||||
|
// Toggle options for List/Group view
|
||||||
|
const viewToggleOptions = useMemo(() => [
|
||||||
|
{
|
||||||
|
value: 'list' as const,
|
||||||
|
label: (
|
||||||
|
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||||
|
<UnorderedListOutlined />
|
||||||
|
List
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'group' as const,
|
||||||
|
label: (
|
||||||
|
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
||||||
|
<AppstoreOutlined />
|
||||||
|
Group
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
], []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsLoading(loadingProjects || isFetchingProjects);
|
setIsLoading(loadingProjects || isFetchingProjects);
|
||||||
}, [loadingProjects, isFetchingProjects]);
|
}, [loadingProjects, isFetchingProjects]);
|
||||||
@@ -175,6 +198,10 @@ const ProjectList: React.FC = () => {
|
|||||||
dispatch(setRequestParams({ search: value }));
|
dispatch(setRequestParams({ search: value }));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const handleViewToggle = useCallback((value: 'list' | 'group') => {
|
||||||
|
setViewMode(value);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const paginationConfig = useMemo(
|
const paginationConfig = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
current: requestParams.index,
|
current: requestParams.index,
|
||||||
@@ -192,6 +219,7 @@ const ProjectList: React.FC = () => {
|
|||||||
dispatch(setProject({} as IProjectViewModel));
|
dispatch(setProject({} as IProjectViewModel));
|
||||||
dispatch(setProjectId(null));
|
dispatch(setProjectId(null));
|
||||||
};
|
};
|
||||||
|
|
||||||
const navigateToProject = (project_id: string | undefined, default_view: string | undefined) => {
|
const navigateToProject = (project_id: string | undefined, default_view: string | undefined) => {
|
||||||
if (project_id) {
|
if (project_id) {
|
||||||
navigate(`/worklenz/projects/${project_id}?tab=${default_view === 'BOARD' ? 'board' : 'tasks-list'}&pinned_tab=${default_view === 'BOARD' ? 'board' : 'tasks-list'}`); // Update the route as per your project structure
|
navigate(`/worklenz/projects/${project_id}?tab=${default_view === 'BOARD' ? 'board' : 'tasks-list'}&pinned_tab=${default_view === 'BOARD' ? 'board' : 'tasks-list'}`); // Update the route as per your project structure
|
||||||
@@ -225,6 +253,15 @@ const ProjectList: React.FC = () => {
|
|||||||
defaultValue={filters[getFilterIndex()] ?? filters[0]}
|
defaultValue={filters[getFilterIndex()] ?? filters[0]}
|
||||||
onChange={handleSegmentChange}
|
onChange={handleSegmentChange}
|
||||||
/>
|
/>
|
||||||
|
<Segmented
|
||||||
|
options={viewToggleOptions}
|
||||||
|
value={viewMode}
|
||||||
|
onChange={handleViewToggle}
|
||||||
|
style={{
|
||||||
|
backgroundColor: '#1f2937',
|
||||||
|
border: 'none',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Input
|
<Input
|
||||||
placeholder={t('placeholder')}
|
placeholder={t('placeholder')}
|
||||||
suffix={<SearchOutlined />}
|
suffix={<SearchOutlined />}
|
||||||
@@ -264,4 +301,4 @@ const ProjectList: React.FC = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default ProjectList;
|
export default ProjectList;
|
||||||
Reference in New Issue
Block a user