diff --git a/app/api/collections/[uuid]/route.tsx b/app/api/collections/[uuid]/route.tsx new file mode 100644 index 00000000..23dd69a9 --- /dev/null +++ b/app/api/collections/[uuid]/route.tsx @@ -0,0 +1,8 @@ +import { NextResponse } from "next/server"; +import collectionsLandingPageSchema from "../../../src/data/schemas/collectionsLandingPageSchema"; + +export const GET = async () => { + return NextResponse.json(collectionsLandingPageSchema, { status: 200 }); +}; + +// http://localhost:3000/api/collections/:uuid diff --git a/app/api/collections/[uuid]/structure/route.tsx b/app/api/collections/[uuid]/structure/route.tsx new file mode 100644 index 00000000..42b501cd --- /dev/null +++ b/app/api/collections/[uuid]/structure/route.tsx @@ -0,0 +1,8 @@ +import { NextResponse } from "next/server"; +import collectionsStructureSchema from "../../../../src/data/schemas/collectionsStructureSchema"; + +export const GET = async () => { + return NextResponse.json(collectionsStructureSchema, { status: 200 }); +}; + +// http://localhost:3000/api/collections/:uuid/structure diff --git a/app/api/search/facets/route.tsx b/app/api/search/facets/route.tsx new file mode 100644 index 00000000..5a9404dc --- /dev/null +++ b/app/api/search/facets/route.tsx @@ -0,0 +1,8 @@ +import { NextResponse } from "next/server"; +import searchFacetsSchema from "../../../src/data/schemas/searchFacetsSchema"; + +export const GET = async () => { + return NextResponse.json(searchFacetsSchema, { status: 200 }); +}; + +// http://localhost:3000/api/search/facets diff --git a/app/api/search/route.tsx b/app/api/search/route.tsx new file mode 100644 index 00000000..021cc973 --- /dev/null +++ b/app/api/search/route.tsx @@ -0,0 +1,8 @@ +import { NextResponse } from "next/server"; +import searchSchema from "../../src/data/schemas/searchSchema"; + +export const GET = async () => { + return NextResponse.json(searchSchema, { status: 200 }); +}; + +// http://localhost:3000/api/search diff --git a/app/src/data/schemas/collectionsLandingPageSchema.ts b/app/src/data/schemas/collectionsLandingPageSchema.ts new file mode 100644 index 00000000..63dcf001 --- /dev/null +++ b/app/src/data/schemas/collectionsLandingPageSchema.ts @@ -0,0 +1,37 @@ +const collectionsLandingPageSchema = { + response: { + headers: { + status: "200", + code: "200", + message: "some copy", + }, + numResults: "6", + page: "1", + perPage: "40", + items: [ + { + uuid: "string", + title: "string", + url: "string", + imageID: "string | null", + imageURL: "string", + }, + { + uuid: "string", + title: "string", + url: "string", + imageID: "string | null", + imageURL: "string", + }, + { + uuid: "string", + title: "string", + url: "string", + imageID: "string | null", + imageURL: "string", + }, + ], + }, +}; + +export default collectionsLandingPageSchema; diff --git a/app/src/data/schemas/collectionsStructureSchema.ts b/app/src/data/schemas/collectionsStructureSchema.ts new file mode 100644 index 00000000..f7c98ba6 --- /dev/null +++ b/app/src/data/schemas/collectionsStructureSchema.ts @@ -0,0 +1,14 @@ +const collectionsStructureSchema = { + response: { + headers: { + status: "200", + code: "200", + message: "some copy", + }, + numResults: "6", + page: "1", + perPage: "40", + }, +}; + +export default collectionsStructureSchema; diff --git a/app/src/data/schemas/searchFacetsSchema.ts b/app/src/data/schemas/searchFacetsSchema.ts new file mode 100644 index 00000000..b878e0a7 --- /dev/null +++ b/app/src/data/schemas/searchFacetsSchema.ts @@ -0,0 +1,14 @@ +const searchFacetsSchema = { + response: { + headers: { + status: "200", + code: "200", + message: "some copy", + }, + numResults: "6", + page: "1", + perPage: "40", + }, +}; + +export default searchFacetsSchema; diff --git a/app/src/data/schemas/searchSchema.ts b/app/src/data/schemas/searchSchema.ts new file mode 100644 index 00000000..14c2b581 --- /dev/null +++ b/app/src/data/schemas/searchSchema.ts @@ -0,0 +1,77 @@ +const searchSchema = { + // Sort fields + // Filter fields + // Keyword included in search + response: { + headers: { + status: "200", + code: "200", + message: "some copy", + }, + // Pagination fields + numResults: "6", + page: "1", + perPage: "40", + sort: "title DESC", + collections: [ + { + uuid: "string", + title: "string", + url: "string", + imageID: "string | null", + imageURL: "string", + numberOfDigitizedItems: "number", + containsOnSiteMaterials: "boolean", + containsAVMaterial: "boolean", + }, + { + uuid: "string", + title: "string", + url: "string", + imageID: "string | null", + imageURL: "string", + numberOfDigitizedItems: "number", + containsOnSiteMaterials: "boolean", + containsAVMaterial: "boolean", + }, + { + uuid: "string", + title: "string", + url: "string", + imageID: "string | null", + imageURL: "string", + numberOfDigitizedItems: "number", + containsOnSiteMaterials: "boolean", + containsAVMaterial: "boolean", + }, + ], + items: [ + { + uuid: "string", + title: "string", + url: "string", + imageID: "string | null", + imageURL: "string", + containsMultipleImages: "boolean", + }, + { + uuid: "string", + title: "string", + url: "string", + imageID: "string | null", + imageURL: "string", + containsMultipleImages: "boolean", + }, + { + uuid: "string", + title: "string", + url: "string", + imageID: "string | null", + imageURL: "string", + containsMultipleImages: "boolean", + }, + ], + }, +}; + +export default searchSchema; diff --git a/app/src/utils/apiHelpers.ts b/app/src/utils/apiHelpers.ts index d51a3764..0a56c412 100644 --- a/app/src/utils/apiHelpers.ts +++ b/app/src/utils/apiHelpers.ts @@ -174,3 +174,26 @@ export const getLaneData = async ({ const apiUrl = `${process.env.API_URL}/api/v2/collections?genre=${slug}&page=${pageNum}&per_page=${perPage}`; return await fetchApi(apiUrl); }; + +export const getCollectionsData = async ({ + keyword = "", + sortID = "chronological-descending", + pageNum = 1, + perPage = CARDS_PER_PAGE, +}: { + keyword?: string; + sortID?: string; + pageNum?: number; + perPage?: number; +} = {}) => { + let sortOptions = { + date_desc: "date DESC", + date_asc: "date ASC", + "title-desc": "title DESC", + "title-asc": "title ASC", + }; + + let apiUrl = `${process.env.API_URL}/api/v2/collections?page=${pageNum}&per_page=${perPage}&sort=${sortOptions[sortID]}&q=${keyword}`; + const res = await fetchApi(apiUrl); + return res; +};