rubber-blueR
Refine•3y ago
rubber-blue

Howto set saveButtonProps.onClick correctly?

I am trying to overwrite the saveButtonProps.onClick function. However i cant quite get it:

  const reactHookFormMethods = useStepsForm<BaseRecord, HttpError, ExpenseStartupAPI>({
    refineCoreProps: {
      action: "edit",
      metaData: {
        populate: ["administration", "businessplan", "vermittlung","geschaeftsausstattung","weitereKosten"],
      },
    },   
  })
...

  const {handleSubmit, refineCore:{onFinish}} = reactHookFormMethods

  reactHookFormMethods.saveButtonProps.onClick = (e) => {
    console.log("saveButtonProps onclick is executed",e)
     handleSubmit((values) => {
        console.log("iam in hanldesubmit")
        const convertedDate = new Date(values.start).toJSON()
        values.start = convertedDate
        // @ts-ignore
        values.financialplan = 14
        console.log("🚀 ThIS DATA IS SENT TO BACKEND::::::::::::::::::: ~ file: edit.tsx:64 ~ handleSubmit ~ values", values)
        onFinish(values)
     })
  }

Inside another Component:
...
      <Edit
         isLoading={formLoading}
         saveButtonProps={saveButtonProps}
         ...
      />


The first console.log gets fired console.log("saveButtonProps onclick is executed",e)
However the second one is not reached

Can someone help thank you
Was this page helpful?