-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Projects management | Create New Project (#3615)
* add 'create project form' * add 'financial settings form' * add 'categorization form' * add a reusable select (mono/multi) for the creation steps * add the final review view * add summary review , validations & dark mode * finish validations & project creation flow * connect the project creation flow with the api * create image assets for the new project * fix spell typo * clean up ..., internationalization * add coderabit suggestions
- Loading branch information
Showing
35 changed files
with
2,986 additions
and
33 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
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,72 @@ | ||
import { ITag } from '@app/interfaces'; | ||
import { createTagAPI, deleteTagAPI, getTagsAPI, updateTagAPI } from '@app/services/client/api'; | ||
import { useCallback } from 'react'; | ||
import { useAtom } from 'jotai'; | ||
import { useQuery } from '../useQuery'; | ||
import cloneDeep from 'lodash/cloneDeep'; | ||
import { tagsState } from '@/app/stores/tags'; | ||
|
||
export const useTags = () => { | ||
const [tags, setTags] = useAtom(tagsState); | ||
|
||
const { loading, queryCall: getTagsQueryCall } = useQuery(getTagsAPI); | ||
const { loading: createTagLoading, queryCall: createTagQueryCall } = useQuery(createTagAPI); | ||
const { loading: updateTagLoading, queryCall: updateTagQueryCall } = useQuery(updateTagAPI); | ||
const { loading: deleteTagLoading, queryCall: deleteTagQueryCall } = useQuery(deleteTagAPI); | ||
|
||
const getTags = useCallback(() => { | ||
getTagsQueryCall().then((response) => { | ||
if (response.data.items.length) { | ||
setTags(response.data.items); | ||
} | ||
}); | ||
}, [getTagsQueryCall, setTags]); | ||
|
||
const createTag = useCallback( | ||
async (tag: Omit<ITag, 'id'>) => { | ||
return createTagQueryCall(tag).then((response) => { | ||
setTags((prevTags) => [response.data, ...prevTags]); | ||
}); | ||
}, | ||
[createTagQueryCall, setTags] | ||
); | ||
|
||
const updateTag = useCallback( | ||
async (tag: ITag) => { | ||
updateTagQueryCall(tag).then(() => { | ||
const index = tags.findIndex((item) => item.id === tag.id); | ||
const tempTags = cloneDeep(tags); | ||
if (index >= 0) { | ||
tempTags[index].name = tag.name; | ||
} | ||
|
||
setTags(tempTags); | ||
}); | ||
}, | ||
[tags, setTags, updateTagQueryCall] | ||
); | ||
|
||
const deleteTag = useCallback( | ||
async (id: string) => { | ||
deleteTagQueryCall(id).then(() => { | ||
setTags(tags.filter((tag) => tag.id !== id)); | ||
}); | ||
}, | ||
[deleteTagQueryCall, setTags, tags] | ||
); | ||
|
||
return { | ||
tags, | ||
loading, | ||
getTags, | ||
|
||
createTag, | ||
createTagLoading, | ||
|
||
deleteTag, | ||
deleteTagLoading, | ||
|
||
updateTag, | ||
updateTagLoading | ||
}; | ||
}; |
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,10 @@ | ||
export enum RolesEnum { | ||
SUPER_ADMIN = 'SUPER_ADMIN', | ||
ADMIN = 'ADMIN', | ||
DATA_ENTRY = 'DATA_ENTRY', | ||
EMPLOYEE = 'EMPLOYEE', | ||
CANDIDATE = 'CANDIDATE', | ||
MANAGER = 'MANAGER', | ||
VIEWER = 'VIEWER', | ||
INTERVIEWER = 'INTERVIEWER' | ||
} |
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,7 +1,6 @@ | ||
import { IProject, IProjectCreate } from '@app/interfaces'; | ||
import { ICreateProjectInput, IProject } from '@app/interfaces'; | ||
import { post } from '../axios'; | ||
|
||
export function createOrganizationProjectAPI(data: IProjectCreate) { | ||
|
||
export function createOrganizationProjectAPI(data: Partial<ICreateProjectInput>) { | ||
return post<IProject>(`/organization-projects`, data); | ||
} |
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,30 @@ | ||
import { ITag, PaginationResponse } from '@app/interfaces'; | ||
import { deleteApi, get, post, put } from '../axios'; | ||
import { getOrganizationIdCookie, getTenantIdCookie } from '@/app/helpers'; | ||
import qs from 'qs'; | ||
|
||
export function getTagsAPI() { | ||
const organizationId = getOrganizationIdCookie(); | ||
const tenantId = getTenantIdCookie(); | ||
|
||
const obj = { | ||
'where[organizationId]': organizationId, | ||
'where[tenantId]': tenantId | ||
} as Record<string, string>; | ||
|
||
const query = qs.stringify(obj); | ||
|
||
return get<PaginationResponse<ITag>>(`/tags?${query}`); | ||
} | ||
|
||
export function createTagAPI(data: Omit<ITag, 'id'>) { | ||
return post<ITag>('/tags', data); | ||
} | ||
|
||
export function deleteTagAPI(id: string) { | ||
return deleteApi<ITag>(`/tags/${id}`); | ||
} | ||
|
||
export function updateTagAPI(data: ITag) { | ||
return put<ITag>(`/tags/${data.id}`, data); | ||
} |
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 { ITag } from '@app/interfaces/'; | ||
import { atom } from 'jotai'; | ||
|
||
export const tagsState = atom<ITag[]>([]); |
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.