{"size": 1947, "ext": "js", "max_stars_repo_path": "src/services/documents/service/doc_service.js", "max_stars_repo_name": "jauhari-i/Ukk_backend", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/services/documents/service/doc_service.js", "max_issues_repo_name": "jauhari-i/Ukk_backend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/services/documents/service/doc_service.js", "max_forks_repo_name": "jauhari-i/Ukk_backend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 20.28125, "max_line_length": 55, "alphanum_fraction": 0.5475089882}
import { INTERNAL_SERVER_ERROR, OK } from 'http-status'
import {
  excelUserQuery,
  excelStafQuery,
  excelLaporanQuery,
  pdfUserQuery,
} from '../query/doc_query'

export const excelUser = async () => {
  try {
    const query = await excelUserQuery()
    if (!query.error) {
      return {
        code: OK,
        message: 'Generate excel user success',
        success: true,
        url: query.file.secure_url,
      }
    } else {
      throw {
        code: INTERNAL_SERVER_ERROR,
        message: 'Internal server error',
        success: false,
      }
    }
  } catch (error) {
    return error
  }
}

export const excelStaf = async () => {
  try {
    const query = await excelStafQuery()
    if (!query.error) {
      return {
        code: OK,
        message: 'Generate excel staf success',
        success: true,
        url: query.file.secure_url,
      }
    } else {
      throw {
        code: INTERNAL_SERVER_ERROR,
        message: 'Internal server error',
        success: false,
      }
    }
  } catch (error) {
    return error
  }
}

export const excelReport = async () => {
  try {
    const query = await excelLaporanQuery()
    if (!query.error) {
      return {
        code: OK,
        message: 'Generate excel report success',
        success: true,
        url: query.file.secure_url,
      }
    } else {
      throw {
        code: INTERNAL_SERVER_ERROR,
        message: 'Internal server error',
        success: false,
      }
    }
  } catch (error) {
    return error
  }
}

export const pdfUser = async () => {
  try {
    const query = await pdfUserQuery()
    if (!query.error) {
      return {
        code: OK,
        message: 'Generate pdf user success',
        success: true,
        url: query.url,
      }
    } else {
      throw {
        code: INTERNAL_SERVER_ERROR,
        message: 'Internal server error',
        success: false,
      }
    }
  } catch (error) {
    return error
  }
}
