-
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.
add project in task details page / possiblity to edit
- Loading branch information
Showing
24 changed files
with
499 additions
and
231 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[]>([]) |
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
Oops, something went wrong.