How to reuse data passed as parameters in another file

Viewed 24

In my request I have a message as a template, which I need to use by passing the form data using the React Hook Form lib. But I wanted to put this template in a separate file, the data is passed as a parameter of the submit function and sent in the body of the request.

What should I do to be able to use the form data in a separate file? For example, if I were to create a component for this and pass the data as props, I can't send a component in the body of the request. Also I can't pass a function in the body with all the data.

const handleSendMessage = async ({
    phone,
    entry,
    exit,
    collation,
    lunch,
    snack,
    dinner,
    descriptionRemedy,
    date,
    sleepDescription,
    evacuationDescription,
    ministeredBy,
  }: SendMessageData) => {
    const newDate = format(new Date(`${date}T21:00:00`), 'dd MMM yyyy', {
      locale: ptBR,
    });

    const bodyMessage = `Olá, Sr.Responsável!\n\n Estou aqui para lhe informar a rotina do aluno(a) no dia ${newDate}.\n\n

    A entrada do aluno(a) foi ás ${entry} e a saída ás ${exit}.
                          ---------@---------

    *-> Relatório de refeições:*
     
    ${
      collation
        ? `✅ Durante a colação ele(a) ${collation}.`
        : `❌ Durante a colação: (Não esteve presente)`
    }
       
    ${
      lunch
        ? `✅ Durante o almoço ele(a) ${lunch}.`
        : `❌ Durante o almoço: (Não esteve presente)`
    }
0 Answers
Related