-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/42-dealPage
- Loading branch information
Showing
24 changed files
with
2,243 additions
and
2,153 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,15 @@ | ||
// import { axiosClient } from '../AxiosClient'; | ||
import axios from 'axios'; | ||
|
||
import { ICVDataProps } from '@finnect/interface/CompanyInterface'; | ||
|
||
export const useGetCVData = async (): Promise<ICVDataProps> => { | ||
try { | ||
const response = await axios.get(`/api/workspaces/views/company`); | ||
|
||
return response.data; | ||
} catch (error) { | ||
console.error(error); | ||
throw error; | ||
} | ||
}; |
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,17 @@ | ||
// import { axiosClient } from '../AxiosClient'; | ||
import axios from 'axios'; | ||
|
||
import { ICVDetailDataProps } from '@finnect/interface/CompanyInterface'; | ||
|
||
export const GetCVDetailData = async ( | ||
companyId: number | ||
): Promise<ICVDetailDataProps> => { | ||
try { | ||
const response = await axios.get(`/api/workspaces/companies/${companyId}`); | ||
|
||
return response.data; | ||
} catch (error) { | ||
console.error(error); | ||
throw error; | ||
} | ||
}; |
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,19 @@ | ||
// import { axiosClient } from '../AxiosClient'; | ||
import axios from 'axios'; | ||
|
||
import { ICVPDetailDataProps } from '@finnect/interface/CompanyInterface'; | ||
|
||
export const GetCVPDetailData = async ( | ||
companyId: number | ||
): Promise<ICVPDetailDataProps> => { | ||
try { | ||
const response = await axios.get( | ||
`/api/workspaces/companies?companyId=${companyId}` | ||
); | ||
|
||
return response.data; | ||
} catch (error) { | ||
console.error(error); | ||
throw error; | ||
} | ||
}; |
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,22 @@ | ||
import { ColDef } from 'ag-grid-community'; | ||
import { atom } from 'recoil'; | ||
|
||
import { IPRowData } from '@finnect/interface/CompanyInterface'; | ||
|
||
export const rowPDataState = atom<IPRowData[]>({ | ||
key: 'rowPDataState', | ||
default: [], | ||
}); | ||
|
||
export const columnPDefsState = atom<ColDef[]>({ | ||
key: 'columnPDefsState', | ||
default: [ | ||
{ | ||
headerName: 'Person', | ||
field: 'personName', | ||
}, | ||
{ headerName: 'Role', field: 'personRole' }, | ||
{ headerName: 'Email', field: 'personEmail' }, | ||
{ headerName: 'Phone', field: 'personPhone' }, | ||
], | ||
}); |
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,58 @@ | ||
// @finnect/hooks/custom-hooks/company/useCompanyData.ts | ||
import { useEffect } from 'react'; | ||
import { useRecoilState } from 'recoil'; | ||
import { | ||
rowDataState, | ||
columnDefsState, | ||
} from '@finnect/atoms/company/useCompany'; | ||
import { useGetCV } from '@finnect/hooks/queries/company/useGetCV'; | ||
|
||
import { RowData } from '@finnect/interface/CompanyInterface'; | ||
|
||
export const useCompanyViewData = () => { | ||
const [rowData, setRowData] = useRecoilState(rowDataState); | ||
const [columnDefs, setColumnDefs] = useRecoilState(columnDefsState); | ||
const { data, isPending, isError, error } = useGetCV(); | ||
|
||
useEffect(() => { | ||
if ( | ||
data && | ||
data.result && | ||
data.result.viewColumns && | ||
data.result.viewCompanies | ||
) { | ||
const columnsFromApi = data.result.viewColumns.map((col) => ({ | ||
headerName: col.columnName, | ||
field: col.columnName, | ||
sortable: true, | ||
filter: true, | ||
hide: col.hided, | ||
})); | ||
|
||
const combinedColumns = [...columnDefs, ...columnsFromApi]; | ||
|
||
const rows = data.result.viewCompanies.map((company) => { | ||
const row: RowData = { | ||
companyId: company.companyId, | ||
companyName: company.companyName, | ||
domain: company.domain, | ||
}; | ||
company.cells.forEach((cell) => { | ||
const column = data.result.viewColumns.find( | ||
(col) => col.columnId === cell.columnId | ||
); | ||
if (column) { | ||
row[column.columnName] = cell.value; | ||
} | ||
}); | ||
return row; | ||
}); | ||
|
||
setColumnDefs(combinedColumns); | ||
setRowData(rows); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [data]); | ||
|
||
return { rowData, columnDefs, isPending, isError, error }; | ||
}; |
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,13 @@ | ||
import { useGetCVData } from '@finnect/apis/companies/useGetCVData'; | ||
|
||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export const useGetCV = () => { | ||
const { data, isPending, isError, error, refetch } = useQuery({ | ||
queryKey: ['getCVData'], | ||
queryFn: useGetCVData, | ||
refetchOnMount: true, | ||
}); | ||
|
||
return { data, isPending, isError, error, refetch }; | ||
}; |
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,13 @@ | ||
import { GetCVDetailData } from '@finnect/apis/companies/useGetCVDetailData'; | ||
|
||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export const useGetCVD = (companyId: number) => { | ||
const { data, isPending, isError, error, refetch } = useQuery({ | ||
queryKey: ['getCVDData'], | ||
queryFn: () => GetCVDetailData(companyId), | ||
refetchOnMount: false, | ||
}); | ||
|
||
return { data, isPending, isError, error, refetch }; | ||
}; |
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,13 @@ | ||
import { GetCVPDetailData } from '@finnect/apis/companies/useGetCVPDetailData'; | ||
|
||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export const useGetCVP = (companyId: number) => { | ||
const { data, isPending, isError, error, refetch } = useQuery({ | ||
queryKey: ['getCVPData'], | ||
queryFn: () => GetCVPDetailData(companyId), | ||
refetchOnMount: false, | ||
}); | ||
|
||
return { data, isPending, isError, error, refetch }; | ||
}; |
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.