Skip to content

Commit 57a7f1a

Browse files
authored
Merge pull request #103 from bcgov/test
Promote test to main
2 parents bb8c4fd + f90d8b6 commit 57a7f1a

File tree

18 files changed

+224
-86
lines changed

18 files changed

+224
-86
lines changed

graphemes-api/src/routes/api/v1/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { Router } from "express";
33
import graphemesRouter from "./graphemes/index.js";
44
import languagesRouter from "./languages/index.js";
55
import matchRouter from "./match/index.js";
6+
import nameRouter from "./name/index.js";
67
import sitesRouter from "./sites/index.js";
78

89
const v1Router = Router();
910
v1Router.use("/graphemes", graphemesRouter);
1011
v1Router.use("/languages", languagesRouter);
1112
v1Router.use("/match", matchRouter);
13+
v1Router.use("/name", nameRouter);
1214
v1Router.use("/sites", sitesRouter);
1315

1416
export default v1Router;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import anyAscii from "any-ascii";
2+
import { Router } from "express";
3+
4+
const nameRouter = Router();
5+
6+
// GET /api/v1/name/:search
7+
nameRouter.get("/:search", async (req, res) => {
8+
try {
9+
const { search } = req.params;
10+
const trimmed = search.trim();
11+
const segmenter = new Intl.Segmenter("en-CA", { granularity: "grapheme" });
12+
13+
res.json({
14+
input: trimmed,
15+
output: {
16+
charactersSplit: trimmed.split(""),
17+
charactersSegmented: Array.from(segmenter.segment(trimmed)),
18+
anyAscii: anyAscii(trimmed),
19+
},
20+
});
21+
} catch (error) {
22+
console.error("Error searching names: ", error);
23+
res.status(500).json({ error: "Internal Server Error" });
24+
}
25+
});
26+
27+
export default nameRouter;

validator/frontend/package-lock.json

Lines changed: 16 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

validator/frontend/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
"@bcgov/bc-sans": "2.1.0",
1717
"@bcgov/design-system-react-components": "0.5.1",
1818
"@bcgov/design-tokens": "3.2.0",
19-
"@tanstack/react-query": "5.85.0",
20-
"@tanstack/react-router": "^1.131.8",
19+
"@tanstack/react-query": "5.85.3",
20+
"@tanstack/react-router": "^1.131.10",
2121
"react": "19.1.1",
2222
"react-aria-components": "1.11.0",
2323
"react-dom": "19.1.1"
2424
},
2525
"devDependencies": {
2626
"@eslint/js": "9.33.0",
27-
"@testing-library/jest-dom": "6.6.4",
27+
"@testing-library/jest-dom": "6.7.0",
2828
"@testing-library/react": "16.3.0",
2929
"@testing-library/user-event": "14.6.1",
3030
"@types/node": "24.2.1",

validator/frontend/src/App.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,31 @@ function App() {
5252
},
5353
{
5454
id: "all-confusables",
55-
label: "All confusables ",
55+
label: "All confusables",
5656
},
5757
{ id: "ocr", label: "Optical Character Recognition (OCR)" },
5858
{
5959
id: "text-comparison",
6060
label: "Text comparison",
6161
},
62+
{
63+
id: "name-search",
64+
label: "Name search",
65+
},
6266
]}
6367
onSelectionChange={(key) => {
6468
switch (key) {
69+
case "all-confusables":
70+
navigate({ to: routePaths.allConfusables });
71+
break;
6572
case "by-label":
6673
navigate({ to: routePaths.byLabel });
6774
break;
6875
case "by-character":
6976
navigate({ to: routePaths.byCharacter });
7077
break;
71-
case "all-confusables":
72-
navigate({ to: routePaths.allConfusables });
78+
case "name-search":
79+
navigate({ to: routePaths.nameSearch });
7380
break;
7481
case "ocr":
7582
navigate({ to: routePaths.opticalCharacterRecognition });

validator/frontend/src/layout/Confusables/AllConfusables/AllConfusables.tsx renamed to validator/frontend/src/layout/AllConfusables/AllConfusables.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { InlineAlert } from "@bcgov/design-system-react-components";
22
import { useQuery } from "@tanstack/react-query";
33

4-
import ConfusableDisplay from "../../../components/ConfusableDisplay/ConfusableDisplay";
5-
import ProgressBar from "../../../components/ProgressBar/ProgressBar";
6-
import { getAllConfusables } from "../../../services/api";
4+
import ConfusableDisplay from "../../components/ConfusableDisplay/ConfusableDisplay";
5+
import ProgressBar from "../../components/ProgressBar/ProgressBar";
6+
import { getAllConfusables } from "../../services/api";
77

88
export default function AllConfusables() {
99
const query = useQuery({

validator/frontend/src/layout/Confusables/ByCharacter/ByCharacter.tsx renamed to validator/frontend/src/layout/ByCharacter/ByCharacter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState } from "react";
22
import * as tokens from "@bcgov/design-tokens/js";
33

4-
import SearchBar from "../../../components/SearchBar/SearchBar";
4+
import SearchBar from "../../components/SearchBar/SearchBar";
55
import SearchResults from "./SearchResults";
66

77
export default function ByCharacter() {

validator/frontend/src/layout/Confusables/ByCharacter/SearchResults.tsx renamed to validator/frontend/src/layout/ByCharacter/SearchResults.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { InlineAlert } from "@bcgov/design-system-react-components";
22
import { useQuery } from "@tanstack/react-query";
33

4-
import { getConfusablesByCharacter } from "../../../services/api";
5-
import ConfusableDisplay from "../../../components/ConfusableDisplay/ConfusableDisplay";
6-
import ProgressBar from "../../../components/ProgressBar/ProgressBar";
4+
import { getConfusablesByCharacter } from "../../services/api";
5+
import ConfusableDisplay from "../../components/ConfusableDisplay/ConfusableDisplay";
6+
import ProgressBar from "../../components/ProgressBar/ProgressBar";
77

88
interface SearchResultsProps {
99
search: string;

validator/frontend/src/layout/Confusables/ByLabel/ByLabel.tsx renamed to validator/frontend/src/layout/ByLabel/ByLabel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState } from "react";
22
import * as tokens from "@bcgov/design-tokens/js";
33

4-
import SearchBar from "../../../components/SearchBar/SearchBar";
4+
import SearchBar from "../../components/SearchBar/SearchBar";
55
import SearchResults from "./SearchResults";
66

77
export default function ByLabel() {

validator/frontend/src/layout/Confusables/ByLabel/SearchResults.tsx renamed to validator/frontend/src/layout/ByLabel/SearchResults.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { InlineAlert } from "@bcgov/design-system-react-components";
22
import { useQuery } from "@tanstack/react-query";
33

4-
import { getOneConfusableByLabel } from "../../../services/api";
5-
import ConfusableDisplay from "../../../components/ConfusableDisplay/ConfusableDisplay";
6-
import ProgressBar from "../../../components/ProgressBar/ProgressBar";
4+
import { getOneConfusableByLabel } from "../../services/api";
5+
import ConfusableDisplay from "../../components/ConfusableDisplay/ConfusableDisplay";
6+
import ProgressBar from "../../components/ProgressBar/ProgressBar";
77

88
interface SearchResultsProps {
99
search: string;

0 commit comments

Comments
 (0)