{"id":22783238,"url":"https://github.com/gregolive/online-shop","last_synced_at":"2026-05-05T12:33:25.742Z","repository":{"id":183622992,"uuid":"475910373","full_name":"gregolive/online-shop","owner":"gregolive","description":"A fake online shop with a functional shopping cart.","archived":false,"fork":false,"pushed_at":"2022-04-03T08:54:08.000Z","size":6204,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T15:14:00.305Z","etag":null,"topics":["javascript","react","react-router"],"latest_commit_sha":null,"homepage":"https://gregolive.github.io/online-shop/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gregolive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-03-30T14:14:04.000Z","updated_at":"2022-04-03T06:45:13.000Z","dependencies_parsed_at":"2023-07-25T07:27:47.491Z","dependency_job_id":"e3dc4aa3-d1b3-41c6-a91d-16527b7039a4","html_url":"https://github.com/gregolive/online-shop","commit_stats":null,"previous_names":["gregolive/online-shop"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gregolive/online-shop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregolive%2Fonline-shop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregolive%2Fonline-shop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregolive%2Fonline-shop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregolive%2Fonline-shop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregolive","download_url":"https://codeload.github.com/gregolive/online-shop/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregolive%2Fonline-shop/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32649578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-05T11:29:49.557Z","status":"ssl_error","status_checked_at":"2026-05-05T11:29:48.587Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","react","react-router"],"created_at":"2024-12-11T22:07:23.771Z","updated_at":"2026-05-05T12:33:25.645Z","avatar_url":"https://github.com/gregolive.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Online Shop\n\nA fake online shop for \u003ci\u003eprospresso\u003c/i\u003e. Equipped with a functional shopping cart and mobile-friendly nav menu.\n\n[Live demo](https://gregolive.github.io/online-shop/) 👈\n\n## Functionality\n\n- Routing via \u003ccode\u003ereact-router\u003c/code\u003e allows users to navigate between home, shop and product pages\n- Storage of shopping cart items in the user's browser via \u003ccode\u003elocalStorage\u003c/code\u003e\n- On smaller screen sizes (less than 768px) the header navigation is hidden and opened with a menu button on the left side of the header\n- The shopping cart slides out from the right side of the screen on click of the cart button and opens when a new item is added\n- On the shop page user's can add a product to their cart and a quantity of 1 is used by default\n- On a product's page users can use a \u003ccode\u003eselect\u003c/code\u003e input to add a custom quantity of the product to their cart\n- In the cart an the quantity of a product can be adjusted with \u003ccode\u003e+\u003c/code\u003e and \u003ccode\u003e-\u003c/code\u003e buttons or the item can be removed entirely\n\n## Reflection\n\nI was able to implement routing and testing in react for the first time with this online shop project. \n\nRouting was acheived by importing functions from \u003ccode\u003ereact-router\u003c/code\u003e and for the most part was fairly straightforward. One issue I ran into was with generating product pages with a product's id. The project uses \u003ccode\u003euniqid\u003c/code\u003e to generate id's for the shop's dummy products, but because these are not saved to a database they re-generate on every page load. This meant that when I tried to link to a product via it's id:\n\n````\n\u003cLink to={product.id}\u003e\n````\nthe id changed on the page load and \u003ccode\u003euseParams()\u003c/code\u003e was unable to find the product with matching id. For this reason I opted to link to a profuct by their name, although this creates less appealing urls.\n\nThe main difficulty of testing was testing a product's page and supplying a mock product link. Based on a [Testing Library docs section on React Router](https://testing-library.com/docs/example-react-router/) I created the following function to supply a testProduct in \u003ccode\u003eMemoryRouter\u003c/code\u003e's \u003ccode\u003einitialEntries\u003c/code\u003e prop:\n\n````\nconst renderWithRouter = () =\u003e (\n  render(\n    \u003cMemoryRouter initialEntries={[`/shop/${testProduct.name}`]}\u003e\n      \u003cRoutes\u003e\n        \u003cRoute path='/shop/:productName' element={\u003cProduct /\u003e} /\u003e\n      \u003c/Routes\u003e\n    \u003c/MemoryRouter\u003e\n  )\n);\n````\n\n## Screenshot\n\n\u003cimg src='./screenshot.jpg' alt='online shop screenshot'\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregolive%2Fonline-shop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregolive%2Fonline-shop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregolive%2Fonline-shop/lists"}