123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- import { useRouter } from 'vue-router'
- import { EnumSystemImportSource } from '#shared/graphql/types.ts'
- import MutationHandler from '#shared/server/apollo/handler/MutationHandler.ts'
- import { useSystemImportConfigurationMutation } from '../graphql/mutations/systemImportConfiguration.api.ts'
- import { useImportSource } from './useImportSource.ts'
- import type { ImportSourceConfigurationBase } from '../types/setup-import.ts'
- export const useImportSourceConfiguration = <
- T extends ImportSourceConfigurationBase,
- >(
- source: EnumSystemImportSource,
- ) => {
- const router = useRouter()
- const { loading } = useImportSource()
- const configureSystemImportSource = (data: T) => {
- loading.value = true
- const systemImportConfigurationMutation = new MutationHandler(
- useSystemImportConfigurationMutation(),
- )
- let tlsVerify = true
- if (data.sslVerify !== undefined) {
- tlsVerify = data.sslVerify
- delete data.sslVerify
- }
- return systemImportConfigurationMutation
- .send({
- configuration: {
- ...data,
- source,
- tlsVerify,
- },
- })
- .then((result) => {
- if (result?.systemImportConfiguration?.success) {
-
- router.push(`/guided-setup/import/${source}/start`)
- }
- })
- .finally(() => {
- loading.value = false
- })
- }
- return {
- configureSystemImportSource,
- }
- }
|