npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@icon-solutions/icon-segment-builder

v2.4.0

Published

Icon Segment Builder is a React Componenten developed by Icon Solutions. The component is used to structure and offer functionailty to select data about Countries, Titles, Title groups, Title levels, Functions, Function groups and Industires. The data has

Downloads

51

Readme

Icon Segment Builder

Icon Segment Builder is a React Componenten developed by Icon Solutions. The component is used to structure and offer functionailty to select data about Countries, Titles, Title groups, Title levels, Functions, Function groups and Industires. The data has to be structured based on the types offered within the NPM package.

How to use

Installation

The package is a private NPM package and is (so far) only available within the Icon Solutions development team.

npm install @icon-solutions/icon-segment-builder

Props

Disclaimer: Mandatatory props are marked with (*). Optional props are marked with (?).

countries (*)

countries requries an array of type Country. Leave as [] if you don't want to provide country-selection.

titles (*)

titles requries an array of type Title. Leave as [] if you don't want to provide title-selection.

jobFunctions (*)

jobFunctions requries an array of type JobFunction. Leave as [] if you don't want to provide job function-selection.

titleLevels (*)

titleLevels requries an array of type TitleLevel. Leave as [] if you don't want to provide title level-selection.

languages (*)

languages requries an array of type Language. Leave as [] if you don't want to provide language-selection.

naces (*)

naces requries an array of type Nace. Leave as [] if you don't want to provide nace / industry-selection. NB: Nace requires country selection to be able do determine which naces to use.

titleGroups (*)

titleGroups requries an array of type TitleGroup. Leave as [] if you don't want to provide title group-selection.

jobFunctionGroups (*)

jobFunctionGroups requries an array of type JobFunctionGroup. Leave as [] if you don't want to provide job function group-selection.

saveSegmentHandler (?)

A function that recieves data from selected items within the Icon Segment Builder (type: SegmentData). The function is triggered by the "Save"-button.

selectCountryHandler (?)

A async function that selects country. This is used within the country-selection tab and returns the selected country.

countProfilesHandler (?)

A function that recieves data from selected items within the Icon Segment Builder (type: SegmentData). The function is triggered by the "Count"-button.

importSegmentData (?)

A function returns segment data (type: SegmentData) and inject into segment builder.

Example usage

import React, { useState, useEffect } from 'react';

import { getAllTitles } from './services/titles/titles';
import { getAllTitleLevels } from './services/titleLevels/titleLevels';
import { getAllLanguages } from './services/languages/languages';
import { getAllJobFunctions } from './services/jobFunctions/jobFunctions';
import { getAllNaces } from './services/naces/naces';
import { countProfiles } from './services/count/count';
import { getAllJobFunctionGroups } from './services/jobFunctionGroups/jobFunctionGroups';
import { getAllTitleGroups } from './services/titleGroups/titleGroups';

import { SegmentBuilder, SegmentData, Title, TitleLevel, JobFunction, Language, Nace, Country, JobFunctionGroup, TitleGroup } from '@icon-solutions/icon-segment-builder';


function TestApp() {
  const [titles, setTitles] = useState<Array<Title>>([]);
  const [jobFunctions, setJobFunctions] = useState<Array<JobFunction>>([]);
  const [titleLevels, setTitleLevels] = useState<Array<TitleLevel>>([]);
  const [languages, setLanguages] = useState<Array<Language>>([]);
  const [countries, setCountries] = useState<Array<Country>>([]);
  const [naces, setNaces] = useState<Array<Nace>>([]);
  const [loading, setLoading] = useState<Boolean>(true);
  const [jobFunctionGroups, setJobFunctionGroups] = useState<Array<JobFunctionGroup>>([]);
  const [titleGroups, setTitleGroups] = useState<Array<TitleGroup>>([]);
  
  useEffect(() => {
    const fetchData = async () => {
        let titlesData = await getAllTitles();
        titlesData = await titlesData.data.recordset;
        setTitles((titlesData as unknown as Array<Title>));

        let jobFunctionsData = await getAllJobFunctions();
        jobFunctionsData = await jobFunctionsData.data.recordset;
        setJobFunctions((jobFunctionsData as unknown as Array<JobFunction>));

        let titleLevelsData = await getAllTitleLevels();
        titleLevelsData = await titleLevelsData.data.recordset;
        setTitleLevels((titleLevelsData as unknown as Array<TitleLevel>));

        let languagesData = await getAllLanguages();
        languagesData = await languagesData.data.recordset;
        setLanguages((languagesData as unknown as Array<Language>));

        let titleGroupsData = await getAllTitleGroups();
        titleGroupsData = await titleGroupsData.data.recordset;
        setTitleGroups((titleGroupsData as unknown as Array<TitleGroup>));

        let countriesData = await getAllCountries();
        countriesData = await countriesData.data.recordset;
        setCountries((countriesData as unknown as Array<Country>));

        let jobFunctionGroupsData = await getAllJobFunctionGroups();
        jobFunctionGroupsData = await jobFunctionGroupsData.data.recordset;
        setJobFunctionGroups((jobFunctionGroupsData as unknown as Array<JobFunctionGroup>));
    };

    fetchData().then(() => {
        setLoading(false);
    });
      
  }, []);

  const saveSegmentHandler = (segmentData: SegmentData) => {
      console.log("[TestApp.tsx] segmentData: ", segmentData);
  };

  const selectCountryHandler = async (selectedCountry: Country) => {
    console.log("[TestApp.tsx] selectedCountry: ", selectedCountry);
    let naceData = await getAllNaces(selectedCountry.CountryID);
    naceData = await naceData.data.recordset;
    setNaces((naceData as unknown as Array<Nace>));
  };

  const countProfilesHandler = async (segmentData: SegmentData) => {
    let countData = await countProfiles(segmentData);
    countData = await countData.data.recordset;
    console.log("[TestApp.tsx] count res:", countData)
    return (countData as any)[0].ProfileMatches;
  };

  const goBackHandler = () => {
    console.log("GO BACK!");
  };

  return (
    <div className="App">
      <header className="App-header">
        { loading ? 
          <p>Loading...</p>
          :
          <SegmentBuilder
            titles={titles}
            countries={countries}
            jobFunctions={jobFunctions}
            titleLevels={titleLevels}
            languages={languages}
            naces={naces}
            titleGroups={titleGroups}
            jobFunctionGroups={jobFunctionGroups}
            saveSegmentHandler={saveSegmentHandler}
            selectCountryHandler={selectCountryHandler}
            countProfilesHandler={countProfilesHandler}
            goBackHandler={goBackHandler}
          />
        }
      </header>
    </div>
  ); 
}

export default TestApp;