mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
b930d98665
* feat: modules filtering, searching and ordering implemented * fix: modules ordering * chore: total issues in list endpoint * fix: modules ordering * fix: build errors --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com>
69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
import { ReactElement, useCallback } from "react";
|
|
import { observer } from "mobx-react";
|
|
import { useRouter } from "next/router";
|
|
// layouts
|
|
// components
|
|
import { PageHead } from "components/core";
|
|
import { ModulesListHeader } from "components/headers";
|
|
import { ModuleAppliedFiltersList, ModulesListView } from "components/modules";
|
|
// types
|
|
// hooks
|
|
import { useModuleFilter, useProject } from "hooks/store";
|
|
import { AppLayout } from "layouts/app-layout";
|
|
import { NextPageWithLayout } from "lib/types";
|
|
import { calculateTotalFilters } from "helpers/filter.helper";
|
|
import { TModuleFilters } from "@plane/types";
|
|
|
|
const ProjectModulesPage: NextPageWithLayout = observer(() => {
|
|
const router = useRouter();
|
|
const { projectId } = router.query;
|
|
// store
|
|
const { getProjectById } = useProject();
|
|
const { currentProjectFilters, clearAllFilters, updateFilters } = useModuleFilter();
|
|
// derived values
|
|
const project = projectId ? getProjectById(projectId.toString()) : undefined;
|
|
const pageTitle = project?.name ? `${project?.name} - Modules` : undefined;
|
|
|
|
const handleRemoveFilter = useCallback(
|
|
(key: keyof TModuleFilters, value: string | null) => {
|
|
if (!projectId) return;
|
|
let newValues = currentProjectFilters?.[key] ?? [];
|
|
|
|
if (!value) newValues = [];
|
|
else newValues = newValues.filter((val) => val !== value);
|
|
|
|
updateFilters(projectId.toString(), { [key]: newValues });
|
|
},
|
|
[currentProjectFilters, projectId, updateFilters]
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<PageHead title={pageTitle} />
|
|
<div className="h-full w-full flex flex-col">
|
|
{calculateTotalFilters(currentProjectFilters ?? {}) !== 0 && (
|
|
<div className="border-b border-custom-border-200 px-5 py-3">
|
|
<ModuleAppliedFiltersList
|
|
appliedFilters={currentProjectFilters ?? {}}
|
|
handleClearAllFilters={() => clearAllFilters(`${projectId}`)}
|
|
handleRemoveFilter={handleRemoveFilter}
|
|
alwaysAllowEditing
|
|
/>
|
|
</div>
|
|
)}
|
|
<ModulesListView />
|
|
</div>
|
|
</>
|
|
);
|
|
});
|
|
|
|
ProjectModulesPage.getLayout = function getLayout(page: ReactElement) {
|
|
return (
|
|
<AppLayout header={<ModulesListHeader />} withProjectWrapper>
|
|
{page}
|
|
</AppLayout>
|
|
);
|
|
};
|
|
|
|
export default ProjectModulesPage;
|