Skip to content

Commit

Permalink
Add string-ts and use it in useRoutes()
Browse files Browse the repository at this point in the history
  • Loading branch information
anagperal committed Aug 2, 2024
1 parent 10399a6 commit 82357d1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"react-dom": "^18.2.0",
"react-router-dom": "5.2.0",
"real-cancellable-promise": "^1.1.2",
"string-ts": "2.2.0",
"styled-components": "5.3.5",
"styled-jsx": "3.4.5",
"typed-immutable-map": "^0.1.1",
Expand Down
4 changes: 3 additions & 1 deletion src/webapp/hooks/useRoutes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";
import { join } from "string-ts";
import { generatePath, useHistory } from "react-router-dom";

import { FormType } from "../pages/form-page/FormPage";

export enum RouteName {
Expand All @@ -14,7 +16,7 @@ export enum RouteName {

const formTypes = ["disease-outbreak-event"] as const satisfies FormType[];

Check failure on line 17 in src/webapp/hooks/useRoutes.ts

View workflow job for this annotation

GitHub Actions / Unit tests

Type 'readonly ["disease-outbreak-event"]' does not satisfy the expected type '"disease-outbreak-event"[]'.

const formType = `:formType(${formTypes.join("|")})` as const;
const formType = `:formType(${join(formTypes, "|")})` as const;

export const routes: Record<RouteName, string> = {
[RouteName.CREATE_FORM]: `/create/${formType}`,
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10553,6 +10553,11 @@ string-natural-compare@^3.0.1:
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4"
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==

[email protected]:
version "2.2.0"
resolved "https://registry.yarnpkg.com/string-ts/-/string-ts-2.2.0.tgz#46573f475f90f9b43c50cd01c9a603c83426bd25"
integrity sha512-VTP0LLZo4Jp9Gz5IiDVMS9WyLx/3IeYh0PXUn0NdPqusUFNgkHPWiEdbB9TU2Iv3myUskraD5WtYEdHUrQEIlQ==

string-width@^3.0.0, string-width@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961"
Expand Down

0 comments on commit 82357d1

Please sign in to comment.