JoshKisb / mccod

0 stars 0 forks source link

Create fieldMap from output json #1

Open JoshKisb opened 3 months ago

JoshKisb commented 3 months ago

Create a field map from src/utils/output json using simple names like interval_a, dob, nationality etc

use short names as the keys for the fieldmap object to be saved in src/utils/fieldMap.ts instead of using a function to auto generate the name, its better to hard code the names because these are going to be used throughout the app and will not change. you can just come up with a unique name from the object displayName

for example src/utils/fieldMap.ts

export default { nationality: { id: "....", name.......}, ... }

sweep-ai[bot] commented 3 months ago
Sweeping

75%

Actions

src/utils/fieldMap.ts

Create the `fieldMap` object in the `src/utils/fieldMap.ts` file. 1.
import outputData from './output.json';

const fieldMap: Record<string, { id: string; name: string }> = {};

outputData.forEach(item => {
  let key = '';

  if (item.displayName.includes('interval_for_a')) {
    key = 'interval_a';
  } else if (item.displayName.includes('Date of Birth')) {
    key = 'dob';  
  } else if (item.displayName.includes('Nationality')) {
    key = 'nationality';
  } 
  // Add more else if conditions to map other fields

  if (key) {
    fieldMap[key] = {
      id: item.id,
      name: item.displayName
    };
  }
});

export default fieldMap;

Feel free to add more details to the issue description so Sweep can better address it. Alternatively, reach out to Kevin or William for help at https://community.sweep.dev/.

For bonus Sweep issues, please report this bug on our community forum (tracking ID: ad1f86ac3a).


[!TIP] To recreate the pull request, edit the issue title or description.

This is an automated message generated by Sweep AI.

JoshKisb commented 3 months ago

instead of using a function, its better to hard code because these are going to be used throughout the app and will not change. you can just come up with a unique name from the object displayName