#please help How can I update a table when an action is performed from another route?

1 messages · Page 1 of 1 (latest)

crimson sundial
#

im using useSubmit to upload the files ` const handleSubmit = (date: Date, requirements: string, event: React.FormEvent) => {
event.preventDefault();
const formData = new FormData();
formData.append("date", date.toISOString());
formData.append("requirements", requirements);
if (files) {
files.forEach((file) => formData.append("file", file));
}

submit(formData, {
  action: "/",
  method: "POST",
  encType: "multipart/form-data",
});

};`

#

In the admin route, I have a table where new documents should be shown, and when one is added, I want it to appear here:

`` export async function loader({ request }: LoaderFunctionArgs) {
const user = await authenticator.isAuthenticated(request);

if (!user) {
return redirect("/")
}

const documents = await prisma.document.findMany({
include: {
customer: {
select: { name: true },
},
},
orderBy: { createdAt: "desc" },
});

return documents;
}

export default function Admin() {
const documents = useLoaderData<typeof loader>();
return (
<>
<TableSort data={documents} />
<Outlet />
</>
);
}
`

night kestrel
#

Is the data persisting in the db?