Skip to content

Commit c573bb5

Browse files
committed
feat: Implement Arizona verification logic and integrate BlobSync for result handling
1 parent 8f724b1 commit c573bb5

3 files changed

Lines changed: 125 additions & 45 deletions

File tree

app/api/verify/arizona/logic.ts

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,55 @@
11
import { VetResult } from "@/app/types/vet-result";
2+
import BlobSync from "@/data/controls/blobs/blobSync";
23

3-
export async function verify(
4-
// firstName: string,
5-
// lastName: string,
6-
// licenseNumber: string
7-
): Promise<VetResult[]> {
8-
// ...Arizona-specific fetch and parsing logic here...
9-
return [];
4+
export async function verify({
5+
firstName,
6+
lastName,
7+
licenseNumber,
8+
}: {
9+
firstName: string;
10+
lastName: string;
11+
licenseNumber: string;
12+
}): Promise<VetResult[]> {
13+
console.log("Arizona Loaded");
14+
15+
const keyword = [licenseNumber, firstName, lastName].filter(Boolean).join(" ").trim();
16+
17+
const queryParams = new URLSearchParams({
18+
keyword,
19+
skip: "0",
20+
take: "2000",
21+
lang: "en-us",
22+
licenseType: "Veterinarian (Regular)",
23+
licenseStatus: "Active",
24+
disciplined: "false",
25+
});
26+
27+
const res = await fetch(`/api/verify/arizona/?${queryParams.toString()}`);
28+
if (!res.ok) throw new Error("Failed to fetch Arizona data");
29+
30+
const data = await res.json();
31+
const rawResults = data?.result?.dataResults || [];
32+
33+
const results: VetResult[] = rawResults.map((entry: any) => {
34+
const licenseNumber = entry.columnValues?.[0]?.data || "";
35+
const first = entry.columnValues?.[1]?.data || "";
36+
const last = entry.columnValues?.[2]?.data || "";
37+
const name = `${first} ${last}`.trim();
38+
39+
return {
40+
name,
41+
licenseNumber,
42+
issuedDate: "",
43+
expirationDate: "",
44+
detailsUrl: "",
45+
reportUrl: "",
46+
status: "active",
47+
expiration: "",
48+
};
49+
});
50+
51+
await BlobSync("arizona", results);
52+
return results;
1053
}
54+
55+

app/api/verify/arizona/route.ts

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
1-
// import type { NextRequest } from "next/server";
1+
import type { NextRequest } from "next/server";
22

3-
export async function GET(
4-
// request: NextRequest
5-
) {
6-
return new Response(`<h1>${"<STATE>"}</h1>`, { status: 200, headers: { "Content-Type": "text/html" } });
7-
}
3+
export async function GET(request: NextRequest) {
4+
// Forward all query string parameters from the incoming request
5+
const { search } = new URL(request.url);
6+
const url =
7+
"https://azsvmeb.portalus.thentiacloud.net/rest/public/profile/search/?" +
8+
(search || "");
9+
10+
try {
11+
const response = await fetch(url, {
12+
method: "GET",
13+
headers: {
14+
"User-Agent":
15+
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
16+
Referer: "https://azsvmeb.portalus.thentiacloud.net/webs/portal/register/",
17+
Origin: "https://azsvmeb.portalus.thentiacloud.net",
18+
Accept: "*/*",
19+
},
20+
});
21+
const data = await response.text();
22+
return new Response(data, {
23+
headers: { "Content-Type": "application/json; charset=utf-8" },
24+
status: response.status,
25+
});
26+
} catch (error) {
27+
return Response.json(
28+
{
29+
error: error instanceof Error ? error.message : "Failed to fetch data",
30+
},
31+
{ status: 500 }
32+
);
33+
}
34+
}

app/components/Project/Header.tsx

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import {
33
Heading,
44
HStack,
55
Icon,
6+
Show,
67
Status,
78
Tag,
89
Text,
10+
useBreakpointValue,
911
VStack,
1012
} from "@chakra-ui/react";
1113
import { Activity } from "lucide-react";
@@ -24,6 +26,8 @@ const checkingStates = ListedStates.items.filter(
2426
(state) => state.active === null
2527
).length;
2628

29+
30+
2731
export function ProjectHeader({
2832
icon,
2933
title,
@@ -46,7 +50,7 @@ export function ProjectHeader({
4650
gradientTo={"#2179b5"}
4751
>
4852
<Container
49-
maxW={"7xl"}
53+
5054
m={"auto"}
5155
px={{ sm: 6, base: 4, lg: 8 }}
5256
py={6}
@@ -76,40 +80,44 @@ export function ProjectHeader({
7680
</Text>
7781
</Heading>
7882
</VStack>
79-
</HStack>
80-
<HStack justify={"space-between"}>
81-
<Tag.Root rounded={"full"}>
82-
<Status.Root>
83-
<Status.Indicator colorPalette={"red"} />
84-
<Icon as={Activity} color={"red"} />
85-
{offlineStates} Offline
86-
</Status.Root>
87-
</Tag.Root>
88-
<Tag.Root rounded={"full"}>
89-
<Status.Root>
90-
<Status.Indicator colorPalette={"yellow"} />
9183

92-
<Icon as={Activity} color={"yellow"} />
93-
{checkingStates} Checking
94-
</Status.Root>
95-
</Tag.Root>
96-
<Tag.Root rounded={"full"}>
97-
<Status.Root>
98-
<Status.Indicator colorPalette={"green"} />
99-
<Icon as={Activity} color={"green"} />
100-
{onlineStates} Online
101-
</Status.Root>
102-
</Tag.Root>
103-
<Tag.Root rounded={"full"}>
104-
<Status.Root size="lg">
105-
<Status.Indicator />
106-
{totalStates} Total Lookups
107-
</Status.Root>
108-
</Tag.Root>
10984
</HStack>
85+
86+
<Show when={""} >
87+
<HStack justify={"space-between"}>
88+
<Tag.Root rounded={"full"}>
89+
<Status.Root>
90+
<Status.Indicator colorPalette={"red"} />
91+
<Icon as={Activity} color={"red"} />
92+
{offlineStates} Offline
93+
</Status.Root>
94+
</Tag.Root>
95+
<Tag.Root rounded={"full"}>
96+
<Status.Root>
97+
<Status.Indicator colorPalette={"yellow"} />
98+
99+
<Icon as={Activity} color={"yellow"} />
100+
{checkingStates} Checking
101+
</Status.Root>
102+
</Tag.Root>
103+
<Tag.Root rounded={"full"}>
104+
<Status.Root>
105+
<Status.Indicator colorPalette={"green"} />
106+
<Icon as={Activity} color={"green"} />
107+
{onlineStates} Online
108+
</Status.Root>
109+
</Tag.Root>
110+
<Tag.Root rounded={"full"}>
111+
<Status.Root size="lg">
112+
<Status.Indicator />
113+
{totalStates} Total Lookups
114+
</Status.Root>
115+
</Tag.Root>
116+
</HStack>
117+
</Show>
110118
</HStack>
111-
</Container>
112-
</HStack>
119+
</Container >
120+
</HStack >
113121
</>
114122
);
115123
}

0 commit comments

Comments
 (0)