-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Show | Edit project information in the task details page (#…
…3347) * add project in task details page / possiblity to edit * Update apps/web/components/pages/task/details-section/blocks/task-secondary-info.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Ruslan Konviser <[email protected]> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
f89d96d
commit f37fac7
Showing
21 changed files
with
494 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,83 @@ | ||
import { | ||
editOrganizationProjectSettingAPI, | ||
editOrganizationProjectAPI | ||
editOrganizationProjectAPI, | ||
getOrganizationProjectAPI, | ||
getOrganizationProjectsAPI | ||
} from '@app/services/client/api'; | ||
import { userState } from '@app/stores'; | ||
import { useCallback } from 'react'; | ||
import { useAtom } from 'jotai'; | ||
import { useQuery } from '../useQuery'; | ||
import { organizationProjectsState } from '@/app/stores/organization-projects'; | ||
|
||
export function useOrganizationProjects() { | ||
const [user] = useAtom(userState); | ||
|
||
const { | ||
loading: editOrganizationProjectLoading, | ||
queryCall: editOrganizationProjectQueryCall | ||
} = useQuery(editOrganizationProjectAPI); | ||
|
||
const { | ||
loading: editOrganizationProjectSettingLoading, | ||
queryCall: editOrganizationProjectSettingQueryCall | ||
} = useQuery(editOrganizationProjectSettingAPI); | ||
|
||
const editOrganizationProjectSetting = useCallback( | ||
(id: string, data: any) => { | ||
if (user?.tenantId) { | ||
return editOrganizationProjectSettingQueryCall( | ||
id, | ||
data, | ||
user?.tenantId || '' | ||
).then((res) => { | ||
return res; | ||
}); | ||
} | ||
}, | ||
[user, editOrganizationProjectSettingQueryCall] | ||
); | ||
|
||
const editOrganizationProject = useCallback( | ||
(id: string, data: any) => { | ||
if (user?.tenantId) { | ||
return editOrganizationProjectQueryCall( | ||
id, | ||
data, | ||
user?.tenantId || '' | ||
).then((res) => { | ||
return res; | ||
}); | ||
} | ||
}, | ||
[user, editOrganizationProjectQueryCall] | ||
); | ||
|
||
return { | ||
editOrganizationProjectSetting, | ||
editOrganizationProjectSettingLoading, | ||
editOrganizationProject, | ||
editOrganizationProjectLoading | ||
}; | ||
const [user] = useAtom(userState); | ||
const [organizationProjects, setOrganizationProjects] = useAtom(organizationProjectsState); | ||
|
||
const { loading: editOrganizationProjectLoading, queryCall: editOrganizationProjectQueryCall } = | ||
useQuery(editOrganizationProjectAPI); | ||
|
||
const { loading: editOrganizationProjectSettingLoading, queryCall: editOrganizationProjectSettingQueryCall } = | ||
useQuery(editOrganizationProjectSettingAPI); | ||
|
||
const { loading: getOrganizationProjectLoading, queryCall: getOrganizationProjectQueryCall } = | ||
useQuery(getOrganizationProjectAPI); | ||
|
||
const { loading: getOrganizationProjectsLoading, queryCall: getOrganizationProjectsQueryCall } = | ||
useQuery(getOrganizationProjectsAPI); | ||
|
||
const editOrganizationProjectSetting = useCallback( | ||
(id: string, data: any) => { | ||
if (user?.tenantId) { | ||
return editOrganizationProjectSettingQueryCall(id, data, user?.tenantId || '').then((res) => { | ||
return res; | ||
}); | ||
} | ||
}, | ||
[user, editOrganizationProjectSettingQueryCall] | ||
); | ||
|
||
const editOrganizationProject = useCallback( | ||
(id: string, data: any) => { | ||
if (user?.tenantId) { | ||
return editOrganizationProjectQueryCall(id, data, user?.tenantId || '').then((res) => { | ||
return res; | ||
}); | ||
} | ||
}, | ||
[user, editOrganizationProjectQueryCall] | ||
); | ||
|
||
const getOrganizationProject = useCallback( | ||
async (id: string) => { | ||
try { | ||
return await getOrganizationProjectQueryCall(id); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}, | ||
[getOrganizationProjectQueryCall] | ||
); | ||
|
||
const getOrganizationProjects = useCallback(async () => { | ||
try { | ||
const res = await getOrganizationProjectsQueryCall(); | ||
|
||
setOrganizationProjects(res.data.items); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}, [getOrganizationProjectsQueryCall, setOrganizationProjects]); | ||
|
||
return { | ||
editOrganizationProjectSetting, | ||
editOrganizationProjectSettingLoading, | ||
editOrganizationProject, | ||
editOrganizationProjectLoading, | ||
getOrganizationProject, | ||
getOrganizationProjectLoading, | ||
getOrganizationProjects, | ||
getOrganizationProjectsLoading, | ||
organizationProjects, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { atom } from "jotai"; | ||
import { IProject } from "../interfaces"; | ||
|
||
export const organizationProjectsState = atom<IProject[]>([]) |
Oops, something went wrong.