fix Owliver ai chat
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import * as React from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { base44 } from '@/api/base44Client';
|
||||
import {
|
||||
useApplications, useCourses, useInterviews, useJobPostings, useStaff,
|
||||
useUserActivity, useWorkerProfile, useWorkerProfiles,
|
||||
useUserActivity, useWorkerProfiles,
|
||||
} from '@/lib/krowHooks';
|
||||
import { buildFacts } from './insights';
|
||||
import { createAssistantProvider } from './provider';
|
||||
@@ -14,7 +16,7 @@ const provider = createAssistantProvider();
|
||||
* costs no extra requests and cannot be looking at a different snapshot than the
|
||||
* card beside it.
|
||||
*/
|
||||
export function useAssistantFacts({ needsWorkerProfile = false } = {}) {
|
||||
export function useAssistantFacts() {
|
||||
const { data: applications = [] } = useApplications();
|
||||
const { data: postings = [] } = useJobPostings();
|
||||
const { data: interviews = [] } = useInterviews();
|
||||
@@ -23,19 +25,30 @@ export function useAssistantFacts({ needsWorkerProfile = false } = {}) {
|
||||
const { data: activity = [] } = useUserActivity();
|
||||
const { data: courses = [] } = useCourses();
|
||||
|
||||
// Gated: this query creates the record if absent, so it must not run for
|
||||
// employer or admin sessions.
|
||||
const { data: profile = null } = useWorkerProfile({ enabled: needsWorkerProfile });
|
||||
|
||||
// Krow AI serves Employer and Admin only, so it never reads the signed-in
|
||||
// worker's own profile — that query also creates the record if absent, and it
|
||||
// belongs to the talent portal, not here.
|
||||
return React.useMemo(
|
||||
() => buildFacts({
|
||||
applications, postings, interviews, staff, profiles, activity, courses,
|
||||
profile: needsWorkerProfile ? profile : null,
|
||||
}),
|
||||
[applications, postings, interviews, staff, profiles, activity, courses, profile, needsWorkerProfile]
|
||||
() => buildFacts({ applications, postings, interviews, staff, profiles, activity, courses }),
|
||||
[applications, postings, interviews, staff, profiles, activity, courses]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The signed-in user's first name, for personalizing the greeting.
|
||||
*
|
||||
* Shares the `['user']` query key with the rest of the app, so this is a cache
|
||||
* read rather than another request.
|
||||
*/
|
||||
export function useCurrentUserName() {
|
||||
const { data } = useQuery({
|
||||
queryKey: ['user'],
|
||||
queryFn: () => base44.auth.me().catch(() => null),
|
||||
staleTime: Infinity,
|
||||
});
|
||||
return data?.full_name || '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Conversation state for one page context.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user