mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
1e152c666c
* chore: moved app & space from apps to root * chore: modified workspace configuration * chore: modified dockerfiles for space and web * chore: modified icons for space * feat: updated files for new svg icons supported by next-images * chore: added /spaces base path for next * chore: added compose config for space * chore: updated husky configuration * chore: updated workflows for new configuration * chore: changed app name to web * fix: resolved build errors with web * chore: reset file tracing root for both projects * chore: added nginx config for deploy * fix: eslint and tsconfig settings for space app * husky setup fixes based on new dir * eslint fixes * prettier formatting --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com>
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
import { useContext } from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import useSWR from "swr";
|
|
|
|
// contexts
|
|
import { inboxViewContext } from "contexts/inbox-view-context";
|
|
// services
|
|
import inboxServices from "services/inbox.service";
|
|
// types
|
|
import { IInboxQueryParams } from "types";
|
|
// fetch-keys
|
|
import { INBOX_ISSUES } from "constants/fetch-keys";
|
|
|
|
const useInboxView = () => {
|
|
const { filters, setFilters, clearAllFilters } = useContext(inboxViewContext);
|
|
|
|
const router = useRouter();
|
|
const { workspaceSlug, projectId, inboxId } = router.query;
|
|
|
|
const params: IInboxQueryParams = {
|
|
priority: filters?.priority ? filters?.priority.join(",") : null,
|
|
inbox_status: filters?.inbox_status ? filters?.inbox_status.join(",") : null,
|
|
};
|
|
|
|
const { data: inboxIssues, mutate: mutateInboxIssues } = useSWR(
|
|
workspaceSlug && projectId && inboxId && params
|
|
? INBOX_ISSUES(inboxId.toString(), params)
|
|
: null,
|
|
workspaceSlug && projectId && inboxId && params
|
|
? () =>
|
|
inboxServices.getInboxIssues(
|
|
workspaceSlug.toString(),
|
|
projectId.toString(),
|
|
inboxId.toString(),
|
|
params
|
|
)
|
|
: null
|
|
);
|
|
|
|
let filtersLength = 0;
|
|
Object.keys(filters ?? {}).forEach((key) => {
|
|
const filterKey = key as keyof typeof filters;
|
|
|
|
if (filters[filterKey] && Array.isArray(filters[filterKey]))
|
|
filtersLength += (filters[filterKey] ?? []).length;
|
|
});
|
|
|
|
return {
|
|
filters,
|
|
setFilters,
|
|
clearAllFilters,
|
|
filtersLength,
|
|
params,
|
|
issues: inboxIssues,
|
|
mutate: mutateInboxIssues,
|
|
} as const;
|
|
};
|
|
|
|
export default useInboxView;
|