-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Visning av kundeansvalrlig og bugfixes #561
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,9 +37,16 @@ router.get('/customerCards', async (req, res, next) => { | |
try { | ||
const perProject = await getFileFromS3('perProject') | ||
const employeeCustomers = await getFileFromS3('employeeCustomers') | ||
const accountManager = await getFileFromS3('accountManager') | ||
const project_data = JSON.parse(perProject) | ||
const customer_data = JSON.parse(employeeCustomers) | ||
const aggregatedData = createCustomerCardData(project_data, customer_data) | ||
const accountManagerTable = JSON.parse(accountManager) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. legger også til account manager info |
||
|
||
const aggregatedData = createCustomerCardData( | ||
project_data, | ||
customer_data, | ||
accountManagerTable | ||
) | ||
res.send(aggregatedData) | ||
} catch (error) { | ||
next(error) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,15 +5,12 @@ import { | |
getHoursBilledPerCustomerCharts, | ||
getHoursBilledPerWeekCharts, | ||
} from './customerApi' | ||
import { CustomerData } from '../../../pages/customer/cards/CustomerCard' | ||
import { CustomerCardData } from './customerApiTypes' | ||
|
||
export const useCustomerCardsQuery = () => | ||
useSWR('/customerCards', getCustomerCards, { | ||
export const useCustomerCards = () => { | ||
const { data } = useSWR('/customerCards', getCustomerCards, { | ||
revalidateOnFocus: false, | ||
}) | ||
|
||
export const useCustomerCards = () => { | ||
const { data } = useCustomerCardsQuery() | ||
return data || [] | ||
} | ||
|
||
|
@@ -27,9 +24,21 @@ export const useHoursBilledPerCustomerCharts = () => | |
revalidateOnFocus: false, | ||
}) | ||
|
||
export const useAllCustomerData = (): CustomerData[] => { | ||
export const useAllCustomerData = (): CustomerCardData[] => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Vi har ikke antall konsulenter og timer for historiske kunder. Dette burde egentlig fikses. Kansje en forbedring er å hente historisk data sammen med customerCards også heller filtrere ut manglende konsulenter i front There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dette har jeg nå fikset ved å ta med historiske kunder i customerCard apiet og filtrere dem ut senere |
||
const { data: hoursBilledPerCustomer } = useHoursBilledPerCustomerCharts() | ||
return hoursBilledPerCustomer ? hoursBilledPerCustomer?.data : [] | ||
return ( | ||
hoursBilledPerCustomer?.data?.map( | ||
(cd): CustomerCardData => ({ | ||
customer: cd.customer, | ||
accountManager: undefined, | ||
consultantsLastPeriod: 0, | ||
consultantsLastLongPeriod: 0, | ||
billedLastPeriod: 0, | ||
billedLastLongPeriod: 0, | ||
billedTotal: 0, | ||
}) | ||
) || [] | ||
) | ||
} | ||
|
||
export const useHoursBilledPerWeekCharts = () => | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Før var antall ansatte, anta unike over 3 uker, mens antall timer var forige uke.
Nå deler vi opp begge datapunktene i enten 1 uke eller 4 uker og sender alt til frontenden.