'Data structure when submitting in Firestore that handles tracking of inventories with product variations

Each product may have variations of sizes and each with its different colors and quantities.

Example:

  • Product Name: Shirt

  • Size: Large

  • Color: Red, Qty: 10

  • Color: Blue, Qty: 5

  • Product Name: Cupp

  • Size: Large

  • Color: Red, Qty: 10

  • Color: Blue, Qty: 5

The way I submitted it and what shows in the console:

enter image description here

Code: Link: https://codesandbox.io/s/form-order-working-4f6g2

Firestore:

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source