base con autenticacion, registro, modulo encuestas
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
'use server';
|
||||
import { safeFetchApi } from '@/lib/fetch.api';
|
||||
import { SurveyStatisticsData } from '../schemas/statistics';
|
||||
import { SurveyStatisticsSchema } from '../schemas/statistics-schema';
|
||||
|
||||
|
||||
export const getSurveysStatistics = async (): Promise<SurveyStatisticsData> => {
|
||||
|
||||
const [error, data] = await safeFetchApi(
|
||||
SurveyStatisticsSchema,
|
||||
`surveys/statistics`,
|
||||
'GET',
|
||||
);
|
||||
|
||||
if (error) {
|
||||
console.log(error);
|
||||
// console.log(error.details);
|
||||
throw new Error('Ocurrio un error');
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
throw new Error('No statistics data available');
|
||||
}
|
||||
|
||||
return data?.data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user