Skip to content

Commit

Permalink
removed console.log which were all over the place for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Smef committed Jun 10, 2024
1 parent 5d9e4d2 commit 189b637
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 20 deletions.
8 changes: 0 additions & 8 deletions src/runtime/composables/useForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export default function useForm<TForm extends FormDataType>(
const _options = {
...options,
onBefore: () => {
console.log("onBefore");
this.wasSuccessful = false;
this.recentlySuccessful = false;
clearTimeout(recentlySuccessfulTimeoutId);
Expand All @@ -136,7 +135,6 @@ export default function useForm<TForm extends FormDataType>(
}
},
onStart: (visit) => {
console.log("onStart", visit);
this.processing = true;

if (options.onStart) {
Expand All @@ -151,7 +149,6 @@ export default function useForm<TForm extends FormDataType>(
}
},
onSuccess: async (response) => {
console.log("onSuccess", response);
this.processing = false;
this.progress = null;
this.clearErrors();
Expand All @@ -165,7 +162,6 @@ export default function useForm<TForm extends FormDataType>(
return onSuccess;
},
onError: (errors) => {
console.log("onError", errors);
this.processing = false;
this.progress = null;
this.clearErrors().setError(errors);
Expand All @@ -175,7 +171,6 @@ export default function useForm<TForm extends FormDataType>(
}
},
onFinish: (visit) => {
console.log("onFinish");
this.processing = false;
this.progress = null;

Expand All @@ -197,12 +192,9 @@ export default function useForm<TForm extends FormDataType>(
method: method,
body: data,
onRequest: async ({ request, options }) => {
console.log("oFetch onRequest", request, options);

await _options.onStart();
},
onResponse: async ({ response }) => {
console.log("onResponse");
// onResponse is always called, even if there was an errors
// return early so we don't execute both this and onResponseError
if (!response.ok) {
Expand Down
9 changes: 0 additions & 9 deletions src/runtime/composables/usePrecognitionForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export default function usePrecognitionForm<Data extends Record<string, unknown>
}

async function validate(fieldName: string) {
console.log("validate", fieldName);
// check if the fieldName is an array
let onlyFieldsToValidate;
const transformedData = this.transform(this.data());
Expand All @@ -39,26 +38,21 @@ async function validate(fieldName: string) {

const defaultOptions = {
onStart: () => {
console.log("precognition onStart");
this.validating = true;
},
onSuccess: async (response) => {
console.log("precognition onSuccess", response);
this.clearErrors();
},
onError: (errors) => {
console.log("precognitionOnError", errors);
this.setError(errors);
},
onFinish: () => {
console.log("precognitionOnFinish");
this.validating = false;
},
};

const validateOnly = Object.keys(onlyFieldsToValidate).join();

console.log("precognition oFetch");
try {
await $fetch(this.url, {
method: this.method,
Expand All @@ -68,8 +62,6 @@ async function validate(fieldName: string) {
},
body: onlyFieldsToValidate,
onRequest: async ({ request, options }) => {
console.log("precognition oFetch onRequest", request, options);

await defaultOptions.onStart();
},
onResponse: async (context: FetchContext & { response: FetchResponse<R> }): Promise<void> | void => {
Expand All @@ -81,7 +73,6 @@ async function validate(fieldName: string) {
await this.clearErrors(validateOnly);
},
onResponseError: async ({ response }) => {
console.log("precognition onResponseError");
const errors = response._data.data?.errors;
await defaultOptions.onError(errors);
await defaultOptions.onFinish();
Expand Down
3 changes: 0 additions & 3 deletions src/runtime/server/utils/definePrecognitionEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ const precognitionEventHandler = <T extends EventHandlerRequest, D>(
): EventHandler<T, D> =>
defineEventHandler<T>(async (event) => {
// do something before the route handler
console.log("starting precognition event handler");
const headers = getHeaders(event);

if (!headers.precognition) {
// this is not a precognition event
// return the regular response
console.log("Regular event handler running");

return handler(event);
}
Expand All @@ -25,7 +23,6 @@ const precognitionEventHandler = <T extends EventHandlerRequest, D>(
const fieldsToValidate = validateOnlyHeader ? validateOnlyHeader.split(",") : [];

// this is a precognition event
console.log("Handling precognition event...");
return await processPrecognitionRequest(event, zodObject, fieldsToValidate);
});

Expand Down

0 comments on commit 189b637

Please sign in to comment.