Skip to content

Commit

Permalink
✨ feat(useCampaignInsights.ts): add useCampaignInsights hook to fetch…
Browse files Browse the repository at this point in the history
… campaign insights data
  • Loading branch information
marcbon committed Jul 20, 2023
1 parent 2dee0b9 commit c48215d
Showing 1 changed file with 109 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
interface Insight {
id: number;
title: string;
description: string;
severity: {
id: number;
name: string;
};
cluster:
| string
| {
id: number;
name: string;
}[];
videoPart: {
id: number;
start: number;
end: number;
mediaId: number;
url: string;
streamUrl: string;
description: string;
}[];
}

export const useCampaignInsights = ({
campaignId,

Check warning on line 27 in src/pages/Campaign/useWidgets/Experience/widgets/Insights/useCampaignInsights.ts

View workflow job for this annotation

GitHub Actions / validate

'campaignId' is defined but never used
}: {
campaignId: number;
}): {
data: {
insights: Insight[];
};
isLoading: boolean;
} => {
const isLoading = false;

if (isLoading) {
return {
data: {
insights: [],
},
isLoading: true,
};
}

const results = {
insights: [
{
id: 1,
title: 'My insight',
description: 'This is an insight',
severity: {
id: 1,
name: 'Minor',
},
cluster: 'all',
videoPart: [
{
id: 1,
start: 10,
end: 20,
mediaId: 1,
url: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
streamUrl:
'http://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8',
description: 'This is a video part',
},
],
},
{
id: 2,
title: 'My second insight',
description: 'This is another insight',
severity: {
id: 2,
name: 'Positive',
},
cluster: [
{
id: 1,
name: 'UC1: Cart',
},
{
id: 2,
name: 'UC2: Login',
},
],
videoPart: [
{
id: 2,
start: 15,
end: 25,
mediaId: 2,
url: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
streamUrl:
'http://sample.vodobox.net/skate_phantom_flex_4k/skate_phantom_flex_4k.m3u8',
description: 'This is a video part',
},
],
},
],
};

return {
data: results,
isLoading: false,
};
};

0 comments on commit c48215d

Please sign in to comment.