29 lines
839 B
JavaScript
29 lines
839 B
JavaScript
import { defineStore } from "pinia";
|
|
import { gql } from "@/graphql";
|
|
|
|
export const useAnalyticsStore = defineStore("analytics", {
|
|
state: () => ({ data: null, loading: false, error: null }),
|
|
actions: {
|
|
async fetch() {
|
|
this.loading = true;
|
|
this.error = null;
|
|
try {
|
|
const result = await gql(`query DashboardAnalytics {
|
|
analytics {
|
|
totalApplications statusCounts { status count }
|
|
transitions { from to count }
|
|
responseCount interviewCount offerCount
|
|
responseRate interviewRate offerRate
|
|
averageDaysToResponse averageDaysToInterview averageDaysToOffer
|
|
}
|
|
}`);
|
|
this.data = result.analytics;
|
|
} catch (error) {
|
|
this.error = error;
|
|
} finally {
|
|
this.loading = false;
|
|
}
|
|
},
|
|
},
|
|
});
|