{"id":24736549,"url":"https://github.com/phukon/shopping-cart-react","last_synced_at":"2025-03-22T17:23:40.815Z","repository":{"id":212246779,"uuid":"730841002","full_name":"phukon/shopping-cart-react","owner":"phukon","description":"React Context-Api practice in Typescript","archived":false,"fork":false,"pushed_at":"2024-01-17T10:24:18.000Z","size":3351,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-27T21:26:17.124Z","etag":null,"topics":["react-context-api"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/phukon.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,"roadmap":null,"authors":null}},"created_at":"2023-12-12T19:43:12.000Z","updated_at":"2023-12-14T15:44:25.000Z","dependencies_parsed_at":"2024-01-17T11:47:01.123Z","dependency_job_id":"e42119a6-a989-4bb5-bcf2-20e082594b75","html_url":"https://github.com/phukon/shopping-cart-react","commit_stats":null,"previous_names":["phukon/shopping-cart-react"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phukon%2Fshopping-cart-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phukon%2Fshopping-cart-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phukon%2Fshopping-cart-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phukon%2Fshopping-cart-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phukon","download_url":"https://codeload.github.com/phukon/shopping-cart-react/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244992886,"owners_count":20543877,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["react-context-api"],"created_at":"2025-01-27T21:26:13.609Z","updated_at":"2025-03-22T17:23:40.770Z","avatar_url":"https://github.com/phukon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Context + Typescript Practice\n\n\u003cp align='center'\u003eI wanted to brush up my React + Typescript skills and what better way to do so \u003cbr/\u003ethan by delving into contexts and diving deep into the data flow?\u003c/p\u003e\n\u003cimg src='https://github.com/phukon/shopping-cart-react/assets/60285613/52cff078-7c9a-4ab3-86eb-0026cbd4e5b7'alt=\"store screenshot\"/\u003e\n\n---\n- Used best practices for using Context (abstraction using custom hooks)\n- Items are listed in the `/store` route. \n- Items can be added doing which the cart `🛒` icon with the total number of items in the cart appears.\n- This cart `🛒` icon can be clicked to reveal a sidebar that gives the summary of the items, prices and quantities.\n- A navigation bar and three routes\n\n## Nuances\n\nWriting types was the fun part. Here are the types I wrote for the `Shopping Cart Context`\n\n### Types\n\n```typescript\ntype TShoppingCartProviderProps = {\n  children: ReactNode;\n};\n\ntype TShoppingCartContext = {\n  openCart: () =\u003e void;\n  closeCart: () =\u003e void;\n  getItemQuantity: (id: number) =\u003e number;\n  increaseCartQuantity: (id: number) =\u003e void;\n  decreaseCartQuantity: (id: number) =\u003e void;\n  removeFromCart: (id: number) =\u003e void;\n  cartQuantity: number;\n  cartItems: TCartItem[];\n};\n\ntype TCartItem = {\n  id: number;\n  quantity: number;\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphukon%2Fshopping-cart-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphukon%2Fshopping-cart-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphukon%2Fshopping-cart-react/lists"}