Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions packages/support/src/hooks/case.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ const CaseCommentFirstResponseTrigger: Hook = {
const responseTimeMinutes = Math.floor((now.getTime() - createdDate.getTime()) / (1000 * 60));

// Update case with first response info
await ctx.db.update('Case', caseRecord[0].id, {
await ctx.db.doc.update('Case', caseRecord[0].id, {
FirstResponseTime: now,
ResponseTimeMinutes: responseTimeMinutes
});

// Update comment
await ctx.db.update('CaseComment', comment.id, {
await ctx.db.doc.update('CaseComment', comment.id, {
IsFirstResponse: true,
ResponseTimeMinutes: responseTimeMinutes
});
Expand All @@ -259,7 +259,7 @@ async function findApplicableSLAPolicy(caseRecord: any, ctx: TriggerContext): Pr
['IsActive', '=', true],
['IsLatestVersion', '=', true]
],
sort: [['Priority', 'asc']],
sort: 'Priority',
limit: 100
});

Expand Down Expand Up @@ -338,7 +338,7 @@ async function createSLAMilestones(caseRecord: any, policy: any, ctx: TriggerCon

// Create milestones
for (const milestone of milestones) {
await ctx.db.create('SLAMilestone', milestone);
await ctx.db.doc.create('SLAMilestone', milestone);
}
}

Expand Down Expand Up @@ -372,7 +372,7 @@ async function updateSLAViolationStatus(caseRecord: any, ctx: TriggerContext): P
async function findMatchingRoutingRule(caseRecord: any, ctx: TriggerContext): Promise<any> {
const rules = await ctx.db.find('RoutingRule', {
filters: [['IsActive', '=', true]],
sort: [['Priority', 'asc']],
sort: 'Priority',
limit: 100
});

Expand Down Expand Up @@ -433,7 +433,7 @@ async function findBestAgent(caseRecord: any, routingRule: any, ctx: TriggerCont
async function findApplicableEscalationRule(caseRecord: any, ctx: TriggerContext): Promise<any> {
const rules = await ctx.db.find('EscalationRule', {
filters: [['IsActive', '=', true]],
sort: [['EscalationLevel', 'asc']],
sort: 'EscalationLevel',
limit: 100
});

Expand Down Expand Up @@ -476,7 +476,7 @@ function shouldAutoEscalate(caseRecord: any, oldCase: any): boolean {

async function executeEscalation(caseRecord: any, rule: any, ctx: TriggerContext): Promise<void> {
// Update case with escalation info
await ctx.db.update('Case', caseRecord.id, {
await ctx.db.doc.update('Case', caseRecord.id, {
IsEscalated: true,
EscalatedDate: new Date(),
EscalationLevel: (caseRecord.EscalationLevel || 0) + 1,
Expand All @@ -485,7 +485,7 @@ async function executeEscalation(caseRecord: any, rule: any, ctx: TriggerContext
});

// Update rule statistics
await ctx.db.update('EscalationRule', rule.id, {
await ctx.db.doc.update('EscalationRule', rule.id, {
TimesTriggered: (rule.TimesTriggered || 0) + 1,
LastTriggeredDate: new Date()
});
Expand All @@ -506,7 +506,7 @@ async function updateSLAMilestone(caseId: string, milestoneType: string, complet
const targetDate = new Date(milestone.TargetDateTime);
const isViolated = completedDate > targetDate;

await ctx.db.update('SLAMilestone', milestone.id, {
await ctx.db.doc.update('SLAMilestone', milestone.id, {
Status: isViolated ? 'Violated' : 'Completed',
ActualDateTime: completedDate,
IsViolated: isViolated
Expand Down
6 changes: 3 additions & 3 deletions packages/support/src/hooks/knowledge.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const KnowledgeArticleWorkflowTrigger: Hook = {
const oldArticle = ctx.old;

// Track status changes
if (oldArticle.Status !== article.Status) {
if (oldArticle && oldArticle.Status !== article.Status) {
await trackStatusChange(article, oldArticle, ctx);
}

Expand Down Expand Up @@ -166,7 +166,7 @@ const KnowledgeArticleUsageTracker: Hook = {
const oldCase = ctx.old;

// Track when case is resolved and knowledge was used
if (caseRecord.Status === 'Resolved' && oldCase.Status !== 'Resolved') {
if (oldCase && caseRecord.Status === 'Resolved' && oldCase.Status !== 'Resolved') {
if (caseRecord.AIRelatedKnowledge) {
const articleIds = caseRecord.AIRelatedKnowledge.split(',');

Expand Down Expand Up @@ -517,7 +517,7 @@ async function incrementArticleUsage(articleId: string, ctx: TriggerContext): Pr

if (article && article.length > 0) {
const currentCount = article[0].CaseResolutionCount || 0;
await ctx.db.update('KnowledgeArticle', articleId, {
await ctx.db.doc.update('KnowledgeArticle', articleId, {
CaseResolutionCount: currentCount + 1,
LastUsedInCaseDate: new Date()
});
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/dashboard/sales_intelligence.dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ const SalesIntelligenceDashboard: Dashboard = {
// ========================================================================
{
title: '🚨 At-Risk Deals',
type: 'list',
type: 'table',
object: 'Opportunity',
filter: {
$and: [
Expand Down Expand Up @@ -346,7 +346,7 @@ const SalesIntelligenceDashboard: Dashboard = {
// ========================================================================
{
title: '✨ AI-Identified Opportunities',
type: 'list',
type: 'table',
object: 'Opportunity',
filter: {
$and: [
Expand Down
Loading