2023-01-08 17:14:46 +01:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const React = require("react");
|
|
|
|
|
|
|
|
const Loading = require("../../components/loading");
|
|
|
|
|
|
|
|
// Wrap Form component inside component that fires the RTK Query call,
|
|
|
|
// so Form will only be rendered when data is available to generate form-fields for
|
2023-01-13 00:33:39 +01:00
|
|
|
module.exports = function FormWithData({ dataQuery, DataForm, arg }) {
|
|
|
|
const { data, isLoading } = dataQuery(arg);
|
2023-01-08 17:14:46 +01:00
|
|
|
|
|
|
|
if (isLoading) {
|
2023-01-13 00:33:39 +01:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Loading />
|
|
|
|
</div>
|
|
|
|
);
|
2023-01-08 17:14:46 +01:00
|
|
|
} else {
|
2023-01-13 00:33:39 +01:00
|
|
|
return <DataForm data={data} />;
|
2023-01-08 17:14:46 +01:00
|
|
|
}
|
|
|
|
};
|