-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
237,756 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
SERVER_URL=http://localhost:8000 | ||
SERVER_URL=http://localhost:8000 | ||
NEXT_PUBLIC_API_MOCKING=enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { setupWorker } from "msw/browser"; | ||
import { handlers } from "./handlers"; | ||
|
||
export const worker = setupWorker(...handlers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { SHEETY_BASE_URL, Sheets } from "api/sheety/constants"; | ||
import { http, HttpResponse } from "msw"; | ||
import { methodsSuccessResponse } from "./responses/methods"; | ||
import { categoriesSuccessResponse } from "./responses/categories"; | ||
import { instructionsSuccessResponse } from "./responses/instructions"; | ||
import { facilitiesSuccessResponse } from "./responses/facilities"; | ||
import { pickupSuccessResponse } from "./responses/pickup"; | ||
import { itemsSuccessResponse } from "./responses/items"; | ||
import { unrecyclabilitySuccessResponse } from "./responses/unrecyclability"; | ||
import { onemapSuccessResponse } from "./responses/onemap"; | ||
|
||
export const handlers = [ | ||
http.get(getUrlFromSheetName(Sheets.ITEMS_SHEET_NAME), () => { | ||
return HttpResponse.json(itemsSuccessResponse); | ||
}), | ||
http.get(getUrlFromSheetName(Sheets.METHODS_SHEET_NAME), () => { | ||
return HttpResponse.json(methodsSuccessResponse); | ||
}), | ||
http.get(getUrlFromSheetName(Sheets.CATEGORIES_SHEET_NAME), () => { | ||
return HttpResponse.json(categoriesSuccessResponse); | ||
}), | ||
http.get(getUrlFromSheetName(Sheets.INSTRUCTIONS_SHEET_NAME), () => { | ||
return HttpResponse.json(instructionsSuccessResponse); | ||
}), | ||
http.get(getUrlFromSheetName(Sheets.FACILITIES_SHEET_NAME), () => { | ||
return HttpResponse.json(facilitiesSuccessResponse); | ||
}), | ||
http.get(getUrlFromSheetName(Sheets.PICKUP_SHEET_NAME), () => { | ||
return HttpResponse.json(pickupSuccessResponse); | ||
}), | ||
http.get(getUrlFromSheetName(Sheets.UNRECYCLABILITY_SHEET_NAME), () => { | ||
return HttpResponse.json(unrecyclabilitySuccessResponse); | ||
}), | ||
http.get("https://developers.onemap.sg/commonapi/search*", () => { | ||
return HttpResponse.json(onemapSuccessResponse); | ||
}), | ||
]; | ||
|
||
function getUrlFromSheetName(sheetName: string) { | ||
return SHEETY_BASE_URL + sheetName.split(" ")[0] + "*"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
async function initMocks() { | ||
const { worker } = await import("./browser"); | ||
return await worker.start(); | ||
} | ||
|
||
window.__mswStart = initMocks(); | ||
|
||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
export const categoriesSuccessResponse = { | ||
"categoriesList (final)": [ | ||
{ | ||
itemCategories: "CONTENT_CONTAINER", | ||
method1: "RECYCLE", | ||
id: 2, | ||
}, | ||
{ | ||
itemCategories: "FOOD_DRINK_CONTAINER", | ||
method1: "RECYCLE", | ||
id: 3, | ||
}, | ||
{ | ||
itemCategories: "RECYCLABLE", | ||
method1: "RECYCLE", | ||
id: 4, | ||
}, | ||
{ | ||
itemCategories: "PAPER_AND_CARDBOARD", | ||
method1: "RECYCLE", | ||
id: 5, | ||
}, | ||
{ | ||
itemCategories: "BAGS_AND_ACCESSORIES", | ||
method1: "RECYCLE", | ||
method2: "RESELL", | ||
method3: "DONATE", | ||
method4: "REPAIR", | ||
id: 6, | ||
}, | ||
{ | ||
itemCategories: "HOUSEHOLD_GOODS", | ||
method1: "RECYCLE", | ||
method2: "RESELL", | ||
id: 7, | ||
}, | ||
{ | ||
itemCategories: "ICT_EQUIPMENT", | ||
method1: "RECYCLE", | ||
method2: "REPAIR", | ||
method3: "DONATE", | ||
method4: "REPAIR", | ||
id: 8, | ||
}, | ||
{ | ||
itemCategories: "INKS_AND_TONER_CARTRIDGES", | ||
method1: "RECYCLE", | ||
id: 9, | ||
}, | ||
{ | ||
itemCategories: "LAMPS", | ||
method1: "RECYCLE", | ||
id: 10, | ||
}, | ||
{ | ||
itemCategories: "OTHER_ELECTRICAL_APPLIANCES", | ||
method1: "DONATE", | ||
method2: "REPAIR", | ||
method3: "RESELL", | ||
id: 11, | ||
}, | ||
{ | ||
itemCategories: "SHOES", | ||
method1: "DONATE", | ||
method2: "REPAIR", | ||
id: 12, | ||
}, | ||
{ | ||
itemCategories: "STATIONERY", | ||
method1: "DONATE", | ||
method2: "RESELL", | ||
id: 13, | ||
}, | ||
{ | ||
itemCategories: "TOYS", | ||
method1: "DONATE", | ||
method2: "RESELL", | ||
id: 14, | ||
}, | ||
{ | ||
itemCategories: "BABY_CHILDREN_ITEMS", | ||
method1: "DONATE", | ||
method2: "RESELL", | ||
id: 15, | ||
}, | ||
{ | ||
itemCategories: "CLOTHING", | ||
method1: "DONATE", | ||
method2: "REPAIR", | ||
method3: "RESELL", | ||
id: 16, | ||
}, | ||
{ | ||
itemCategories: "FURNITURE", | ||
method1: "DONATE", | ||
method2: "RESELL", | ||
id: 17, | ||
}, | ||
{ | ||
itemCategories: "LARGE_HOUSEHOLD_APPLIANCES", | ||
method1: "DONATE", | ||
id: 18, | ||
}, | ||
{ | ||
itemCategories: "FOOD", | ||
method1: "DONATE", | ||
id: 19, | ||
}, | ||
{ | ||
itemCategories: "BOOKS", | ||
method1: "DONATE", | ||
method2: "RESELL", | ||
id: 20, | ||
}, | ||
{ | ||
itemCategories: "PORTABLE_BATTERIES", | ||
method1: "RECYCLE", | ||
id: 21, | ||
}, | ||
{ | ||
itemCategories: "LAMPS", | ||
method1: "RECYCLE", | ||
id: 22, | ||
}, | ||
{ | ||
itemCategories: "GENERAL_WASTE", | ||
method1: "RECYCLE", | ||
id: 23, | ||
}, | ||
], | ||
}; |
Oops, something went wrong.