scottyzen / woonuxt

Static e-commerce powered by WooCommerce & Nuxt
https://woonuxt.com
GNU General Public License v3.0
692 stars 191 forks source link

Create use country composable #202

Closed alexookah closed 3 months ago

alexookah commented 4 months ago

I noticed that the states dropdown was only being populated in the BillingDetails component on the checkout page.

This new useCountry.ts composable addresses this issue by centralizing the logic for fetching allowed countries and states. It includes the following features:

Fetching Allowed Countries:

Retrieves the list of allowed countries and filters it against the current static list of countries. Ensures the allowed countries list is only fetched once and reused thereafter, improving performance.

State Dictionary:

Maintains a dictionary for country codes mapping to their respective states. Caches state data to avoid multiple requests for the same country, enhancing performance and reducing unnecessary network calls.

Separation of Requests:

The allowed countries request has been moved out of the getStates function into a separate request. This change ensures that the allowed countries are fetched only once initially and are not redundantly requested during state retrieval. With this composable, all state inputs across the application can now reuse the same logic, ensuring consistency and correct functionality without redundant requests.

vercel[bot] commented 4 months ago

@alexookah is attempting to deploy a commit to the scottyzen's projects Team on Vercel.

A member of the Team first needs to authorize it.

netlify[bot] commented 4 months ago

Deploy Preview for sleepy-chandrasekhar-717c3d ready!

Name Link
Latest commit 1dacd86a862376be09223f4352a4bc231e2cb257
Latest deploy log https://app.netlify.com/sites/sleepy-chandrasekhar-717c3d/deploys/66c333535ef049000874cecc
Deploy Preview https://deploy-preview-202--sleepy-chandrasekhar-717c3d.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

Lighthouse
1 paths audited
Performance: 80
Accessibility: 96
Best Practices: 100
SEO: 92
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

alexookah commented 4 months ago

@scottyzen Can you give some feedback? What would you like to improve or change? Feel free to change or suggest changes!