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

fix(404): add button for searches #869

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

fix(404): add button for searches #869

wants to merge 6 commits into from

Conversation

seaerchin
Copy link
Contributor

Problem

on the 404 page, users are not able to take action to self-resolve the issue

Solution

  1. add a button (for now) that redirects to the searchsg page so that users can self-resolve the issue

1. duplicate infobar to not found layout
2. export styles from infobar so it's kept in sync
3. add client component for search button
@seaerchin seaerchin requested a review from a team as a code owner November 11, 2024 10:23
Copy link

vercel bot commented Nov 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
isomer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 12, 2024 10:51am

@datadog-opengovsg
Copy link

datadog-opengovsg bot commented Nov 11, 2024

Datadog Report

Branch report: fix/404
Commit report: 1790a36
Test service: isomer-studio

✅ 0 Failed, 185 Passed, 34 Skipped, 37.62s Total Time
⬆️ Test Sessions change in coverage: 1 increased (+1.71%)

Comment on lines +30 to +40
it("should preserve `=` in the original permalink", () => {
// Arrange
const singleLevelPermalink = "/this-._single=level|"
const expected = "this+single+level"

// Act
const actual = getWordsFromPermalink(singleLevelPermalink)

// Assert
expect(actual).toBe(expected)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

unsure if i understand the test description correctly but = isn't preserve but converted?

Copy link
Contributor Author

@seaerchin seaerchin Nov 13, 2024

Choose a reason for hiding this comment

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

this is my bad, i was flipflopping on whether we should keep this due to query params but i decided teh = wasn't going to impact the search results much - i'll just remove this test and add a = character ot the other permalinks

}: NotFoundSearchButtonProps) => {
const [permalink, setPermalink] = useState("")

useLayoutEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need useLayoutEffect here? iirc, the use of this hook is discouraged in favour of useEffect

const [permalink, setPermalink] = useState("")

useLayoutEffect(() => {
// The check for typeof window and navigator ensures this only runs in browser environments, not during server-side rendering
Copy link
Contributor

Choose a reason for hiding this comment

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

this will never be server-side rendered due to "use client" declarative at top

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not server-side rendered but nextjs will transpile then serve the js at runtime. this led to compile errors as window is undefined when transpiling

@@ -0,0 +1,15 @@
export const getWordsFromPermalink = (permalink: string): string => {
Copy link
Contributor

Choose a reason for hiding this comment

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

checking understanding:

so https://example.com/some-page_name+ will yield some+page+name right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeap excatly

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.

3 participants