Skip to content

Commit

Permalink
fix: πŸ› tanstack mutate query raise false uncaught error
Browse files Browse the repository at this point in the history
βœ… Closes: #208
  • Loading branch information
growupanand committed Mar 3, 2024
1 parent c46eab4 commit 7828ac4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ export default function CreateFormButton({ workspace }: Readonly<Props>) {
});
const { isPending: isCreatingForm } = createForm;

const handleCreateForm = async (
formData: z.infer<typeof createFormSchema>,
) => {
await createForm.mutateAsync({
const handleCreateForm = (formData: z.infer<typeof createFormSchema>) => {
createForm.mutate({
...formData,
workspaceId: workspace.id,
organizationId: workspace.organizationId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export function FormListItem({ form }: Readonly<Props>) {
});
const isDeleting = deleteForm.isPending;

const handleDeleteForm = async () =>
deleteForm.mutateAsync({
const handleDeleteForm = () =>
deleteForm.mutate({
id: form.id,
});

Expand Down Expand Up @@ -110,7 +110,7 @@ export function FormListItem({ form }: Readonly<Props>) {
<ConfirmAction
title="Are you sure you want to delete this form?"
description="This action will delete all data related to this form. This action cannot be undone."
onConfirm={() => handleDeleteForm()}
onConfirm={handleDeleteForm}
confirmText="Yes, delete form"
>
<DropdownMenuItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ import {
} from "@/lib/validations/form";

type Props = {
onFormGenerated: (
formData: z.infer<typeof createFormSchema>,
) => Promise<void>;
onFormGenerated: (formData: z.infer<typeof createFormSchema>) => void;
isCreatingForm: boolean;
open: boolean;
setOpen: (open: boolean) => void;
Expand Down Expand Up @@ -78,7 +76,7 @@ export function GenerateForm({
isGeneratingFormData: false,
isGeneratedSuccessfully: true,
}));
await onFormGenerated({
onFormGenerated({
...newFormData,
formField: newFormData.formFields,
isAIGenerated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const WorkspaceHeader = ({ workspace }: Props) => {
});

const handleDeleteWorkspace = useCallback(
async () => deleteWorkspace.mutateAsync({ id: currentWorkspaceId }),
async () => deleteWorkspace.mutate({ id: currentWorkspaceId }),
[currentWorkspaceId],
);
const isDeleting = deleteWorkspace.isPending;
Expand All @@ -88,8 +88,8 @@ export const WorkspaceHeader = ({ workspace }: Props) => {
});

const handleUpdateWorkspace = useCallback(
async (name: string) =>
await updateWorkspace.mutateAsync({
(name: string) =>
updateWorkspace.mutate({
id: currentWorkspaceId,
name,
}),
Expand All @@ -100,7 +100,7 @@ export const WorkspaceHeader = ({ workspace }: Props) => {

const inputRef = useRef<HTMLInputElement>(null);

const handleWorkspaceNameInputChange = async (e: any) => {
const handleWorkspaceNameInputChange = (e: any) => {
const updatedName = e.target.value as string;
debounce(() => handleUpdateWorkspace(updatedName), 1000);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ export default function ChangeNameInput({ form, className }: Props) {
});
const isUpdating = updateForm.isPending;

const updateWorkspace = async (name: string) =>
updateForm.mutateAsync({
const updateWorkspace = (name: string) =>
updateForm.mutate({
id: form.id,
name,
});

const handleFormNameInputChange = async (e: any) => {
const handleFormNameInputChange = (e: any) => {
const updatedName = e.target.value as string;
debounce(() => updateWorkspace(updatedName), 1000);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function FormEditorCard({ form }: Readonly<Props>) {
const isFormBusy = updateForm.isPending;

const onSubmit = (formData: FormSubmitDataSchema) =>
updateForm.mutateAsync({
updateForm.mutate({
id: form.id,
...formData,
});
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/mainPage/navigationCardContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function NavigationCardContent({ orgId }: Readonly<Props>) {
const isCreatingWorkspace = createWorkspace.isPending;

const handleCreateWorkspace = useCallback(async () => {
await createWorkspace.mutateAsync({
await createWorkspace.mutate({
organizationId: orgId,
name: "New Workspace",
});
Expand Down

0 comments on commit 7828ac4

Please sign in to comment.