Routing - Garasje-folka/bartstua GitHub Wiki

Practical info

Creating a page component

Page-components are placed in /src/pages. Create a new page here to implement a new page. If multiple components are needed to be developed, create a folder using the page's name and with a index.ts-file exporting at least the page-component.

Adding new route

All routings are defined in /src/router/routings.ts. To add a new route, add a Routing-object with the corresponding values.

Routing-object

Routing {
  path: string, // Routing path (url)
  component: React.ComponentType<any>, // Page-component
  guardType: GuardType, // The guard function (use GuardType.NONE if not needed)
  expectedGuardValue?: boolean // Should the guardFunction return true or false? This value is not needed
}

GuardType

GuardType {
  VERIFICATION_CHECK, // Returns if user is verfied or not
  SIGN_IN_CHECK, // Returns if user is signed in
  NONE, // No checks
}

If you're curious

The routing on the website is implemented by using a combination of React Router and custom guard.

The guard component is just a conditional redirecting component (code: /src/router/customRouter)

⚠️ **GitHub.com Fallback** ⚠️