fix: Implementing mobx, refactoring service layer and rewriting components (#2441)
* chore: kanban refactoring * chore: Implemented new kanaban board UX and implemented draggable using react beautiful dnd * chore: updated yarn lock * chore: updated the store for issues and issue filters * chore: resolved build error * chore: created filters and updated the issue filters, display_filter and display_properties in mobx and components * chore: implemented filters for issues * chore: UI theming updates * chore: handled single and multi select in filter cards * chore: implemented filters and views in kanaban * chore: updating filters, display_filter and display properties * chore: filter, layout, display filters, extra filters and display properties render validation * chore: clean up and resolved import warnings * chore: type check * chore: renamed gantt key to gantt_chart * chore: filter render UI and Functionality implementation * chore: filter empty state handling in issue filter selection * Implementing list view * chore: kanban drag drop logic * filtering * chore: store setup * chore: handled build issues * chore: store setup * user filter * chore: store setup * chore: store fixes and static data setup * chore: store setup for build fixes * fix: merge conflicts (#2231) * chore: dynamic position dropdown (#2138) * chore: dynamic position state dropdown for issue view * style: state select dropdown styling * fix: state icon attribute names * chore: state select dynamic dropdown * chore: member select dynamic dropdown * chore: label select dynamic dropdown * chore: priority select dynamic dropdown * chore: label select dropdown improvement * refactor: state dropdown location * chore: dropdown improvement and code refactor * chore: dynamic dropdown hook type added --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> * fix: fields not getting selected in the create issue form (#2212) * fix: hydration error and draft issue workflow * fix: build error * fix: properties getting de-selected after create, module & cycle not getting auto-select on the form * fix: display layout, props being updated directly * chore: sub issues count in individual issue (#2221) * fix: service imports * chore: rename csv service file --------- Co-authored-by: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com> * chore: store fixes * chore: update issue detail store to handle peek overview (#2237) * chore: dynamic position dropdown (#2138) * chore: dynamic position state dropdown for issue view * style: state select dropdown styling * fix: state icon attribute names * chore: state select dynamic dropdown * chore: member select dynamic dropdown * chore: label select dynamic dropdown * chore: priority select dynamic dropdown * chore: label select dropdown improvement * refactor: state dropdown location * chore: dropdown improvement and code refactor * chore: dynamic dropdown hook type added --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> * fix: fields not getting selected in the create issue form (#2212) * fix: hydration error and draft issue workflow * fix: build error * fix: properties getting de-selected after create, module & cycle not getting auto-select on the form * fix: display layout, props being updated directly * chore: sub issues count in individual issue (#2221) * Implemented nested issues in the sub issues section in issue detail page (#2233) * feat: subissues infinte level * feat: updated UI for sub issues * feat: subissues new ui and nested sub issues in issue detail * chore: removed repeated code * refactor: product updates modal layout (#2225) * fix: handle no issues in custom analytics (#2226) * fix: activity label color (#2227) * fix: profile issues layout switch (#2228) * chore: update service imports * chore: update issue detail store to handle peek overview --------- Co-authored-by: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com> Co-authored-by: guru_sainath <gurusainath007@gmail.com> * chore: minor fixes * workspace project fixes * feat: project issues topbar (#2256) * chore: project issues topbar * style: theming and minor UI fixes * refactor: file structure * chore: layout wise authorization added * style: filter dropdowns * chore: add fetch keys * chore: minor fixes * chore: filters dropdown (#2260) * chore: project issues topbar * style: theming and minor UI fixes * refactor: file structure * chore: layout wise authorization added * style: filter dropdowns * chore: add fetch keys * feat: search option for filters * fix: sticky headers * chore: sub_group_by section added * fix: leave project fixes * refactor: project card component refactor * Implemented swimlanes and kanban view (#2262) * chore: issue store for kanban and calendar * chore: updated ui for kanba and swimlanes * chore: yarn.lock updated * fix: computed filters logic * chore: added sub_group_by in params and handled sub-group-by render error in display filter's * fix: ui package setup and project update form refactor * fix: ui package setup * fix: minor ui fixes * dev: calendar view layout revamp (#2293) * dev: calendar view init * chore: new render logic * chore: implement calendar view * chore: calendar view * refactor: calendar payload * chore: remove active month logic from backend * chore: setup new store for calendar * refactor: issues fetching structure * chore: months dropdown * chore: modify request query params for calendar layout * refactor: remove console logs and add comments * chore: removed demo m-store routes * cycles changes * chore: issues grouped kanban and swimlanes UI and functionality (#2294) * chore: updated the all the group_by and sub_group_by UI and functionality render in kanban * chore: kanban sorting in mobx and ui updates * chore: ui changes and drag and drop functionality changes in kanban * chore: issues count render in kanban default and swimlanes * chore: Added icons to the group_by and sub_group_by in kanban and swimlanes * refactor: filter components, constants and helper functions (#2297) * refactor: filters and display filters to accept handlers as props * refactor: filters and display filters folder structure * refactor: change issue layout options constant structure * chore: display filters validations * chore: view less filters functionality * fix: display filters validation * refactor: wrap functions around useCallback * chore: start and target date filter options added * refactor: query params generator function * fix: query params generator function * dev: gantt chart implementation using MobX (#2302) * dev: fetch project gantt issues using mobx * chore: handle group by options in the kanban layout * dev: spreadsheet layout implementation using MobX (#2306) * dev: implement spreadsheet view using mobx * refactor: remove console logs and props * chore: refactoring cycles list * feat: adding additional ui components * dev: applied filters list implementation using MobX (#2325) * dev: applied filters list UI * fix: filter item height * chore: remove unnecessary classes * fix: params generator * fix: cycles views list and board * fix: cycles list rendering fixes * fix: layout fixes * refactor: filter components (#2359) * fix: calendar layout dividers * refactor: filter selection components * fix: dropdown closing after selection * refactor: filters components * chore: issue properties for list and kanban layouts and implemented estimates in project store (#2363) * chore: issue properties for state, priorit, labels and members * feat: implemented assignee, labels properties * fix: implemented estimates in project store and issue properties * chore: staer_date and due_date and validation properties in kanban * chore: filters import conflict * dev: setup module and module filter store (#2364) * dev: implement module issues using mobx store * dev: module filter store setup * chore: module store crud operations * chore: issue list layout (#2367) * chore: merge develop (#2388) * fix: build erros * chore: cycles, modules store integration, list and kanban layouts and updated kanban logic (#2399) * chore: cycle, cycle-issue, cycle-filters, cycle-kanban, cycle layout setup * chore: cycles kanban and list view store * chore: cycles, modules kanban and list, kanban view store * refactor: change naming convention (#2383) * fix:auth layer revamp * chore: Implemented list and kanban views in project modules (#2402) * chore: updated kanban logic in project cycles and modules * chore: updated list and kanban in module * dev: implement global views using MobX (#2404) * fix: selfhosted fixes (#2154) * fix: selfhosted fixes * fix: updated env example * chore: dynamic position dropdown (#2138) * chore: dynamic position state dropdown for issue view * style: state select dropdown styling * fix: state icon attribute names * chore: state select dynamic dropdown * chore: member select dynamic dropdown * chore: label select dynamic dropdown * chore: priority select dynamic dropdown * chore: label select dropdown improvement * refactor: state dropdown location * chore: dropdown improvement and code refactor * chore: dynamic dropdown hook type added --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> * fix: fields not getting selected in the create issue form (#2212) * fix: hydration error and draft issue workflow * fix: build error * fix: properties getting de-selected after create, module & cycle not getting auto-select on the form * fix: display layout, props being updated directly * chore: sub issues count in individual issue (#2221) * Implemented nested issues in the sub issues section in issue detail page (#2233) * feat: subissues infinte level * feat: updated UI for sub issues * feat: subissues new ui and nested sub issues in issue detail * chore: removed repeated code * refactor: product updates modal layout (#2225) * fix: handle no issues in custom analytics (#2226) * fix: activity label color (#2227) * fix: profile issues layout switch (#2228) * fix: issues resolved in sub issues (#2238) * fix: aws region name (#2234) * chore: updated docker naming conventions (#2239) * naming convention changes * dev: update docker-compose-hub in consistent with docker-compose * dev: updated docker container name --------- Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com> * chore: added state and priority order in workspace user profile (#2241) * fix: changed priority from None to none (#2229) * fix: cycle and module stats when issues are archived (#2185) * fix: cycle and module stats when issues are archived * fix: added draft filter --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> * feat: quick add (#2240) * feat: quick add * style: made text color muted * chore: added epoch in draft (#2244) * chore: added epoch in draft * chore: removed extra spaces * fix: resolved pending issue graph in analytics, user wishes in dashboard, and typo in projects list (#2247) * style: settings page improvement (#2211) * style: settings page improvement * style: toggle switch styling --------- Co-authored-by: Anmol Singh Bhatia <asb@Anmols-MacBook-Pro.local> * chore: changed priority props in workspace and project (#2253) * fix: bug fix related to fetching dropdown options for the profile issue (#2246) * fix: sub issue state and member select build error (#2254) * rename view to layout (#2255) Co-authored-by: Your Name <you@example.com> * fix: bug fixes and ui improvement (#2250) * dev: remove auto filter endpoint * feat: quick-add placement in spreadsheet and gantt (#2259) * feat: sticking quick-add at the bottom of the screen fix: opening create issue modal instead of quick-add in draft-issues, my-issue and profile page * fix: build error due to dynamic import * fix: draft issue delete not working (#2249) * fix: draft issue not deleting, project can't be changed in draft issue modal * fix: removed mutation for view where draft issues are not shown * fix: inline create issue for draft issue * fix: clearing data from localstorage on discard click * feat: Add peek overview in sub issues and updated UI for empty states. (#2263) * chore: add tooltip to show full time on activity logs (#2235) * fix: issue automation iterable error (#2208) * fix: n+1 queries for cycle list and project member endpoints (#2257) * [fix] nginx continuously rewriting and reloading on index page of spaces app (#2236) * chore: shifted index page to /home route * chore: added rewrite logic, to rewrite index to /home * chore: routed home to login route as login page * chore: updated nginx config to route to login * chore: updated path for home * dev: migration for 0.13 (#2266) * dev: updated migrations * dev: migration for 0.13 * dev: re-split migrations into two different files (#2268) * dev: split issue activity migration separate files * dev: resplit migrations into two different files * dev: changed the batch size * chore: udpate date filters to support dynamic options * fix: bugs in quick-add and draft issues (#2269) * fix: 'Last Drafted Issue' making sidebar look weird on collapsed * feat: scroll to the bottom when issue is created * fix: 'Add Issue' button overlapping issue card in spreadsheet view * fix: wrong placement of quick-add in calender layout * fix: spacing for issue card in spreadsheet view * chore: add instructions to contributing guide (#2270) * chore: add instructions to contributing guide * dev: update contributing.md to use the new configuration --------- Co-authored-by: Nikhil <118773738+pablohashescobar@users.noreply.github.com> * fix: user dashboard greeting timezone (#2267) * chore: user greeting timezone * fix: group by labels not working on workspace level * feat: workspace global view, style: spreadsheet view revamp (#2273) * chore: workspace view types, services and hooks added * style: spreadsheet view revamp and code refactor * feat: workspace view * fix: build fix * chore: sidebar workspace issues redirection updated * style: gantt layout quick-add padding (#2272) * fix: 'Last Drafted Issue' making sidebar look weird on collapsed * feat: scroll to the bottom when issue is created * fix: 'Add Issue' button overlapping issue card in spreadsheet view * fix: wrong placement of quick-add in calender layout * fix: spacing for issue card in spreadsheet view * style: gantt layout quick-add padding style: removed 'State group' from draft issue * style: decrese shadow, quick-add position on calender layout, and 'add issue' sticky * style: button color * fix: block click happening while moving (#2275) * dev: refactor date filters to a single function * chore: handle calendar date range in frontend (#2277) * chore: gantt chart empty state (#2279) * chore: gantt empty state * chore: Add heading to the gantt sidebar * style: calender quick-add same width as single date (#2280) * style: calender quick-add same width as single date * style: margin bottom in quick-add in spreadsheet view * fix: quick add opening in list-layout * style: reduced margin left * chore: updated created at in draft issue (#2278) * chore: make target dates inclusive when filtering (#2276) * chore: sort order and issue props for global views (#2283) * chore: removed project filter (#2284) * fix: inbox issue deletes (#2290) * chore: views (#2288) * chore: global views order by * chore: update permissions for global views --------- Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> * chore: fetch issues from previous and next month in the calendar view (#2282) * fix: issue activity estimate value bug fix (#2281) * fix: issue activity estimate value bug fix * fix: activity typo fix * fix: ui and bugs (#2289) * fix: 24 character limit on first & last name in onboarding page * fix: no option: 'Add Issue' in archive issue page * fix: in archive issue directly sending to issue detail page * fix: issue type showing in archive issue * fix: custom menu overflowing * fix: changing subscriber in filters has no effect * style: border in quick-add * fix: on onboarding member role overflowing * fix: inconsistent icons in issue detail * style: spacing, borders and shadows in quick-add * fix: custom menu truncate * fix: notifications for created by me and assigned to me (#2292) * chore: workspace view display filters and properties , code refactor (#2295) * chore: spreadsheet view context * chore: spreadsheet context provider * chore: spreadsheet view context * chore: display filters and properties added in workspace view and code refactor * fix: build error fix * chore: set sub-issue display option to false for global views --------- Co-authored-by: gurusainath <gurusainath007@gmail.com> * chore: label create error (#2299) * chore: global issues ui improvement and bug fixes (#2300) * chore: workspace view mutation fix ,bug fixes and code refactor (#2301) * chore: workspace view mutation fix ,bug fixes and code refactor * chore: update workspace view toast alert added * chore: workspace view order by removed (#2303) * dev: updated migrations for 0.13-dev (#2305) * chore: epoch migration batch size changed * chore: reoredered the migration files * dev: updated migrations for 0.13-dev * chore: added epoch field * dev: merged the migration files * fix: workspace view filters count fix (#2307) * fix: unsplash api fix (#2310) * fix: workspace view redirection fix, style: spreadsheet view shadow scroll fix (#2314) * fix: workspace view redirection fix * style: spreadsheet view scroll shadow fix * fix: update build workflow for the deploy app (#2315) * fix: workspace view add issue mutation fix (#2317) * dev: create action to sync PR changes to the repo (#2333) * fix: ui package readme added (#2334) * fix: variable name for token (#2336) * dev: update add permissions to the action (#2337) * dev: rename token variables (#2338) * fix: updated readme fixes (#2339) * dev: update sync workflow to run only when the source repo is configured (#2346) * dev: update sync workflow to run only when the source repo is configured * fix: naming convention changes --------- Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com> * fix: issue relation mutation and draft issue (#2340) * fix: issue relation mutation and draft issue * fix: 'New Issue' in gantt view fix: emoji select going under * fix: profile page typo * fix: sync workflow fixes (#2365) * fix: sync job pr description escaped values fix (#2366) * Update index.tsx (#2343) Fixes #2342 * dev: update apiserver configuration files (#2348) * dev: update apiserver configuration files * dev: add email and minio redirection urls * fix: themening validation in store init. (#2350) * chore: member can change role (#2371) * chore: removed the issue draft log from my profile (#2368) * adding sync info in pr title (#2373) * chore: layout access validation and switch in plane deploy issues route (#2351) * chore: handled route validation and layout access validation in plane deploy issues * chore: impoved validation condition * show current version in the help section dropdown (#2353) * fix: table menu positioning (#2354) * fix: handle cross project issues in the sub-issues. (#2357) * fix: login process validation based on api config (#2361) * dev: configuration endpoint for frontend client (#2355) * dev: configuration endpoint for frontend clients * dev: configuration enable magic and email/password signup * dev: update unsplash keys * dev: add unsplash API and add env for magic login * fix: 404 when redirecting user clicks on Sign In button (#2349) * fix: 404 when redirecting user to login page * fix: next_path redirection not working * fix: authentication workflow update in plane deploy --------- Co-authored-by: gurusainath <gurusainath007@gmail.com> * fix: project setting member role validation (#2369) * fix: project setting member role validation * chore: opacity removed from member setting page * chore: member setting page validation * chore: project covers endpoint (#2370) * chore: project covers endpoint * dev: remove print logs * dev: formatting --------- Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com> * feat: default project cover images tab on the change cover popover (#2375) * feat: default project cover images tab * chore: remove unnecessary env vars from turbo.json * chore: remove unnecessary OAuth envs (#2378) * chore: remove unnecessary oauth envs * merge conflicts resolved * fix: adding new service --------- Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com> * fix: added user store variables in mobx store observable (#2380) * fix: state group icons (#2381) * fix: removed default theme setting in the index page (#2382) * fix: removed default theme setting in the index page * fix: empty space * dev: global views and workspace filters store implemented * sync CE Master to EE Develop * refactor: create update view modal * chore: static issue global views * refactor: remove old code * refactor: filters select dropdown * chore: fix calendar layout * chore: mobx store for new applied filters * chore: dded search functionality --------- Co-authored-by: Vamsi Kurama <vamsi.kurama@gmail.com> Co-authored-by: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com> Co-authored-by: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com> Co-authored-by: guru_sainath <gurusainath007@gmail.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: Anmol Singh Bhatia <asb@Anmols-MacBook-Pro.local> Co-authored-by: Rhea Jain <65884341+rhea0110@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: Thomas <git@thomasync.dev> Co-authored-by: Luis Cruz <55716036+luis-cruzt@users.noreply.github.com> Co-authored-by: Manish Gupta <manish@mgupta.me> * fix: Auth fixes and Layout fixes (#2408) * fix: auth fixes and layout improvements * fix: layout fixes * fix: analytics page fixes * dev: implemented project views using MobX (#2410) * dev: implemented project views list using mobx * style: views list UI * dev: implemented view issues page using mobx * refactor: project view issues fetching * chore: plane ui library component and code refactor (#2406) * chore: swap input component with plane/ui package * chore: swap textarea component with plane/ui package * chore: swap button component with plane/ui package * chore: button component revamp * fix: button type fix * chore: secondary button revamp * chore: button props updated * chore: swap loader component with plane/ui package * fix: build error fix * chore: button component refactor * chore: code refactor * chore: swap toggle switch component with plane/ui package * chore: swap spinner component with plane/ui package * chore: swap progress bar componenet with plan/ui package * chore: code refactor * fix: gitignore fixes * fix: project card fixes * chore: ui component revamp (#2415) * chore: swap tooltip component with plane ui package * chore: swap linear progress component with plane ui package * fix: login button fix * chore: implement new worksapace wrapper for global views (#2412) * chore: implement new worksapace wrapper for global views pages * fix: merge conflicts * fix: merge conflicts * dev: add remaining layouts to cycle (#2413) * fix: workspace auth wrapper changes * chore: project card revamp and refactor (#2416) * removing dist from ui * refactor: analytics (#2419) * refactor: helper functions * chore: updated all the page headers * refactor: custom analytics * refactor: project analytics modal * refactor: folder structure, remove junk code (#2423) * refactor: folder structure * chore: ad order by target date option * refactor: remove old layout components * refactor: inbox folder structure * fix: services fixes * fix: store imports changes * fix: services export fixes * fix: services implementation fixes * fix: build issue fixes * fix: react library fixes * refactor: MobX store folder structure (#2435) * refactor: store folder structure * chore: update import statements * fix: service import errors (#2436) * fix: service imports * chore: update service imports in store * chore: fix remianing service imports * build fixes * editor ts config fixes * fix: turbo and build fixes * fix: Auth screen loading implementation * fix: build issues * fix: turbo settings for ui package --------- Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Aaryan Khandelwal <65252264+aaryan610@users.noreply.github.com> Co-authored-by: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Co-authored-by: Dakshesh Jain <65905942+dakshesh14@users.noreply.github.com> Co-authored-by: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com> Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> Co-authored-by: Vamsi Kurama <vamsi.kurama@gmail.com> Co-authored-by: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Co-authored-by: NarayanBavisetti <narayan3119@gmail.com> Co-authored-by: Anmol Singh Bhatia <asb@Anmols-MacBook-Pro.local> Co-authored-by: Rhea Jain <65884341+rhea0110@users.noreply.github.com> Co-authored-by: Your Name <you@example.com> Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: Thomas <git@thomasync.dev> Co-authored-by: Luis Cruz <55716036+luis-cruzt@users.noreply.github.com> Co-authored-by: Manish Gupta <manish@mgupta.me>
This commit is contained in:
parent
c6e021d41f
commit
d80a593520
758 changed files with 30452 additions and 23632 deletions
|
|
@ -1,53 +0,0 @@
|
|||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import cyclesService from "services/cycles.service";
|
||||
// hooks
|
||||
import useIssuesView from "hooks/use-issues-view";
|
||||
// fetch-keys
|
||||
import { CYCLE_ISSUES_WITH_PARAMS } from "constants/fetch-keys";
|
||||
|
||||
const useGanttChartCycleIssues = (
|
||||
workspaceSlug: string | undefined,
|
||||
projectId: string | undefined,
|
||||
cycleId: string | undefined
|
||||
) => {
|
||||
const { displayFilters, filters } = useIssuesView();
|
||||
|
||||
const params: any = {
|
||||
order_by: displayFilters.order_by,
|
||||
type: displayFilters?.type ? displayFilters?.type : undefined,
|
||||
sub_issue: displayFilters.sub_issue,
|
||||
assignees: filters?.assignees ? filters?.assignees.join(",") : undefined,
|
||||
state: filters?.state ? filters?.state.join(",") : undefined,
|
||||
priority: filters?.priority ? filters?.priority.join(",") : undefined,
|
||||
labels: filters?.labels ? filters?.labels.join(",") : undefined,
|
||||
created_by: filters?.created_by ? filters?.created_by.join(",") : undefined,
|
||||
start_date: filters?.start_date ? filters?.start_date.join(",") : undefined,
|
||||
target_date: filters?.target_date ? filters?.target_date.join(",") : undefined,
|
||||
start_target_date: true, // to fetch only issues with a start and target date
|
||||
};
|
||||
|
||||
// all issues under the workspace and project
|
||||
const { data: ganttIssues, mutate: mutateGanttIssues } = useSWR(
|
||||
workspaceSlug && projectId && cycleId
|
||||
? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), params)
|
||||
: null,
|
||||
workspaceSlug && projectId && cycleId
|
||||
? () =>
|
||||
cyclesService.getCycleIssuesWithParams(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
cycleId.toString(),
|
||||
params
|
||||
)
|
||||
: null
|
||||
);
|
||||
|
||||
return {
|
||||
ganttIssues,
|
||||
mutateGanttIssues,
|
||||
};
|
||||
};
|
||||
|
||||
export default useGanttChartCycleIssues;
|
||||
|
|
@ -1,12 +1,13 @@
|
|||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import issuesService from "services/issues.service";
|
||||
import { IssueService } from "services/issue";
|
||||
// hooks
|
||||
import useIssuesView from "hooks/use-issues-view";
|
||||
// fetch-keys
|
||||
import { PROJECT_ISSUES_LIST_WITH_PARAMS } from "constants/fetch-keys";
|
||||
|
||||
const issueService = new IssueService();
|
||||
|
||||
const useGanttChartIssues = (workspaceSlug: string | undefined, projectId: string | undefined) => {
|
||||
const { displayFilters, filters } = useIssuesView();
|
||||
|
||||
|
|
@ -28,8 +29,7 @@ const useGanttChartIssues = (workspaceSlug: string | undefined, projectId: strin
|
|||
const { data: ganttIssues, mutate: mutateGanttIssues } = useSWR(
|
||||
workspaceSlug && projectId ? PROJECT_ISSUES_LIST_WITH_PARAMS(projectId, params) : null,
|
||||
workspaceSlug && projectId
|
||||
? () =>
|
||||
issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params)
|
||||
? () => issueService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params)
|
||||
: null
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import modulesService from "services/modules.service";
|
||||
// hooks
|
||||
import useIssuesView from "hooks/use-issues-view";
|
||||
// fetch-keys
|
||||
import { MODULE_ISSUES_WITH_PARAMS } from "constants/fetch-keys";
|
||||
|
||||
const useGanttChartModuleIssues = (
|
||||
workspaceSlug: string | undefined,
|
||||
projectId: string | undefined,
|
||||
moduleId: string | undefined
|
||||
) => {
|
||||
const { displayFilters, filters } = useIssuesView();
|
||||
|
||||
const params: any = {
|
||||
order_by: displayFilters.order_by,
|
||||
type: displayFilters?.type ? displayFilters?.type : undefined,
|
||||
sub_issue: displayFilters.sub_issue,
|
||||
assignees: filters?.assignees ? filters?.assignees.join(",") : undefined,
|
||||
state: filters?.state ? filters?.state.join(",") : undefined,
|
||||
priority: filters?.priority ? filters?.priority.join(",") : undefined,
|
||||
labels: filters?.labels ? filters?.labels.join(",") : undefined,
|
||||
created_by: filters?.created_by ? filters?.created_by.join(",") : undefined,
|
||||
start_date: filters?.start_date ? filters?.start_date.join(",") : undefined,
|
||||
target_date: filters?.target_date ? filters?.target_date.join(",") : undefined,
|
||||
start_target_date: true, // to fetch only issues with a start and target date
|
||||
};
|
||||
|
||||
// all issues under the workspace and project
|
||||
const { data: ganttIssues, mutate: mutateGanttIssues } = useSWR(
|
||||
workspaceSlug && projectId && moduleId
|
||||
? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), params)
|
||||
: null,
|
||||
workspaceSlug && projectId && moduleId
|
||||
? () =>
|
||||
modulesService.getModuleIssuesWithParams(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
moduleId.toString(),
|
||||
params
|
||||
)
|
||||
: null
|
||||
);
|
||||
|
||||
return {
|
||||
ganttIssues,
|
||||
mutateGanttIssues,
|
||||
};
|
||||
};
|
||||
|
||||
export default useGanttChartModuleIssues;
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import issuesService from "services/issues.service";
|
||||
// hooks
|
||||
import useIssuesView from "hooks/use-issues-view";
|
||||
// fetch-keys
|
||||
import { VIEW_ISSUES } from "constants/fetch-keys";
|
||||
|
||||
const useGanttChartViewIssues = (
|
||||
workspaceSlug: string | undefined,
|
||||
projectId: string | undefined,
|
||||
viewId: string | undefined
|
||||
) => {
|
||||
const { params } = useIssuesView();
|
||||
const { order_by, group_by, ...viewGanttParams } = params;
|
||||
|
||||
// all issues under the view
|
||||
const { data: ganttIssues, mutate: mutateGanttIssues } = useSWR(
|
||||
workspaceSlug && projectId && viewId
|
||||
? VIEW_ISSUES(viewId.toString(), { ...viewGanttParams, order_by, start_target_date: true })
|
||||
: null,
|
||||
workspaceSlug && projectId && viewId
|
||||
? () =>
|
||||
issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), {
|
||||
...viewGanttParams,
|
||||
start_target_date: true,
|
||||
})
|
||||
: null
|
||||
);
|
||||
|
||||
return {
|
||||
ganttIssues,
|
||||
mutateGanttIssues,
|
||||
};
|
||||
};
|
||||
|
||||
export default useGanttChartViewIssues;
|
||||
|
|
@ -1,9 +1,7 @@
|
|||
import { useEffect, useCallback } from "react";
|
||||
|
||||
import useSWR, { mutate } from "swr";
|
||||
|
||||
// services
|
||||
import workspaceService from "services/workspace.service";
|
||||
import { WorkspaceService } from "services/workspace.service";
|
||||
// types
|
||||
import {
|
||||
IIssueDisplayFilterOptions,
|
||||
|
|
@ -15,6 +13,8 @@ import {
|
|||
// fetch-keys
|
||||
import { WORKSPACE_MEMBERS_ME } from "constants/fetch-keys";
|
||||
|
||||
const workspaceService = new WorkspaceService();
|
||||
|
||||
const initialValues: IWorkspaceViewProps = {
|
||||
display_filters: {
|
||||
group_by: null,
|
||||
|
|
@ -103,12 +103,7 @@ const useMyIssuesFilters = (workspaceSlug: string | undefined) => {
|
|||
},
|
||||
};
|
||||
|
||||
if (
|
||||
displayFilter.layout &&
|
||||
displayFilter.layout === "kanban" &&
|
||||
groupBy === null &&
|
||||
payload.display_filters
|
||||
)
|
||||
if (displayFilter.layout && displayFilter.layout === "kanban" && groupBy === null && payload.display_filters)
|
||||
payload.display_filters.group_by = "state_detail.group";
|
||||
|
||||
saveData(payload);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { useRouter } from "next/router";
|
|||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import userService from "services/user.service";
|
||||
import { UserService } from "services/user.service";
|
||||
// hooks
|
||||
import useMyIssuesFilters from "hooks/my-issues/use-my-issues-filter";
|
||||
// types
|
||||
|
|
@ -13,6 +13,9 @@ import { IIssue } from "types";
|
|||
// fetch-keys
|
||||
import { USER_ISSUES } from "constants/fetch-keys";
|
||||
|
||||
// services
|
||||
const userService = new UserService();
|
||||
|
||||
const useMyIssues = (workspaceSlug: string | undefined) => {
|
||||
const router = useRouter();
|
||||
|
||||
|
|
@ -33,9 +36,7 @@ const useMyIssues = (workspaceSlug: string | undefined) => {
|
|||
};
|
||||
|
||||
const { data: myIssues, mutate: mutateMyIssues } = useSWR(
|
||||
workspaceSlug && router.pathname.includes("my-issues")
|
||||
? USER_ISSUES(workspaceSlug.toString(), params)
|
||||
: null,
|
||||
workspaceSlug && router.pathname.includes("my-issues") ? USER_ISSUES(workspaceSlug.toString(), params) : null,
|
||||
workspaceSlug && router.pathname.includes("my-issues")
|
||||
? () => userService.userIssues(workspaceSlug.toString(), params)
|
||||
: null
|
||||
|
|
|
|||
|
|
@ -1,150 +0,0 @@
|
|||
import { useContext, useState } from "react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import useSWR from "swr";
|
||||
|
||||
// contexts
|
||||
import { issueViewContext } from "contexts/issue-view.context";
|
||||
// services
|
||||
import issuesService from "services/issues.service";
|
||||
import cyclesService from "services/cycles.service";
|
||||
import modulesService from "services/modules.service";
|
||||
// helpers
|
||||
import { renderDateFormat } from "helpers/date-time.helper";
|
||||
// types
|
||||
import { IIssue } from "types";
|
||||
// fetch-keys
|
||||
import {
|
||||
CYCLE_ISSUES_WITH_PARAMS,
|
||||
MODULE_ISSUES_WITH_PARAMS,
|
||||
PROJECT_ISSUES_LIST_WITH_PARAMS,
|
||||
VIEW_ISSUES,
|
||||
} from "constants/fetch-keys";
|
||||
|
||||
const useCalendarIssuesView = () => {
|
||||
const {
|
||||
display_filters: displayFilters,
|
||||
filters,
|
||||
setFilters,
|
||||
resetFilterToDefault,
|
||||
setNewFilterDefaultView,
|
||||
} = useContext(issueViewContext);
|
||||
|
||||
const [activeMonthDate, setActiveMonthDate] = useState(new Date());
|
||||
|
||||
// previous month's first date
|
||||
const previousMonthYear =
|
||||
activeMonthDate.getMonth() === 0
|
||||
? activeMonthDate.getFullYear() - 1
|
||||
: activeMonthDate.getFullYear();
|
||||
const previousMonthMonth = activeMonthDate.getMonth() === 0 ? 11 : activeMonthDate.getMonth() - 1;
|
||||
|
||||
const previousMonthFirstDate = new Date(previousMonthYear, previousMonthMonth, 1);
|
||||
|
||||
// next month's last date
|
||||
const nextMonthYear =
|
||||
activeMonthDate.getMonth() === 11
|
||||
? activeMonthDate.getFullYear() + 1
|
||||
: activeMonthDate.getFullYear();
|
||||
const nextMonthMonth = (activeMonthDate.getMonth() + 1) % 12;
|
||||
const nextMonthFirstDate = new Date(nextMonthYear, nextMonthMonth, 1);
|
||||
|
||||
const nextMonthLastDate = new Date(
|
||||
nextMonthFirstDate.getFullYear(),
|
||||
nextMonthFirstDate.getMonth() + 1,
|
||||
0
|
||||
);
|
||||
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId, cycleId, moduleId, viewId } = router.query;
|
||||
|
||||
const params: any = {
|
||||
assignees: filters?.assignees ? filters?.assignees.join(",") : undefined,
|
||||
state: filters?.state ? filters?.state.join(",") : undefined,
|
||||
priority: filters?.priority ? filters?.priority.join(",") : undefined,
|
||||
type: displayFilters?.type ? displayFilters?.type : undefined,
|
||||
labels: filters?.labels ? filters?.labels.join(",") : undefined,
|
||||
created_by: filters?.created_by ? filters?.created_by.join(",") : undefined,
|
||||
start_date: filters?.start_date ? filters?.start_date.join(",") : undefined,
|
||||
target_date: `${renderDateFormat(previousMonthFirstDate)};after,${renderDateFormat(
|
||||
nextMonthLastDate
|
||||
)};before`,
|
||||
};
|
||||
|
||||
const { data: projectCalendarIssues, mutate: mutateProjectCalendarIssues } = useSWR(
|
||||
workspaceSlug && projectId
|
||||
? PROJECT_ISSUES_LIST_WITH_PARAMS(projectId.toString(), params)
|
||||
: null,
|
||||
workspaceSlug && projectId
|
||||
? () =>
|
||||
issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: cycleCalendarIssues, mutate: mutateCycleCalendarIssues } = useSWR(
|
||||
workspaceSlug && projectId && cycleId
|
||||
? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), params)
|
||||
: null,
|
||||
workspaceSlug && projectId && cycleId
|
||||
? () =>
|
||||
cyclesService.getCycleIssuesWithParams(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
cycleId.toString(),
|
||||
params
|
||||
)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: moduleCalendarIssues, mutate: mutateModuleCalendarIssues } = useSWR(
|
||||
workspaceSlug && projectId && moduleId
|
||||
? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), params)
|
||||
: null,
|
||||
workspaceSlug && projectId && moduleId
|
||||
? () =>
|
||||
modulesService.getModuleIssuesWithParams(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
moduleId.toString(),
|
||||
params
|
||||
)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: viewCalendarIssues, mutate: mutateViewCalendarIssues } = useSWR(
|
||||
workspaceSlug && projectId && viewId && params ? VIEW_ISSUES(viewId.toString(), params) : null,
|
||||
workspaceSlug && projectId && viewId && params
|
||||
? () =>
|
||||
issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params)
|
||||
: null
|
||||
);
|
||||
|
||||
const calendarIssues = cycleId
|
||||
? (cycleCalendarIssues as IIssue[])
|
||||
: moduleId
|
||||
? (moduleCalendarIssues as IIssue[])
|
||||
: viewId
|
||||
? (viewCalendarIssues as IIssue[])
|
||||
: (projectCalendarIssues as IIssue[]);
|
||||
|
||||
return {
|
||||
activeMonthDate,
|
||||
setActiveMonthDate,
|
||||
calendarIssues: calendarIssues ?? [],
|
||||
mutateIssues: cycleId
|
||||
? mutateCycleCalendarIssues
|
||||
: moduleId
|
||||
? mutateModuleCalendarIssues
|
||||
: viewId
|
||||
? mutateViewCalendarIssues
|
||||
: mutateProjectCalendarIssues,
|
||||
filters,
|
||||
setFilters,
|
||||
params,
|
||||
resetFilterToDefault,
|
||||
setNewFilterDefaultView,
|
||||
} as const;
|
||||
};
|
||||
|
||||
export default useCalendarIssuesView;
|
||||
|
|
@ -2,16 +2,16 @@ import useSWR from "swr";
|
|||
|
||||
// fetch keys
|
||||
import { COMMENT_REACTION_LIST } from "constants/fetch-keys";
|
||||
|
||||
// services
|
||||
import reactionService from "services/reaction.service";
|
||||
|
||||
import { IssueReactionService } from "services/issue";
|
||||
// helpers
|
||||
import { groupReactions } from "helpers/emoji.helper";
|
||||
|
||||
// hooks
|
||||
import useUser from "./use-user";
|
||||
|
||||
// services
|
||||
const issueReactionService = new IssueReactionService();
|
||||
|
||||
const useCommentReaction = (
|
||||
workspaceSlug?: string | string[] | null,
|
||||
projectId?: string | string[] | null,
|
||||
|
|
@ -27,7 +27,7 @@ const useCommentReaction = (
|
|||
: null,
|
||||
workspaceSlug && projectId && commendId
|
||||
? () =>
|
||||
reactionService.listIssueCommentReactions(
|
||||
issueReactionService.listIssueCommentReactions(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
commendId.toString()
|
||||
|
|
@ -48,7 +48,7 @@ const useCommentReaction = (
|
|||
const handleReactionCreate = async (reaction: string) => {
|
||||
if (!workspaceSlug || !projectId || !commendId) return;
|
||||
|
||||
const data = await reactionService.createIssueCommentReaction(
|
||||
const data = await issueReactionService.createIssueCommentReaction(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
commendId.toString(),
|
||||
|
|
@ -69,12 +69,11 @@ const useCommentReaction = (
|
|||
if (!workspaceSlug || !projectId || !commendId) return;
|
||||
|
||||
mutateCommentReactions(
|
||||
(prevData: any) =>
|
||||
prevData?.filter((r: any) => r.actor !== user?.user?.id || r.reaction !== reaction) || [],
|
||||
(prevData: any) => prevData?.filter((r: any) => r.actor !== user?.user?.id || r.reaction !== reaction) || [],
|
||||
false
|
||||
);
|
||||
|
||||
await reactionService.deleteIssueCommentReaction(
|
||||
await issueReactionService.deleteIssueCommentReaction(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
commendId.toString(),
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import { useRouter } from "next/router";
|
||||
|
||||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import estimatesService from "services/estimates.service";
|
||||
import { ProjectEstimateService } from "services/project";
|
||||
// hooks
|
||||
import useProjectDetails from "hooks/use-project-details";
|
||||
// helpers
|
||||
|
|
@ -11,19 +9,22 @@ import { orderArrayBy } from "helpers/array.helper";
|
|||
// fetch-keys
|
||||
import { ESTIMATE_DETAILS } from "constants/fetch-keys";
|
||||
|
||||
// services
|
||||
const projectEstimateService = new ProjectEstimateService();
|
||||
|
||||
const useEstimateOption = (estimateKey?: number | null) => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId } = router.query;
|
||||
|
||||
const { projectDetails } = useProjectDetails();
|
||||
|
||||
const { data: estimateDetails, error: estimateDetailsError } = useSWR(
|
||||
const { data: estimateDetails } = useSWR(
|
||||
workspaceSlug && projectId && projectDetails && projectDetails?.estimate
|
||||
? ESTIMATE_DETAILS(projectDetails.estimate as string)
|
||||
: null,
|
||||
workspaceSlug && projectId && projectDetails && projectDetails.estimate
|
||||
? () =>
|
||||
estimatesService.getEstimateDetails(
|
||||
projectEstimateService.getEstimateDetails(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
projectDetails.estimate as string
|
||||
|
|
@ -32,9 +33,7 @@ const useEstimateOption = (estimateKey?: number | null) => {
|
|||
);
|
||||
|
||||
const estimateValue: any =
|
||||
estimateKey || estimateKey === 0
|
||||
? estimateDetails?.points?.find((e) => e.key === estimateKey)?.value
|
||||
: "None";
|
||||
estimateKey || estimateKey === 0 ? estimateDetails?.points?.find((e) => e.key === estimateKey)?.value : "None";
|
||||
|
||||
return {
|
||||
isEstimateActive: projectDetails?.estimate ? true : false,
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ import useSWR from "swr";
|
|||
// contexts
|
||||
import { inboxViewContext } from "contexts/inbox-view-context";
|
||||
// services
|
||||
import inboxServices from "services/inbox.service";
|
||||
import { InboxService } from "services/inbox.service";
|
||||
// types
|
||||
import { IInboxQueryParams } from "types";
|
||||
// fetch-keys
|
||||
import { INBOX_ISSUES } from "constants/fetch-keys";
|
||||
|
||||
const inboxService = new InboxService();
|
||||
|
||||
const useInboxView = () => {
|
||||
const { filters, setFilters, clearAllFilters } = useContext(inboxViewContext);
|
||||
|
||||
|
|
@ -25,17 +27,9 @@ const useInboxView = () => {
|
|||
};
|
||||
|
||||
const { data: inboxIssues, mutate: mutateInboxIssues } = useSWR(
|
||||
workspaceSlug && projectId && inboxId && params ? INBOX_ISSUES(inboxId.toString(), params) : null,
|
||||
workspaceSlug && projectId && inboxId && params
|
||||
? INBOX_ISSUES(inboxId.toString(), params)
|
||||
: null,
|
||||
workspaceSlug && projectId && inboxId && params
|
||||
? () =>
|
||||
inboxServices.getInboxIssues(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
inboxId.toString(),
|
||||
params
|
||||
)
|
||||
? () => inboxService.getInboxIssues(workspaceSlug.toString(), projectId.toString(), inboxId.toString(), params)
|
||||
: null
|
||||
);
|
||||
|
||||
|
|
@ -43,8 +37,7 @@ const useInboxView = () => {
|
|||
Object.keys(filters ?? {}).forEach((key) => {
|
||||
const filterKey = key as keyof typeof filters;
|
||||
|
||||
if (filters[filterKey] && Array.isArray(filters[filterKey]))
|
||||
filtersLength += (filters[filterKey] ?? []).length;
|
||||
if (filters[filterKey] && Array.isArray(filters[filterKey])) filtersLength += (filters[filterKey] ?? []).length;
|
||||
});
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { useCallback } from "react";
|
||||
|
||||
import useSWR from "swr";
|
||||
|
||||
// hooks
|
||||
import useUserAuth from "hooks/use-user-auth";
|
||||
// services
|
||||
import userNotificationServices from "services/notifications.service";
|
||||
import { NotificationService } from "services/notification.service";
|
||||
|
||||
const userNotificationServices = new NotificationService();
|
||||
|
||||
const useUserIssueNotificationSubscription = (
|
||||
workspaceSlug?: string | string[] | null,
|
||||
|
|
@ -15,9 +15,7 @@ const useUserIssueNotificationSubscription = (
|
|||
const { user } = useUserAuth();
|
||||
|
||||
const { data, error, mutate } = useSWR(
|
||||
workspaceSlug && projectId && issueId
|
||||
? `SUBSCRIPTION_STATUE_${workspaceSlug}_${projectId}_${issueId}`
|
||||
: null,
|
||||
workspaceSlug && projectId && issueId ? `SUBSCRIPTION_STATUE_${workspaceSlug}_${projectId}_${issueId}` : null,
|
||||
workspaceSlug && projectId && issueId
|
||||
? () =>
|
||||
userNotificationServices.getIssueNotificationSubscriptionStatus(
|
||||
|
|
@ -39,11 +37,7 @@ const useUserIssueNotificationSubscription = (
|
|||
);
|
||||
|
||||
userNotificationServices
|
||||
.unsubscribeFromIssueNotifications(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issueId.toString()
|
||||
)
|
||||
.unsubscribeFromIssueNotifications(workspaceSlug.toString(), projectId.toString(), issueId.toString())
|
||||
.then(() => {
|
||||
mutate({
|
||||
subscribed: false,
|
||||
|
|
@ -62,11 +56,7 @@ const useUserIssueNotificationSubscription = (
|
|||
);
|
||||
|
||||
userNotificationServices
|
||||
.subscribeToIssueNotifications(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issueId.toString()
|
||||
)
|
||||
.subscribeToIssueNotifications(workspaceSlug.toString(), projectId.toString(), issueId.toString())
|
||||
.then(() => {
|
||||
mutate({
|
||||
subscribed: true,
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import { useState, useEffect, useCallback } from "react";
|
||||
|
||||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import issueServices from "services/issues.service";
|
||||
import { IssueService } from "services/issue";
|
||||
// hooks
|
||||
import useUser from "hooks/use-user";
|
||||
// types
|
||||
import { IssuePriorities, Properties } from "types";
|
||||
|
||||
const issueService = new IssueService();
|
||||
|
||||
const initialValues: Properties = {
|
||||
assignee: true,
|
||||
start_date: true,
|
||||
|
|
@ -31,12 +31,8 @@ const useIssuesProperties = (workspaceSlug?: string, projectId?: string) => {
|
|||
const { user } = useUser();
|
||||
|
||||
const { data: issueProperties, mutate: mutateIssueProperties } = useSWR<IssuePriorities>(
|
||||
workspaceSlug && projectId
|
||||
? `/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-properties/`
|
||||
: null,
|
||||
workspaceSlug && projectId
|
||||
? () => issueServices.getIssueProperties(workspaceSlug, projectId)
|
||||
: null
|
||||
workspaceSlug && projectId ? `/api/workspaces/${workspaceSlug}/projects/${projectId}/issue-properties/` : null,
|
||||
workspaceSlug && projectId ? () => issueService.getIssueProperties(workspaceSlug, projectId) : null
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -45,12 +41,12 @@ const useIssuesProperties = (workspaceSlug?: string, projectId?: string) => {
|
|||
setProperties({ ...initialValues, ...issueProperties.properties });
|
||||
|
||||
if (Object.keys(issueProperties).length === 0)
|
||||
issueServices.createIssueProperties(workspaceSlug, projectId, {
|
||||
issueService.createIssueProperties(workspaceSlug, projectId, {
|
||||
properties: { ...initialValues },
|
||||
user: user.id,
|
||||
});
|
||||
else if (Object.keys(issueProperties?.properties).length === 0)
|
||||
issueServices.patchIssueProperties(workspaceSlug, projectId, issueProperties.id, {
|
||||
issueService.patchIssueProperties(workspaceSlug, projectId, issueProperties.id, {
|
||||
properties: { ...initialValues },
|
||||
user: user.id,
|
||||
});
|
||||
|
|
@ -68,11 +64,11 @@ const useIssuesProperties = (workspaceSlug?: string, projectId?: string) => {
|
|||
({
|
||||
...prev,
|
||||
properties: { ...prev?.properties, [key]: !prev?.properties?.[key] },
|
||||
}) as IssuePriorities,
|
||||
} as IssuePriorities),
|
||||
false
|
||||
);
|
||||
if (Object.keys(issueProperties).length > 0) {
|
||||
issueServices.patchIssueProperties(workspaceSlug, projectId, issueProperties.id, {
|
||||
issueService.patchIssueProperties(workspaceSlug, projectId, issueProperties.id, {
|
||||
properties: {
|
||||
...issueProperties.properties,
|
||||
[key]: !issueProperties.properties[key],
|
||||
|
|
@ -80,7 +76,7 @@ const useIssuesProperties = (workspaceSlug?: string, projectId?: string) => {
|
|||
user: user.id,
|
||||
});
|
||||
} else {
|
||||
issueServices.createIssueProperties(workspaceSlug, projectId, {
|
||||
issueService.createIssueProperties(workspaceSlug, projectId, {
|
||||
properties: { ...initialValues },
|
||||
user: user.id,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,16 +2,15 @@ import useSWR from "swr";
|
|||
|
||||
// fetch keys
|
||||
import { ISSUE_REACTION_LIST } from "constants/fetch-keys";
|
||||
|
||||
// helpers
|
||||
import { groupReactions } from "helpers/emoji.helper";
|
||||
|
||||
// services
|
||||
import reactionService from "services/reaction.service";
|
||||
|
||||
import { IssueReactionService } from "services/issue";
|
||||
// hooks
|
||||
import useUser from "./use-user";
|
||||
|
||||
const issueReactionService = new IssueReactionService();
|
||||
|
||||
const useIssueReaction = (
|
||||
workspaceSlug?: string | string[] | null,
|
||||
projectId?: string | string[] | null,
|
||||
|
|
@ -29,11 +28,7 @@ const useIssueReaction = (
|
|||
: null,
|
||||
workspaceSlug && projectId && issueId
|
||||
? () =>
|
||||
reactionService.listIssueReactions(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issueId.toString()
|
||||
)
|
||||
issueReactionService.listIssueReactions(workspaceSlug.toString(), projectId.toString(), issueId.toString())
|
||||
: null
|
||||
);
|
||||
|
||||
|
|
@ -48,7 +43,7 @@ const useIssueReaction = (
|
|||
const handleReactionCreate = async (reaction: string) => {
|
||||
if (!workspaceSlug || !projectId || !issueId) return;
|
||||
|
||||
const data = await reactionService.createIssueReaction(
|
||||
const data = await issueReactionService.createIssueReaction(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issueId.toString(),
|
||||
|
|
@ -69,12 +64,11 @@ const useIssueReaction = (
|
|||
if (!workspaceSlug || !projectId || !issueId) return;
|
||||
|
||||
mutateReaction(
|
||||
(prevData: any) =>
|
||||
prevData?.filter((r: any) => r.actor !== user?.user?.id || r.reaction !== reaction) || [],
|
||||
(prevData: any) => prevData?.filter((r: any) => r.actor !== user?.user?.id || r.reaction !== reaction) || [],
|
||||
false
|
||||
);
|
||||
|
||||
await reactionService.deleteIssueReaction(
|
||||
await issueReactionService.deleteIssueReaction(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
issueId.toString(),
|
||||
|
|
|
|||
|
|
@ -1,16 +1,13 @@
|
|||
import { useContext, useMemo } from "react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import useSWR from "swr";
|
||||
|
||||
// contexts
|
||||
import { issueViewContext } from "contexts/issue-view.context";
|
||||
// services
|
||||
import issuesService from "services/issues.service";
|
||||
import cyclesService from "services/cycles.service";
|
||||
import modulesService from "services/modules.service";
|
||||
import stateService from "services/state.service";
|
||||
import { IssueService, IssueArchiveService, IssueDraftService } from "services/issue";
|
||||
import { CycleService } from "services/cycle.service";
|
||||
import { ModuleService } from "services/module.service";
|
||||
import { ProjectStateService } from "services/project";
|
||||
// helpers
|
||||
import { getStatesList } from "helpers/state.helper";
|
||||
// types
|
||||
|
|
@ -26,6 +23,14 @@ import {
|
|||
VIEW_ISSUES,
|
||||
} from "constants/fetch-keys";
|
||||
|
||||
// services
|
||||
const issueService = new IssueService();
|
||||
const issueArchiveService = new IssueArchiveService();
|
||||
const issueDraftService = new IssueDraftService();
|
||||
const cycleService = new CycleService();
|
||||
const moduleService = new ModuleService();
|
||||
const projectStateService = new ProjectStateService();
|
||||
|
||||
const useIssuesView = () => {
|
||||
const {
|
||||
display_filters: displayFilters,
|
||||
|
|
@ -56,12 +61,9 @@ const useIssuesView = () => {
|
|||
};
|
||||
|
||||
const { data: projectIssues, mutate: mutateProjectIssues } = useSWR(
|
||||
workspaceSlug && projectId && params ? PROJECT_ISSUES_LIST_WITH_PARAMS(projectId as string, params) : null,
|
||||
workspaceSlug && projectId && params
|
||||
? PROJECT_ISSUES_LIST_WITH_PARAMS(projectId as string, params)
|
||||
: null,
|
||||
workspaceSlug && projectId && params
|
||||
? () =>
|
||||
issuesService.getIssuesWithParams(workspaceSlug as string, projectId as string, params)
|
||||
? () => issueService.getIssuesWithParams(workspaceSlug as string, projectId as string, params)
|
||||
: null
|
||||
);
|
||||
|
||||
|
|
@ -70,7 +72,7 @@ const useIssuesView = () => {
|
|||
? PROJECT_ARCHIVED_ISSUES_LIST_WITH_PARAMS(projectId as string, params)
|
||||
: null,
|
||||
workspaceSlug && projectId && params && isArchivedIssues && !archivedIssueId
|
||||
? () => issuesService.getArchivedIssues(workspaceSlug as string, projectId as string, params)
|
||||
? () => issueArchiveService.getArchivedIssues(workspaceSlug as string, projectId as string, params)
|
||||
: null
|
||||
);
|
||||
|
||||
|
|
@ -79,32 +81,23 @@ const useIssuesView = () => {
|
|||
? PROJECT_DRAFT_ISSUES_LIST_WITH_PARAMS(projectId as string, params)
|
||||
: null,
|
||||
workspaceSlug && projectId && params && isDraftIssues && !archivedIssueId
|
||||
? () => issuesService.getDraftIssues(workspaceSlug as string, projectId as string, params)
|
||||
? () => issueDraftService.getDraftIssues(workspaceSlug as string, projectId as string, params)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: cycleIssues, mutate: mutateCycleIssues } = useSWR(
|
||||
workspaceSlug && projectId && cycleId && params
|
||||
? CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params)
|
||||
: null,
|
||||
workspaceSlug && projectId && cycleId && params ? CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params) : null,
|
||||
workspaceSlug && projectId && cycleId && params
|
||||
? () =>
|
||||
cyclesService.getCycleIssuesWithParams(
|
||||
workspaceSlug as string,
|
||||
projectId as string,
|
||||
cycleId as string,
|
||||
params
|
||||
)
|
||||
cycleService.getCycleIssuesWithParams(workspaceSlug as string, projectId as string, cycleId as string, params)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: moduleIssues, mutate: mutateModuleIssues } = useSWR(
|
||||
workspaceSlug && projectId && moduleId && params
|
||||
? MODULE_ISSUES_WITH_PARAMS(moduleId as string, params)
|
||||
: null,
|
||||
workspaceSlug && projectId && moduleId && params ? MODULE_ISSUES_WITH_PARAMS(moduleId as string, params) : null,
|
||||
workspaceSlug && projectId && moduleId && params
|
||||
? () =>
|
||||
modulesService.getModuleIssuesWithParams(
|
||||
moduleService.getModuleIssuesWithParams(
|
||||
workspaceSlug as string,
|
||||
projectId as string,
|
||||
moduleId as string,
|
||||
|
|
@ -116,21 +109,18 @@ const useIssuesView = () => {
|
|||
const { data: viewIssues, mutate: mutateViewIssues } = useSWR(
|
||||
workspaceSlug && projectId && viewId && params ? VIEW_ISSUES(viewId.toString(), params) : null,
|
||||
workspaceSlug && projectId && viewId && params
|
||||
? () =>
|
||||
issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params)
|
||||
? () => issueService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: states } = useSWR(
|
||||
workspaceSlug && projectId ? STATES_LIST(projectId as string) : null,
|
||||
workspaceSlug && projectId
|
||||
? () => stateService.getStates(workspaceSlug as string, projectId as string)
|
||||
? () => projectStateService.getStates(workspaceSlug as string, projectId as string)
|
||||
: null
|
||||
);
|
||||
const statesList = getStatesList(states);
|
||||
const activeStatesList = statesList?.filter(
|
||||
(state) => state.group === "started" || state.group === "unstarted"
|
||||
);
|
||||
const activeStatesList = statesList?.filter((state) => state.group === "started" || state.group === "unstarted");
|
||||
const backlogStatesList = statesList?.filter((state) => state.group === "backlog");
|
||||
|
||||
const stateIds =
|
||||
|
|
@ -141,8 +131,7 @@ const useIssuesView = () => {
|
|||
: statesList?.map((state) => state.id);
|
||||
|
||||
const filteredStateIds =
|
||||
(filters && filters?.state ? stateIds?.filter((s) => filters.state?.includes(s)) : stateIds) ??
|
||||
[];
|
||||
(filters && filters?.state ? stateIds?.filter((s) => filters.state?.includes(s)) : stateIds) ?? [];
|
||||
|
||||
const emptyStatesObject: { [key: string]: [] } = {};
|
||||
for (let i = 0; i < filteredStateIds.length; i++) {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ const getValueFromLocalStorage = (key: string, defaultValue: any) => {
|
|||
};
|
||||
|
||||
const useLocalStorage = <T,>(key: string, initialValue: T) => {
|
||||
const [storedValue, setStoredValue] = useState<T | null>(() =>
|
||||
getValueFromLocalStorage(key, initialValue)
|
||||
);
|
||||
const [storedValue, setStoredValue] = useState<T | null>(() => getValueFromLocalStorage(key, initialValue));
|
||||
|
||||
const setValue = useCallback(
|
||||
(value: T) => {
|
||||
|
|
|
|||
|
|
@ -5,14 +5,16 @@ import { useRouter } from "next/router";
|
|||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import userService from "services/user.service";
|
||||
import { UserService } from "services/user.service";
|
||||
// contexts
|
||||
import { profileIssuesContext } from "contexts/profile-issues-context";
|
||||
import { useWorkspaceMyMembership } from "contexts/workspace-member.context";
|
||||
// types
|
||||
import { IIssue } from "types";
|
||||
// fetch-keys
|
||||
import { USER_PROFILE_ISSUES } from "constants/fetch-keys";
|
||||
import { useWorkspaceMyMembership } from "contexts/workspace-member.context";
|
||||
|
||||
const userService = new UserService();
|
||||
|
||||
const useProfileIssues = (workspaceSlug: string | undefined, userId: string | undefined) => {
|
||||
const {
|
||||
|
|
@ -84,18 +86,12 @@ const useProfileIssues = (workspaceSlug: string | undefined, userId: string | un
|
|||
useEffect(() => {
|
||||
if (!userId || !filters) return;
|
||||
|
||||
if (
|
||||
router.pathname.includes("assigned") &&
|
||||
(!filters.assignees || !filters.assignees.includes(userId))
|
||||
) {
|
||||
if (router.pathname.includes("assigned") && (!filters.assignees || !filters.assignees.includes(userId))) {
|
||||
setFilters({ assignees: [...(filters.assignees ?? []), userId] });
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
router.pathname.includes("created") &&
|
||||
(!filters.created_by || !filters.created_by.includes(userId))
|
||||
) {
|
||||
if (router.pathname.includes("created") && (!filters.created_by || !filters.created_by.includes(userId))) {
|
||||
setFilters({ created_by: [...(filters.created_by ?? []), userId] });
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ import { useRouter } from "next/router";
|
|||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import projectService from "services/project.service";
|
||||
import { ProjectService } from "services/project";
|
||||
// fetch-keys
|
||||
import { PROJECT_DETAILS } from "constants/fetch-keys";
|
||||
|
||||
const projectService = new ProjectService();
|
||||
|
||||
const useProjectDetails = () => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId } = router.query;
|
||||
|
|
@ -17,9 +19,7 @@ const useProjectDetails = () => {
|
|||
mutate: mutateProjectDetails,
|
||||
} = useSWR(
|
||||
workspaceSlug && projectId ? PROJECT_DETAILS(projectId as string) : null,
|
||||
workspaceSlug && projectId
|
||||
? () => projectService.getProject(workspaceSlug as string, projectId as string)
|
||||
: null
|
||||
workspaceSlug && projectId ? () => projectService.getProject(workspaceSlug as string, projectId as string) : null
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import useSWR from "swr";
|
||||
// services
|
||||
import projectService from "services/project.service";
|
||||
import { ProjectService } from "services/project";
|
||||
// fetch-keys
|
||||
import { PROJECT_MEMBERS } from "constants/fetch-keys";
|
||||
// hooks
|
||||
import useUser from "./use-user";
|
||||
|
||||
const projectService = new ProjectService();
|
||||
|
||||
const useProjectMembers = (
|
||||
workspaceSlug: string | undefined,
|
||||
projectId: string | undefined,
|
||||
|
|
@ -17,20 +19,14 @@ const useProjectMembers = (
|
|||
// fetching project members
|
||||
const { data: members } = useSWR(
|
||||
workspaceSlug && projectId && fetchCondition ? PROJECT_MEMBERS(projectId) : null,
|
||||
workspaceSlug && projectId && fetchCondition
|
||||
? () => projectService.projectMembers(workspaceSlug, projectId)
|
||||
: null
|
||||
workspaceSlug && projectId && fetchCondition ? () => projectService.projectMembers(workspaceSlug, projectId) : null
|
||||
);
|
||||
|
||||
const hasJoined = members?.some((item: any) => item.member.id === (user as any)?.id);
|
||||
|
||||
const isOwner = members?.some((item) => item.member.id === (user as any)?.id && item.role === 20);
|
||||
const isMember = members?.some(
|
||||
(item) => item.member.id === (user as any)?.id && item.role === 15
|
||||
);
|
||||
const isViewer = members?.some(
|
||||
(item) => item.member.id === (user as any)?.id && item.role === 10
|
||||
);
|
||||
const isMember = members?.some((item) => item.member.id === (user as any)?.id && item.role === 15);
|
||||
const isViewer = members?.some((item) => item.member.id === (user as any)?.id && item.role === 10);
|
||||
const isGuest = members?.some((item) => item.member.id === (user as any)?.id && item.role === 5);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import { useRouter } from "next/router";
|
||||
|
||||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import projectService from "services/project.service";
|
||||
import { ProjectService } from "services/project";
|
||||
// helpers
|
||||
import { orderArrayBy } from "helpers/array.helper";
|
||||
// types
|
||||
|
|
@ -11,6 +9,8 @@ import { IProject } from "types";
|
|||
// fetch-keys
|
||||
import { PROJECTS_LIST } from "constants/fetch-keys";
|
||||
|
||||
const projectService = new ProjectService();
|
||||
|
||||
const useProjects = (type?: "all" | boolean, fetchCondition?: boolean) => {
|
||||
fetchCondition = fetchCondition ?? true;
|
||||
|
||||
|
|
@ -18,12 +18,8 @@ const useProjects = (type?: "all" | boolean, fetchCondition?: boolean) => {
|
|||
const { workspaceSlug } = router.query;
|
||||
|
||||
const { data: projects, mutate: mutateProjects } = useSWR(
|
||||
workspaceSlug && fetchCondition
|
||||
? PROJECTS_LIST(workspaceSlug as string, { is_favorite: type ?? "all" })
|
||||
: null,
|
||||
workspaceSlug && fetchCondition
|
||||
? () => projectService.getProjects(workspaceSlug as string, { is_favorite: type ?? "all" })
|
||||
: null
|
||||
workspaceSlug && fetchCondition ? PROJECTS_LIST(workspaceSlug as string, { is_favorite: type ?? "all" }) : null,
|
||||
workspaceSlug && fetchCondition ? () => projectService.getProjects(workspaceSlug as string) : null
|
||||
);
|
||||
|
||||
const recentProjects = [...(projects ?? [])]
|
||||
|
|
@ -31,9 +27,7 @@ const useProjects = (type?: "all" | boolean, fetchCondition?: boolean) => {
|
|||
?.slice(0, 3);
|
||||
|
||||
return {
|
||||
projects: projects
|
||||
? (orderArrayBy(projects, "is_favorite", "descending") as IProject[])
|
||||
: undefined,
|
||||
projects: projects ? (orderArrayBy(projects, "is_favorite", "descending") as IProject[]) : undefined,
|
||||
recentProjects: recentProjects || [],
|
||||
mutateProjects,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,124 +0,0 @@
|
|||
import { useContext } from "react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import useSWR from "swr";
|
||||
|
||||
// contexts
|
||||
import { issueViewContext } from "contexts/issue-view.context";
|
||||
// services
|
||||
import issuesService from "services/issues.service";
|
||||
import cyclesService from "services/cycles.service";
|
||||
import modulesService from "services/modules.service";
|
||||
// types
|
||||
import { IIssue } from "types";
|
||||
// fetch-keys
|
||||
import {
|
||||
CYCLE_ISSUES_WITH_PARAMS,
|
||||
MODULE_ISSUES_WITH_PARAMS,
|
||||
PROJECT_ISSUES_LIST_WITH_PARAMS,
|
||||
VIEW_ISSUES,
|
||||
} from "constants/fetch-keys";
|
||||
|
||||
const useSpreadsheetIssuesView = () => {
|
||||
const {
|
||||
display_filters: displayFilters,
|
||||
setDisplayFilters,
|
||||
filters,
|
||||
setFilters,
|
||||
resetFilterToDefault,
|
||||
setNewFilterDefaultView,
|
||||
} = useContext(issueViewContext);
|
||||
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId, cycleId, moduleId, viewId } = router.query;
|
||||
|
||||
const params: any = {
|
||||
order_by: displayFilters?.order_by,
|
||||
assignees: filters?.assignees ? filters?.assignees.join(",") : undefined,
|
||||
state: filters?.state ? filters?.state.join(",") : undefined,
|
||||
priority: filters?.priority ? filters?.priority.join(",") : undefined,
|
||||
type: displayFilters?.type ? displayFilters?.type : undefined,
|
||||
labels: filters?.labels ? filters?.labels.join(",") : undefined,
|
||||
created_by: filters?.created_by ? filters?.created_by.join(",") : undefined,
|
||||
start_date: filters?.start_date ? filters?.start_date.join(",") : undefined,
|
||||
target_date: filters?.target_date ? filters?.target_date.join(",") : undefined,
|
||||
sub_issue: "false",
|
||||
};
|
||||
|
||||
const { data: projectSpreadsheetIssues, mutate: mutateProjectSpreadsheetIssues } = useSWR(
|
||||
workspaceSlug && projectId
|
||||
? PROJECT_ISSUES_LIST_WITH_PARAMS(projectId.toString(), params)
|
||||
: null,
|
||||
workspaceSlug && projectId
|
||||
? () =>
|
||||
issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: cycleSpreadsheetIssues, mutate: mutateCycleSpreadsheetIssues } = useSWR(
|
||||
workspaceSlug && projectId && cycleId
|
||||
? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), params)
|
||||
: null,
|
||||
workspaceSlug && projectId && cycleId
|
||||
? () =>
|
||||
cyclesService.getCycleIssuesWithParams(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
cycleId.toString(),
|
||||
params
|
||||
)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: moduleSpreadsheetIssues, mutate: mutateModuleSpreadsheetIssues } = useSWR(
|
||||
workspaceSlug && projectId && moduleId
|
||||
? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), params)
|
||||
: null,
|
||||
workspaceSlug && projectId && moduleId
|
||||
? () =>
|
||||
modulesService.getModuleIssuesWithParams(
|
||||
workspaceSlug.toString(),
|
||||
projectId.toString(),
|
||||
moduleId.toString(),
|
||||
params
|
||||
)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: viewSpreadsheetIssues, mutate: mutateViewSpreadsheetIssues } = useSWR(
|
||||
workspaceSlug && projectId && viewId && params ? VIEW_ISSUES(viewId.toString(), params) : null,
|
||||
workspaceSlug && projectId && viewId && params
|
||||
? () =>
|
||||
issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params)
|
||||
: null
|
||||
);
|
||||
|
||||
const spreadsheetIssues = cycleId
|
||||
? (cycleSpreadsheetIssues as IIssue[])
|
||||
: moduleId
|
||||
? (moduleSpreadsheetIssues as IIssue[])
|
||||
: viewId
|
||||
? (viewSpreadsheetIssues as IIssue[])
|
||||
: (projectSpreadsheetIssues as IIssue[]);
|
||||
|
||||
return {
|
||||
displayFilters,
|
||||
setDisplayFilters,
|
||||
mutateIssues: cycleId
|
||||
? mutateCycleSpreadsheetIssues
|
||||
: moduleId
|
||||
? mutateModuleSpreadsheetIssues
|
||||
: viewId
|
||||
? mutateViewSpreadsheetIssues
|
||||
: mutateProjectSpreadsheetIssues,
|
||||
spreadsheetIssues: spreadsheetIssues ?? [],
|
||||
filters,
|
||||
setFilters,
|
||||
params,
|
||||
resetFilterToDefault,
|
||||
setNewFilterDefaultView,
|
||||
} as const;
|
||||
};
|
||||
|
||||
export default useSpreadsheetIssuesView;
|
||||
|
|
@ -1,16 +1,16 @@
|
|||
import { useEffect, useState } from "react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import issuesService from "services/issues.service";
|
||||
import { IssueService } from "services/issue";
|
||||
// types
|
||||
import { ISubIssueResponse } from "types";
|
||||
// fetch-keys
|
||||
import { SUB_ISSUES } from "constants/fetch-keys";
|
||||
|
||||
const issueService = new IssueService();
|
||||
|
||||
const useSubIssue = (projectId: string, issueId: string, isExpanded: boolean) => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug } = router.query;
|
||||
|
|
@ -19,10 +19,7 @@ const useSubIssue = (projectId: string, issueId: string, isExpanded: boolean) =>
|
|||
|
||||
const { data: subIssuesResponse, isLoading } = useSWR<ISubIssueResponse>(
|
||||
shouldFetch ? SUB_ISSUES(issueId as string) : null,
|
||||
shouldFetch
|
||||
? () =>
|
||||
issuesService.subIssues(workspaceSlug as string, projectId as string, issueId as string)
|
||||
: null
|
||||
shouldFetch ? () => issueService.subIssues(workspaceSlug as string, projectId as string, issueId as string) : null
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -6,10 +6,13 @@ import useSWR from "swr";
|
|||
// keys
|
||||
import { CURRENT_USER } from "constants/fetch-keys";
|
||||
// services
|
||||
import userService from "services/user.service";
|
||||
import workspaceService from "services/workspace.service";
|
||||
import { UserService } from "services/user.service";
|
||||
import { WorkspaceService } from "services/workspace.service";
|
||||
// types
|
||||
import type { IWorkspace, ICurrentUserResponse } from "types";
|
||||
import type { IWorkspace, IUser } from "types";
|
||||
|
||||
const userService = new UserService();
|
||||
const workspaceService = new WorkspaceService();
|
||||
|
||||
const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "admin") => {
|
||||
const router = useRouter();
|
||||
|
|
@ -22,7 +25,7 @@ const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "adm
|
|||
isLoading,
|
||||
error,
|
||||
mutate,
|
||||
} = useSWR<ICurrentUserResponse>(CURRENT_USER, () => userService.currentUser(), {
|
||||
} = useSWR<IUser>(CURRENT_USER, () => userService.currentUser(), {
|
||||
refreshInterval: 0,
|
||||
shouldRetryOnError: false,
|
||||
});
|
||||
|
|
@ -109,8 +112,8 @@ const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "adm
|
|||
isLoading: isRouteAccess,
|
||||
user: error ? undefined : user,
|
||||
mutateUser: mutate,
|
||||
assignedIssuesLength: user?.assigned_issues ?? 0,
|
||||
workspaceInvitesLength: user?.workspace_invites ?? 0,
|
||||
// assignedIssuesLength: user?.assigned_issues ?? 0,
|
||||
// workspaceInvitesLength: user?.workspace_invites ?? 0,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,25 +1,21 @@
|
|||
import { useMemo, useState } from "react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
// swr
|
||||
import useSWR from "swr";
|
||||
import useSWRInfinite from "swr/infinite";
|
||||
|
||||
// services
|
||||
import userNotificationServices from "services/notifications.service";
|
||||
|
||||
import { NotificationService } from "services/notification.service";
|
||||
// hooks
|
||||
import useToast from "./use-toast";
|
||||
|
||||
// fetch-keys
|
||||
import { UNREAD_NOTIFICATIONS_COUNT, getPaginatedNotificationKey } from "constants/fetch-keys";
|
||||
|
||||
// type
|
||||
import type { NotificationType, NotificationCount, IMarkAllAsReadPayload } from "types";
|
||||
|
||||
const PER_PAGE = 30;
|
||||
|
||||
const userNotificationServices = new NotificationService();
|
||||
|
||||
const useUserNotification = () => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug } = router.query;
|
||||
|
|
@ -30,9 +26,7 @@ const useUserNotification = () => {
|
|||
const [archived, setArchived] = useState<boolean>(false);
|
||||
const [readNotification, setReadNotification] = useState<boolean>(false);
|
||||
const [fetchNotifications, setFetchNotifications] = useState<boolean>(false);
|
||||
const [selectedNotificationForSnooze, setSelectedNotificationForSnooze] = useState<string | null>(
|
||||
null
|
||||
);
|
||||
const [selectedNotificationForSnooze, setSelectedNotificationForSnooze] = useState<string | null>(null);
|
||||
const [selectedTab, setSelectedTab] = useState<NotificationType>("assigned");
|
||||
|
||||
const params = useMemo(
|
||||
|
|
@ -55,26 +49,20 @@ const useUserNotification = () => {
|
|||
mutate: notificationMutate,
|
||||
} = useSWRInfinite(
|
||||
fetchNotifications && workspaceSlug
|
||||
? (index, prevData) =>
|
||||
getPaginatedNotificationKey(index, prevData, workspaceSlug.toString(), params)
|
||||
? (index, prevData) => getPaginatedNotificationKey(index, prevData, workspaceSlug.toString(), params)
|
||||
: () => null,
|
||||
async (url: string) => await userNotificationServices.getNotifications(url)
|
||||
);
|
||||
|
||||
const isLoadingMore =
|
||||
isLoading || (size > 0 && paginatedData && typeof paginatedData[size - 1] === "undefined");
|
||||
const isLoadingMore = isLoading || (size > 0 && paginatedData && typeof paginatedData[size - 1] === "undefined");
|
||||
const isEmpty = paginatedData?.[0]?.results?.length === 0;
|
||||
const notifications = paginatedData ? paginatedData.map((d) => d.results).flat() : undefined;
|
||||
const hasMore =
|
||||
isEmpty || (paginatedData && paginatedData[paginatedData.length - 1].next_page_results);
|
||||
const hasMore = isEmpty || (paginatedData && paginatedData[paginatedData.length - 1].next_page_results);
|
||||
const isRefreshing = isValidating && paginatedData && paginatedData.length === size;
|
||||
|
||||
const { data: notificationCount, mutate: mutateNotificationCount } = useSWR(
|
||||
workspaceSlug ? UNREAD_NOTIFICATIONS_COUNT(workspaceSlug.toString()) : null,
|
||||
() =>
|
||||
workspaceSlug
|
||||
? userNotificationServices.getUnreadNotificationsCount(workspaceSlug.toString())
|
||||
: null
|
||||
() => (workspaceSlug ? userNotificationServices.getUnreadNotificationsCount(workspaceSlug.toString()) : null)
|
||||
);
|
||||
|
||||
const handleReadMutation = (action: "read" | "unread") => {
|
||||
|
|
@ -84,11 +72,7 @@ const useUserNotification = () => {
|
|||
if (!prev) return prev;
|
||||
|
||||
const notificationType: keyof NotificationCount =
|
||||
selectedTab === "assigned"
|
||||
? "my_issues"
|
||||
: selectedTab === "created"
|
||||
? "created_issues"
|
||||
: "watching_issues";
|
||||
selectedTab === "assigned" ? "my_issues" : selectedTab === "created" ? "created_issues" : "watching_issues";
|
||||
|
||||
return {
|
||||
...prev,
|
||||
|
|
@ -114,17 +98,14 @@ const useUserNotification = () => {
|
|||
|
||||
if (notificationIndexInPage === -1) return previousNotifications;
|
||||
|
||||
notificationIndexInPage =
|
||||
notificationIndexInPage === -1 ? 0 : notificationIndexInPage % PER_PAGE;
|
||||
notificationIndexInPage = notificationIndexInPage === -1 ? 0 : notificationIndexInPage % PER_PAGE;
|
||||
|
||||
if (notificationIndex === -1) return previousNotifications;
|
||||
|
||||
if (notificationIndexInPage === -1) return previousNotifications;
|
||||
|
||||
const key = Object.keys(value)[0];
|
||||
(previousNotifications[notificationIndex].results[notificationIndexInPage] as any)[key] = (
|
||||
value as any
|
||||
)[key];
|
||||
(previousNotifications[notificationIndex].results[notificationIndexInPage] as any)[key] = (value as any)[key];
|
||||
|
||||
return previousNotifications;
|
||||
}, false);
|
||||
|
|
@ -147,8 +128,7 @@ const useUserNotification = () => {
|
|||
|
||||
if (notificationIndexInPage === -1) return previousNotifications;
|
||||
|
||||
notificationIndexInPage =
|
||||
notificationIndexInPage === -1 ? 0 : notificationIndexInPage % PER_PAGE;
|
||||
notificationIndexInPage = notificationIndexInPage === -1 ? 0 : notificationIndexInPage % PER_PAGE;
|
||||
|
||||
if (notificationIndex === -1) return previousNotifications;
|
||||
|
||||
|
|
@ -163,8 +143,7 @@ const useUserNotification = () => {
|
|||
const markNotificationReadStatus = async (notificationId: string) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
const isRead =
|
||||
notifications?.find((notification) => notification.id === notificationId)?.read_at !== null;
|
||||
const isRead = notifications?.find((notification) => notification.id === notificationId)?.read_at !== null;
|
||||
|
||||
handleReadMutation(isRead ? "unread" : "read");
|
||||
mutateNotification(notificationId, { read_at: isRead ? null : new Date() });
|
||||
|
|
@ -193,28 +172,23 @@ const useUserNotification = () => {
|
|||
const markNotificationAsRead = async (notificationId: string) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
const isRead =
|
||||
notifications?.find((notification) => notification.id === notificationId)?.read_at !== null;
|
||||
const isRead = notifications?.find((notification) => notification.id === notificationId)?.read_at !== null;
|
||||
|
||||
if (isRead) return;
|
||||
|
||||
mutateNotification(notificationId, { read_at: new Date() });
|
||||
handleReadMutation("read");
|
||||
|
||||
await userNotificationServices
|
||||
.markUserNotificationAsRead(workspaceSlug.toString(), notificationId)
|
||||
.catch(() => {
|
||||
throw new Error("Something went wrong");
|
||||
});
|
||||
await userNotificationServices.markUserNotificationAsRead(workspaceSlug.toString(), notificationId).catch(() => {
|
||||
throw new Error("Something went wrong");
|
||||
});
|
||||
|
||||
mutateNotificationCount();
|
||||
};
|
||||
|
||||
const markNotificationArchivedStatus = async (notificationId: string) => {
|
||||
if (!workspaceSlug) return;
|
||||
const isArchived =
|
||||
notifications?.find((notification) => notification.id === notificationId)?.archived_at !==
|
||||
null;
|
||||
const isArchived = notifications?.find((notification) => notification.id === notificationId)?.archived_at !== null;
|
||||
|
||||
if (!isArchived) {
|
||||
handleReadMutation("read");
|
||||
|
|
@ -251,9 +225,7 @@ const useUserNotification = () => {
|
|||
const markSnoozeNotification = async (notificationId: string, dateTime?: Date) => {
|
||||
if (!workspaceSlug) return;
|
||||
|
||||
const isSnoozed =
|
||||
notifications?.find((notification) => notification.id === notificationId)?.snoozed_till !==
|
||||
null;
|
||||
const isSnoozed = notifications?.find((notification) => notification.id === notificationId)?.snoozed_till !== null;
|
||||
|
||||
mutateNotification(notificationId, { snoozed_till: isSnoozed ? null : dateTime });
|
||||
|
||||
|
|
@ -320,9 +292,7 @@ const useUserNotification = () => {
|
|||
selectedTab,
|
||||
setSelectedTab,
|
||||
totalNotificationCount: notificationCount
|
||||
? notificationCount.created_issues +
|
||||
notificationCount.watching_issues +
|
||||
notificationCount.my_issues
|
||||
? notificationCount.created_issues + notificationCount.watching_issues + notificationCount.my_issues
|
||||
: null,
|
||||
notificationCount,
|
||||
mutateNotificationCount,
|
||||
|
|
|
|||
|
|
@ -2,20 +2,19 @@ import { useEffect } from "react";
|
|||
import { useRouter } from "next/router";
|
||||
import useSWR from "swr";
|
||||
// services
|
||||
import userService from "services/user.service";
|
||||
import { UserService } from "services/user.service";
|
||||
// constants
|
||||
import { CURRENT_USER } from "constants/fetch-keys";
|
||||
// types
|
||||
import type { ICurrentUserResponse, IUser } from "types";
|
||||
import type { IUser } from "types";
|
||||
|
||||
// services
|
||||
const userService = new UserService();
|
||||
|
||||
export default function useUser({ redirectTo = "", redirectIfFound = false, options = {} } = {}) {
|
||||
const router = useRouter();
|
||||
// API to fetch user information
|
||||
const { data, isLoading, error, mutate } = useSWR<ICurrentUserResponse>(
|
||||
CURRENT_USER,
|
||||
() => userService.currentUser(),
|
||||
options
|
||||
);
|
||||
const { data, isLoading, error, mutate } = useSWR<IUser>(CURRENT_USER, () => userService.currentUser(), options);
|
||||
|
||||
const user = error ? undefined : data;
|
||||
|
||||
|
|
@ -48,7 +47,7 @@ export default function useUser({ redirectTo = "", redirectIfFound = false, opti
|
|||
isUserLoading: isLoading,
|
||||
mutateUser: mutate,
|
||||
userError: error,
|
||||
assignedIssuesLength: user?.assigned_issues ?? 0,
|
||||
workspaceInvitesLength: user?.workspace_invites ?? 0,
|
||||
// assignedIssuesLength: user?.assigned_issues ?? 0,
|
||||
// workspaceInvitesLength: user?.workspace_invites ?? 0,
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@ import { useEffect } from "react";
|
|||
import { useRouter } from "next/router";
|
||||
import useSWR from "swr";
|
||||
// services
|
||||
import workspaceService from "services/workspace.service";
|
||||
import { WorkspaceService } from "services/workspace.service";
|
||||
// fetch-keys
|
||||
import { WORKSPACE_DETAILS } from "constants/fetch-keys";
|
||||
|
||||
const workspaceService = new WorkspaceService();
|
||||
|
||||
const useWorkspaceDetails = () => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug } = router.query;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import useSWR from "swr";
|
||||
// services
|
||||
import workspaceService from "services/workspace.service";
|
||||
import { WorkspaceService } from "services/workspace.service";
|
||||
// fetch-keys
|
||||
import { WORKSPACE_MEMBERS } from "constants/fetch-keys";
|
||||
// hooks
|
||||
import useUser from "./use-user";
|
||||
|
||||
const workspaceService = new WorkspaceService();
|
||||
|
||||
const useWorkspaceMembers = (workspaceSlug: string | undefined, fetchCondition?: boolean) => {
|
||||
fetchCondition = fetchCondition ?? true;
|
||||
|
||||
|
|
@ -18,18 +20,10 @@ const useWorkspaceMembers = (workspaceSlug: string | undefined, fetchCondition?:
|
|||
|
||||
const hasJoined = workspaceMembers?.some((item: any) => item.member.id === (user as any)?.id);
|
||||
|
||||
const isOwner = workspaceMembers?.some(
|
||||
(item) => item.member.id === (user as any)?.id && item.role === 20
|
||||
);
|
||||
const isMember = workspaceMembers?.some(
|
||||
(item) => item.member.id === (user as any)?.id && item.role === 15
|
||||
);
|
||||
const isViewer = workspaceMembers?.some(
|
||||
(item) => item.member.id === (user as any)?.id && item.role === 10
|
||||
);
|
||||
const isGuest = workspaceMembers?.some(
|
||||
(item) => item.member.id === (user as any)?.id && item.role === 5
|
||||
);
|
||||
const isOwner = workspaceMembers?.some((item) => item.member.id === (user as any)?.id && item.role === 20);
|
||||
const isMember = workspaceMembers?.some((item) => item.member.id === (user as any)?.id && item.role === 15);
|
||||
const isViewer = workspaceMembers?.some((item) => item.member.id === (user as any)?.id && item.role === 10);
|
||||
const isGuest = workspaceMembers?.some((item) => item.member.id === (user as any)?.id && item.role === 5);
|
||||
|
||||
return {
|
||||
workspaceMembers,
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
import { useContext } from "react";
|
||||
// types
|
||||
import { IWorkspaceViewContext, WorkspaceIssueViewContext } from "contexts/workspace-view-context";
|
||||
|
||||
export const useWorkspaceView = (): IWorkspaceViewContext => {
|
||||
const context = useContext(WorkspaceIssueViewContext);
|
||||
|
||||
if (!context) throw new Error("useWorkspaceView must be used within a WorkspaceIssueViewContext");
|
||||
|
||||
return context;
|
||||
};
|
||||
|
|
@ -3,10 +3,12 @@ import { useRouter } from "next/router";
|
|||
import useSWR from "swr";
|
||||
|
||||
// services
|
||||
import workspaceService from "services/workspace.service";
|
||||
import { WorkspaceService } from "services/workspace.service";
|
||||
// fetch-keys
|
||||
import { USER_WORKSPACES } from "constants/fetch-keys";
|
||||
|
||||
const workspaceService = new WorkspaceService();
|
||||
|
||||
const useWorkspaces = () => {
|
||||
// router
|
||||
const router = useRouter();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue