web/src/utils/fetch-privacy-policy.ts

61 lines · 1200 bytes

 1
 2export const fetchTosdrPrivacy = async (serviceId: string): Promise<PrivacyPolicyResponse | null> => {
 3  const endpoint = `https://privacy-policies.as93.workers.dev/${serviceId}`;
 4  try {
 5    return await fetch(endpoint).then((res) => res.json());
 6  } catch (error) {
 7    console.error('Error fetching privacy policy data:', error);
 8    return null;
 9  }
10};
11
12interface Document {
13  id: number;
14  name: string;
15  url: string;
16  updated_at: string;
17  created_at: string;
18}
19
20interface Case {
21  id: number;
22  weight: number;
23  title: string;
24  description: string;
25  updated_at: string;
26  created_at: string;
27  topic_id: number;
28  classification: string;
29}
30
31interface Point {
32  id: number;
33  title: string;
34  source: string;
35  status: string;
36  analysis: string;
37  case: Case;
38  document_id: number | null;
39  updated_at: string;
40  created_at: string;
41}
42
43interface Params {
44  id: number;
45  is_comprehensively_reviewed: boolean;
46  name: string;
47  updated_at: string;
48  created_at: string;
49  slug: string;
50  rating: string;
51  urls: string[];
52  image: string;
53  documents: Document[];
54  points: Point[];
55}
56
57export interface PrivacyPolicyResponse {
58  error: number;
59  message: string;
60  parameters: Params;
61}