Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

217 create operations table #1719

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

BallardRobinett
Copy link
Contributor

Card: bcgov/cas-reporting#217

Creating a page showing operators a list of their operations, similar to OperationsDataGrid in registration. Both are relying on the Registration component DataGrid, which has been moved to a shared component library along with other shared components.

The page has replaced the placeholder page showing the operators API call in the reporting app.

@BallardRobinett BallardRobinett self-assigned this May 29, 2024
@BallardRobinett BallardRobinett requested review from joshgamache, pbastia and dleard and removed request for joshgamache, pbastia and dleard May 29, 2024 01:05
Copy link
Contributor

@pbastia pbastia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First batch of comments! I'll spend more time on it today. Nice work!

OperationRow,
OperationsSearchParams,
} from "@/app/components/operations/types";
import { OperationRow } from "@shared/components/src/operations/type";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with the previous naming

Suggested change
import { OperationRow } from "@shared/components/src/operations/type";
import { OperationRow } from "@shared/components/src/operations/types";

export default async function Page({
searchParams,
}: {
searchParams: OperationsSearchParams;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These search params are not the ones matching the table. We should probably not use them here, and implement search on that table at a later point

// Set flex to 1 to make the column take up all the remaining width if user zooms out
flex: 0,
},
] as GridColDef[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should type the const variable instead of casting the value, otherwise we don't get a proper type check

const columns: GridColDef[] = [{...}]

Comment on lines 27 to 32
if (isOperatorColumn) {
columns.splice(OPERATOR_COLUMN_INDEX, 0, {
field: "operator",
headerName: "Operator",
width: 320,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third column should be "Operation" as per the AC, and we shouldn't make that conditional to whether the user is an operator or not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just deleting this, Operation column is defined above. This is just something copied over from registration that we don't need

@@ -20,7 +20,9 @@
"@bciers/components": ["libs/shared/components/src/index.ts"],
"@bciers/img/*": ["libs/shared/img/*"],
"@bciers/styles": ["libs/shared/styles/src/index.ts"],
"@/*": ["apps/registration/*"]
"@/*": ["apps/registration/*"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to reconsider this alias now that the 2 apps live side by side. For tech debt :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I think it would make a lot of sense to rename the @/* alias to @registration/*, but I thought maybe it needs to be run by the team first.

Comment on lines 96 to 99
// Show the operator column if the user is CAS internal
const isOperatorColumn =
session?.user.app_role?.includes("cas") &&
!session?.user.app_role?.includes("pending");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can leave this out, it's not needed in the reporting app

// Render the DataGrid component
return (
<div className="mt-5">
<OperationDataGrid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping the name will create confusion with the reg app

Suggested change
<OperationDataGrid
<ReportingOperationDataGrid

}: {
searchParams: OperationsSearchParams;
}) {
const session = await getServerSession(authOptions);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the session at this point


const ReportingOperationDataGrid = ({
initialData,
isOperatorColumn = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isOperatorColumn is not needed in the reporting context

Comment on lines 11 to 27
const formatTimestamp = (timestamp: string) => {
if (!timestamp) return undefined;

const date = new Date(timestamp).toLocaleString("en-CA", {
month: "short",
day: "numeric",
year: "numeric",
timeZone: "America/Vancouver",
});

const timeWithTimeZone = new Date(timestamp).toLocaleString("en-CA", {
hour: "numeric",
minute: "numeric",
second: "numeric",
timeZoneName: "short",
timeZone: "America/Vancouver",
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have a timestamp in the table

Copy link
Contributor

@pbastia pbastia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work! Just a few more things:

  • we will need tests for the components
  • this will need a rebase.

Comment on lines 11 to 16
return {
id,
name,
bcghg_id,
operator: operator,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for consistency in the coding style

Suggested change
return {
id,
name,
bcghg_id,
operator: operator,
};
return {
id,
name,
bcghg_id,
operator,
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Sorry just poked my head in here after the demo, hope this was relatively easy to implement from our examples :)

formatOperationRows can be removed altogether, if you notice it's not doing anything (map returning the same values). It's some registration 1 tech debt that we removed in the recent Registration part 2 Operations table.

Comment on lines 29 to 31
} catch (error) {
throw error;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the try block is not useful here if we spit the error right back out. Or is this some javascript weirdness that we try to avoid?

@BallardRobinett BallardRobinett force-pushed the 217-create-operations-table branch 2 times, most recently from a618ae9 to d07137d Compare June 14, 2024 16:06
Copy link
Contributor

@pbastia pbastia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants