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

Admin Banner #58

Merged
merged 21 commits into from
Nov 19, 2024
Merged

Admin Banner #58

merged 21 commits into from
Nov 19, 2024

Conversation

ailZhou
Copy link
Collaborator

@ailZhou ailZhou commented Nov 13, 2024

Description

Behold, we have admin banner page & form!

Screenshot 2024-11-18 at 3 39 53 PM

Related ticket(s)

CMDCT-4089
CMDCT-4090


How to test

  1. Sign into HCBS, adminuser@test.com
  2. In the top right corner, click [My Account] -> [Manage Account]
    Screenshot 2024-11-18 at 3 33 32 PM
  3. On the My Account page click [Banner Editor]
    Screenshot 2024-11-18 at 3 34 27 PM
  4. This will take you to the Banner Admin page. Fill out the form completely and click [Replace Current Banner]
    • Note: We do not have validation yet so there will still be some bugginess until that is added
      Screenshot 2024-11-18 at 3 36 49 PM
  5. You should see the Banner filled in Current Banner section
    Screenshot 2024-11-18 at 3 38 54 PM
  6. Click [Delete Current Banner] and that should remove the banner. That should complete all the test for the banner.

Important updates


Author checklist

  • I have performed a self-review of my code
  • I have added thorough tests, if necessary
  • I have updated relevant documentation, if necessary

convert to a different template: test → val | val → prod

Copy link

codeclimate bot commented Nov 13, 2024

Code Climate has analyzed commit 1877c17 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 28.7% (90% is the threshold).

This pull request will bring the total coverage in the repository to 89.7% (-3.5% change).

View more on Code Climate.

@ailZhou ailZhou changed the title Admin Preview Active Banner + Delete Admin Banner Nov 18, 2024
Copy link
Contributor

@benmartin-coforma benmartin-coforma left a comment

Choose a reason for hiding this comment

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

I've got lots of comments below, but overall I think this is really good work! Thanks so much for taking on this story.

services/app-api/handlers/banners/create.ts Outdated Show resolved Hide resolved
services/app-api/handlers/banners/create.ts Outdated Show resolved Hide resolved
services/app-api/handlers/banners/delete.ts Outdated Show resolved Hide resolved
services/app-api/handlers/banners/delete.ts Outdated Show resolved Hide resolved
services/app-api/handlers/banners/delete.ts Outdated Show resolved Hide resolved
services/ui-src/src/components/pages/Admin/AdminPage.tsx Outdated Show resolved Hide resolved
services/ui-src/src/components/pages/Admin/AdminPage.tsx Outdated Show resolved Hide resolved
services/ui-src/src/types/banners.ts Outdated Show resolved Hide resolved
services/ui-src/src/types/states.ts Outdated Show resolved Hide resolved
@ailZhou ailZhou marked this pull request as ready for review November 18, 2024 20:40
Copy link
Contributor

@benmartin-coforma benmartin-coforma left a comment

Choose a reason for hiding this comment

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

This is looking really good! My remaining comments are quibbles about types.

services/app-api/types/banner.ts Show resolved Hide resolved
@@ -63,11 +59,11 @@ export const AdminPage = () => {
</Text>
<Text sx={sx.currentBannerDate}>
Start Date:{" "}
<span>{convertDateUtcToEt(bannerData?.startDate)}</span>
<span>{convertDateUtcToEt(bannerData?.startDate!)}</span>
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 this needs a change, but I'm not sure what it should be.

For one, the ? in bannerData?.startDate was never necessary here; we know that bannerData exists from the check on line 51.

More importantly, the ! worries me. We're telling Typescript "trust me, this value will always exist"... but you and I know that it won't always exist, because the field in AdminBannerForm is optional. What will we display for a banner with no defined start date? Today's date? An error? Nothing?

I haven't tested this, but I suspect (based on my reading of convertDateUtcToEt) that it will be today's date, which would be incorrect behavior, right? Do you think the best behavior would be to display nothing instead? Something like: { bannerData.startDate && <span{convertDate... perhaps?

If you've already tested this scenario and are satisfied with the behavior, my apologies - but maybe we should make that behavior explicit? Something like: bannerData.startDate ?? new Date().valueOf() perhaps? Or maybe a change within convertDateUtcToEt, so that it accepts number | undefined?

And whatever change we make here, we should also make 4 lines down for endDate.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm glad you gave feedback on this because I was thinking about this before starting work today and wasn't certain what to do.

The start & end date field isn't suppose to be optional when filling out the admin banner form as there's a set time frame when the banner would run, allowing for scheduling ahead of time. I think this is why it was split as a separate type that inherited from a banner parent type. There's suppose to be a validation check that would make sure the user enter's the date fields in but we currently don't have validation set up yet.

Anyway, I decided to go with your suggestion of the conditional to check if the value exist and to display nothing if somehow the user managed to save without it.

@ailZhou ailZhou added the ready for review Ready for all the reviews! label Nov 19, 2024
Copy link
Contributor

@benmartin-coforma benmartin-coforma left a comment

Choose a reason for hiding this comment

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

Brilliant. Thank you for all of this!

Copy link
Contributor

@angelaco11 angelaco11 left a comment

Choose a reason for hiding this comment

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

Tested on cloudfront and the banner editor looks great!

@BearHanded BearHanded merged commit f0484bd into main Nov 19, 2024
15 of 17 checks passed
@BearHanded BearHanded deleted the cmdct-4090-banner branch November 19, 2024 17:11
@ailZhou ailZhou mentioned this pull request Nov 25, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review Ready for all the reviews!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants