-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: ProductionData using page factory pattern
chore: cleanup
- Loading branch information
1 parent
fee479b
commit ea696f2
Showing
5 changed files
with
65 additions
and
98 deletions.
There are no files selected for viewing
20 changes: 3 additions & 17 deletions
20
...ness/industry_user/reports/[version_id]/facilities/[facility_id]/production-data/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,4 @@ | ||
import { Suspense } from "react"; | ||
import Loading from "@bciers/components/loading/SkeletonForm"; | ||
import ProductionData from "@reporting/src/app/components/products/ProductionData"; | ||
import Page from "@reporting/src/app/components/products/ProductionDataPage"; | ||
import defaultPageFactory from "@bciers/components/nextPageFactory/defaultPageFactory"; | ||
|
||
export default async function Page({ | ||
params, | ||
}: { | ||
params: { version_id: number; facility_id: string }; | ||
}) { | ||
return ( | ||
<Suspense fallback={<Loading />}> | ||
<ProductionData | ||
report_version_id={params.version_id} | ||
facility_id={params.facility_id} | ||
/> | ||
</Suspense> | ||
); | ||
} | ||
export default defaultPageFactory(Page); |
20 changes: 3 additions & 17 deletions
20
...ndustry_user_admin/reports/[version_id]/facilities/[facility_id]/production-data/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,4 @@ | ||
import { Suspense } from "react"; | ||
import Loading from "@bciers/components/loading/SkeletonForm"; | ||
import ProductionData from "@reporting/src/app/components/products/ProductionData"; | ||
import Page from "@reporting/src/app/components/products/ProductionDataPage"; | ||
import defaultPageFactory from "@bciers/components/nextPageFactory/defaultPageFactory"; | ||
|
||
export default async function Page({ | ||
params, | ||
}: { | ||
params: { version_id: number; facility_id: string }; | ||
}) { | ||
return ( | ||
<Suspense fallback={<Loading />}> | ||
<ProductionData | ||
report_version_id={params.version_id} | ||
facility_id={params.facility_id} | ||
/> | ||
</Suspense> | ||
); | ||
} | ||
export default defaultPageFactory(Page); |
60 changes: 0 additions & 60 deletions
60
bciers/apps/reporting/src/app/components/products/ProductionData.tsx
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
bciers/apps/reporting/src/app/components/products/ProductionDataPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import ProductionDataForm from "@reporting/src/app/components/products/ProductionDataForm"; | ||
import { buildProductionDataSchema } from "@reporting/src/data/jsonSchema/productionData"; | ||
import { getProductionData } from "@bciers/actions/api"; | ||
import { getOrderedActivities } from "@reporting/src/app/utils/getOrderedActivities"; | ||
import { | ||
ActivePage, | ||
getFacilitiesInformationTaskList, | ||
} from "@reporting/src/app/components/taskList/2_facilitiesInformation"; | ||
import { HasFacilityId } from "@reporting/src/app/utils/defaultPageFactoryTypes"; | ||
|
||
export default async function ProductionDataPage({ | ||
version_id, | ||
facility_id, | ||
}: HasFacilityId) { | ||
const response = await getProductionData(version_id, facility_id); | ||
|
||
const allowedProductNames = response.allowed_products.map((p) => p.name); | ||
const allowedProducts = response.allowed_products.map((p) => ({ | ||
product_id: p.id, | ||
product_name: p.name, | ||
unit: p.unit, | ||
})); | ||
|
||
const schema: any = buildProductionDataSchema( | ||
"Jan 1", | ||
"Dec 31", | ||
allowedProductNames, | ||
); | ||
|
||
const orderedActivities = await getOrderedActivities(version_id, facility_id); | ||
const taskListElements = await getFacilitiesInformationTaskList( | ||
version_id, | ||
facility_id, | ||
orderedActivities, | ||
ActivePage.ProductionData, | ||
); | ||
|
||
return ( | ||
<ProductionDataForm | ||
report_version_id={version_id} | ||
facility_id={facility_id} | ||
allowedProducts={allowedProducts} | ||
initialData={response.report_products} | ||
schema={schema} | ||
taskListElements={taskListElements} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters