Routing - Garasje-folka/bartstua GitHub Wiki
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.
All routings are defined in /src/router/routings.ts
. To add a new route, add a Routing-object with the corresponding values.
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 {
VERIFICATION_CHECK, // Returns if user is verfied or not
SIGN_IN_CHECK, // Returns if user is signed in
NONE, // No checks
}
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
)