Gapura Router — React

Test the Watu Lawang village site on the post’s phone: routes, loaders, errors, lazy and portals. 16 levels, right in the browser.

What the levels ask

  1. Desa Wisata Watu Lawang has a new site built by Ms. Lintang, secretary of the Pokdarwis: the villagers’ homestays, tour packages, the village map, the weather, and booking. The long weekend is two weeks away, and every morning a villager tries it on the post’s phone under the gapura, the way the guests from the city will. This morning it is the neighbourhood head: he taps Inap, then Depan again. Fill <main> in Layout.jsx so the page of that address shows under the site’s header.
  2. Mr. Tono, owner of the rice-field homestay, is welcoming a group. The site’s header has a button for the number of people: he taps it up to 4 org, opens Inap, then presses Back. The group must stay at four, because the site’s header is never reloaded, and Back takes him to Depan. Fill the Inap menu item in Layout.jsx.
  3. Ms. Wulan, a young guide, opens the Omah Kali page (/inap/3). The page has two tabs, Info and Ulasan, child routes of inap/:id. She opens Ulasan, goes back to Info, then presses Back. Exactly one tab must be lit: the one open. Fill the Info tab in Inap, halaman.jsx.
  4. Mr. Bayu looks after the homestay data. From the Inap list he opens Omah Kali, then the Sebelah link to homestay number 4, then presses Back. Every page must show the right homestay with its owner. Complete the lookup in Inap, halaman.jsx: id comes from the route inap/:id.
  5. Mrs. Yanti looks after the tour packages. On the Paket page she picks 2 hari. Then the signal drops and she reloads the page, then sends its address over WA to Mrs. Sari, who opens it on her own phone. The 2 hari choice must last through the reload and travel to Mrs. Sari’s phone. Choose where Paket keeps that choice.
  6. Mr. Karim, owner of Omah Kali, is annoyed: his homestay’s reviews take ages to show. He opens Omah Kali from the Inap list, which takes him to /inap/3/ulasan. The route inap/:id already has a loader for the homestay’s data. Fill the child route ulasan in rute.jsx so the homestay’s data and its reviews are requested together, once each.
  7. Bagas, the neighbourhood head’s son, helps answer guests. On the Omah Sawah page he checks free rooms for Sab 12, then quickly switches to Sab 19 before the answer comes. The server needs 2 seconds for the 12th and half a second for the 19th. The screen must end on the 19th. Fill the effect’s last line in Inap.
  8. Dina, a student home for the holidays, is nearly out of data. She opens Omah Kopi, but its data is slow, so she moves to Paket before the page shows. The router cancels that navigation, and its request to the server must stop too. Complete fetch in the loader muatInap, muat.js.
  9. Grandma Marni, owner of Omah Jati, wants to see the village map. The map is heavy, so Ms. Lintang loads it with lazy, and on the post’s phone its code takes a second and a half. Nenek taps Lihat peta: while it loads, the site’s header and the front page must stay, with Memuat peta... where the map goes. Fill the map’s place in Beranda.
  10. Mr. Harun, head of the Pokdarwis, waits for the BMKG weather on the front page. This morning BMKG sends data with no temperature, and the weather widget crashes. Only the weather may go: the site’s header, the menu and the front page stay, and Mr. Harun can still open Inap. Fill the weather’s place in Beranda.
  11. Mrs. Ratna wants to book a package for her pupils. The packages server is busy until the third second, so the loader muatPaket throws. The packages route must show its error itself inside the site, and the Coba lagi button must really ask again once the server has recovered. Fill two holes: in the packages route (rute.jsx) and in the button of GagalPaket (halaman.jsx).
  12. Mrs. Ijah, who keeps the stall by the gapura, wants to book the Coffee House homestay for her relatives. In the Inap list every homestay is a small card with a Pesan button, and the cards use overflow: hidden. The booking box must show whole over the page, and then Mrs. Ijah taps Kirim. Beside #root, the site’s page has an empty #modal-root. Fill the last line of ModalPesan.

And more, 16 levels in all.