/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import { MutationKey, useMutation, UseMutationResult, } from "@tanstack/react-query"; import { GustoEmbeddedCore } from "../core.js"; import { employeeEmploymentsCreateTermination } from "../funcs/employeeEmploymentsCreateTermination.js"; import { combineSignals } from "../lib/primitives.js"; import { RequestOptions } from "../lib/sdks.js"; import { GustoEmbeddedError } from "../models/errors/gustoembeddederror.js"; import { ConnectionError, InvalidRequestError, RequestAbortedError, RequestTimeoutError, UnexpectedClientError, } from "../models/errors/httpclienterrors.js"; import { NotFoundErrorObject } from "../models/errors/notfounderrorobject.js"; import { ResponseValidationError } from "../models/errors/responsevalidationerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import { UnprocessableEntityError } from "../models/errors/unprocessableentityerror.js"; import { PostV1EmployeesEmployeeIdTerminationsRequest, PostV1EmployeesEmployeeIdTerminationsResponse, } from "../models/operations/postv1employeesemployeeidterminations.js"; import { unwrapAsync } from "../types/fp.js"; import { useGustoEmbeddedContext } from "./_context.js"; import { MutationHookOptions } from "./_types.js"; export type EmployeeEmploymentsCreateTerminationMutationVariables = { request: PostV1EmployeesEmployeeIdTerminationsRequest; options?: RequestOptions; }; export type EmployeeEmploymentsCreateTerminationMutationData = PostV1EmployeesEmployeeIdTerminationsResponse; export type EmployeeEmploymentsCreateTerminationMutationError = | NotFoundErrorObject | UnprocessableEntityError | GustoEmbeddedError | ResponseValidationError | ConnectionError | RequestAbortedError | RequestTimeoutError | InvalidRequestError | UnexpectedClientError | SDKValidationError; /** * Create an employee termination * * @remarks * Create a termination for an employee. The only things required are an effective date (their last day of work) and whether they should receive their wages in a one-off termination payroll or with the rest of the company. * * Note that some states require employees to receive their final wages within 24 hours (unless they consent otherwise,) in which case running a one-off payroll may be the only option. * * scope: `employments:write` */ export function useEmployeeEmploymentsCreateTerminationMutation( options?: MutationHookOptions< EmployeeEmploymentsCreateTerminationMutationData, EmployeeEmploymentsCreateTerminationMutationError, EmployeeEmploymentsCreateTerminationMutationVariables >, ): UseMutationResult< EmployeeEmploymentsCreateTerminationMutationData, EmployeeEmploymentsCreateTerminationMutationError, EmployeeEmploymentsCreateTerminationMutationVariables > { const client = useGustoEmbeddedContext(); return useMutation({ ...buildEmployeeEmploymentsCreateTerminationMutation(client, options), ...options, }); } export function mutationKeyEmployeeEmploymentsCreateTermination(): MutationKey { return ["@gusto/embedded-api", "employeeEmployments", "createTermination"]; } export function buildEmployeeEmploymentsCreateTerminationMutation( client$: GustoEmbeddedCore, hookOptions?: RequestOptions, ): { mutationKey: MutationKey; mutationFn: ( variables: EmployeeEmploymentsCreateTerminationMutationVariables, ) => Promise; } { return { mutationKey: mutationKeyEmployeeEmploymentsCreateTermination(), mutationFn: function employeeEmploymentsCreateTerminationMutationFn({ request, options, }): Promise { const mergedOptions = { ...hookOptions, ...options, fetchOptions: { ...hookOptions?.fetchOptions, ...options?.fetchOptions, signal: combineSignals( hookOptions?.fetchOptions?.signal, options?.fetchOptions?.signal, ), }, }; return unwrapAsync(employeeEmploymentsCreateTermination( client$, request, mergedOptions, )); }, }; }