Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ref/phase 3 endpoints #258

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/api/collections/[uuid]/route.tsx
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions app/api/collections/[uuid]/structure/route.tsx
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions app/api/search/facets/route.tsx
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions app/api/search/route.tsx
Original file line number Diff line number Diff line change
@@ -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 });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand how status is working in this setup. Does this mean it would live on the response (like we've been talking about) instead of within the headers field

};

// http://localhost:3000/api/search
37 changes: 37 additions & 0 deletions app/src/data/schemas/collectionsLandingPageSchema.ts
Original file line number Diff line number Diff line change
@@ -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;
14 changes: 14 additions & 0 deletions app/src/data/schemas/collectionsStructureSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const collectionsStructureSchema = {
response: {
headers: {
status: "200",
code: "200",
message: "some copy",
},
numResults: "6",
page: "1",
perPage: "40",
},
};

export default collectionsStructureSchema;
14 changes: 14 additions & 0 deletions app/src/data/schemas/searchFacetsSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const searchFacetsSchema = {
response: {
headers: {
status: "200",
code: "200",
message: "some copy",
},
numResults: "6",
page: "1",
perPage: "40",
},
};

export default searchFacetsSchema;
77 changes: 77 additions & 0 deletions app/src/data/schemas/searchSchema.ts
Original file line number Diff line number Diff line change
@@ -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;
23 changes: 23 additions & 0 deletions app/src/utils/apiHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Loading