Client Side Salsa

Category: Code Connoisseur

Description of solution: 

Crafting equipment in Minecraft lets you turn basic resources into useful tools, weapons, and armor. Better equipment helps you gather materials faster, survive dangerous mobs, and explore harder areas more safely and efficiently. 

To allow customer to order the appropriate equipment that should be printed, we created a PCF control that allow to choose an item from hundreds of different. 

Let’s see how it works: 

We have a Recipe table where the customer can create a request to build the item. 

If we go to the form, we have two fields Name and Description. For the Name field we activated the PCF control, so the form looks like at the picture: 

Click on the search button and the modal dialog will be open with a more than thousand items to choose. Here we have possibility to choose the type of item and search by the name or description. 

And when customer choose the item, the name, description and small image are set to the fields on the Recipe Model-driven app form. 

Using external API: 

PCF control receives all Minecraft items thorough public Vercel api:  

https://minecraft-api.vercel.app/api/items

Let’s look at the code structure

index.ts – main file with our control 

components/MinecraftItemPicker.tsx – React UI component 

services/MineCraftItems.service.ts – logic and data 

styles/MinecraftItemPicker.styles.ts – styles for component 

types/Minecraft.types.ts – data models/interfaces 

Performance 

  • The control cache external data in a dedicated service and reuse it across renders and dialog openings. 
  • Images are lazy loaded reducing initial load time and avoiding UI blocking. 

Maintainability 

  • The project follows a separation of responsibilities: PCF lifecycle (index.ts), UI components, services, styles, and domain types are isolated in dedicated folders. 
  • External API access and business logic are encapsulated in a service layer, that allows to make future changes easier or replacements with a low risk. 
  • The structure closely aligns with Microsoft PCF sample conventions, making the codebase easy to understand for new developers.