blob: 6e34f11e665c373511f11a806e3b5567698e1906 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
import type { District, Site } from "./types";
import { districts } from "./districts";
import { arcadia } from "./arcadia";
import { arles } from "./arles";
import { hollywood } from "./hollywood";
import { oxford } from "./oxford";
import { petsburg } from "./petsburg";
import { purgatory } from "./purgatory";
import { siliconValley } from "./siliconValley";
import { silverLake } from "./silverLake";
import { stratfordUponAvon } from "./stratfordUponAvon";
import { tokyo } from "./tokyo";
export const getDistrictById = (id: string): District | undefined => {
return districts.find((district) => district.id === id);
};
export const getSitesByDistrictId = (id: string): Site[] => {
switch (id) {
case "arcadia":
return arcadia;
case "arles":
return arles;
case "hollywood":
return hollywood;
case "oxford":
return oxford;
case "petsburg":
return petsburg;
case "purgatory":
return purgatory;
case "silicon-valley":
return siliconValley;
case "silver-lake":
return silverLake;
case "stratford-upon-avon":
return stratfordUponAvon;
case "tokyo":
return tokyo;
default:
return [];
}
};
export const getPaginatedSitesByDistrictId = (
id: string,
page: number,
limit: number
): { sites: Site[]; totalPages: number; currentPage: number } => {
const sites = getSitesByDistrictId(id);
const startIndex = (page - 1) * limit;
const endIndex = startIndex + limit;
return {
sites: sites.slice(startIndex, endIndex),
totalPages: Math.ceil(sites.length / limit),
currentPage: page,
};
};
|