family tree of the subscriber connected

Good morning,
sorry in advance for the translation, I’m French and I find coding very interesting but I’m clearly a beginner. I will try to be as clear as possible.

I am trying to create a family tree of the subscriber connected to his goddaughters. For this I create two collections with certain ids that I want to use for the family tree.
A collection of subscribers (id = SubscribersPlans) with name (id = name) and their avatar (id = avatar).
A collection of referrals (id = AbonnesParrainage) with their identifiers (id = subscriberId), the name of their sponsor (id = referrerName) and profile photo (id = profileImage).

I put two repeaters on the page by integrating a button to display or reduce the view of sponsorships.
The first repeater is for the currently logged in member (id = repeater6) with an area for their avatar (id = imagepar), their name (id = namepar) and the button (id = pluspar)
The second repeater is for his referrals (id = repeater7) with an area for profile photos (id = imagefil), for the referrals’ ID (id = namefil) and the button to display the referrals of the referrals (id = plusfil ).

Ideally, I would like the code to only display the referrals of the connected sponsor and to be able to automatically search for referrals of referrals endlessly, but I don’t know if that’s possible at this time. And when a goddaughter doesn’t have any results (Pas de résultats = translated by no results)

my current code partially works as I want.

import { members } from 'wix-members.v2';

impot wixData from ' wix-dat';

async function getCurrentMember() {
  try {
    const result = await members.getCurrentMember();

    return result;
  } catch (error) {
    console.error (error);
  }
};

$w.onReady( async function () {
  $w('#repeater6').onItemReady(($item,itemData,index)=>{
     $item('#imagepar').src = itemData.avatar
     $item('#namepar').text = itemData.name
  })

  $w('#pluspar').onClick(() =>{
      if ( $w"#repeater7").hidden ) {
        $w("#repeater7").show();
      }
  })
  
      async function theInclude('SubscribersPlans') {
        wixDara.query('AbonnesParParrainage')
          .eq('referrerName', 'name')
          .include("SubscribersPlans")
          .find()
          .then((myResults) =>{
            if (myResults.SubscribersPlans.value = 0 {
              let AbonnesParParrainage = myResults.SubscribersPlans;
              $w('#repeater7').onItemReady(($item,itemData,index)=>{
                $item('#imagefil').src = itemData.progileImage
                $item('#namefil').text = itemData.subscriberId
              })
                     
               
              $w('#repeater7').data = filleule;
              } else {
                console.log("Pas de résultats");
              }
          )
        }
    const {items:filleule} = await wixData.query('AbonnesParParrainage').find()
    const {items:parrain} = await wixData.query('SubscribersPlans').find()
    $w('#repeater6').data = parrain
});

Could you help me or advise me please?

You are not really trying to create a → FAMILY TREE ← in wix, don’t you ?
What a mess! :grin: :grin: :grin:

Well i would recommend you to generate it in a CUSTOM-ELEMENT or at least inside an HTML-Component!

Some examples…

Your family-tree generated in Wix, will look badly!
Maybe something like —>

Totaly ugly compared to …!

You don’t think so ?

Or maybe you want to use some embedded options from 3.rd party services?
Well also not the best solution :thinking:

1 Like

But totally. My idea is disgusting, your display is great.
like I told you, I’m discovering.
I’m going to try to do it myself first because I like learning new skills. However, in the event that I cannot do this, would you be able to do it for me? If so, could you send me a quote?