Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
Filter in vue computed

I have a dashboard with different leads that are also sorted under different statuses.

For now all the different leads get sorted under the different statuses and it looks like this in my setup(). The changeStatus is for dragging the leads in to other statuses. (They are sorted under different "cards")

    const leads = ref<Leads[]>([])
    const sellerFilter = ref<number | null>(null)


    const statuses = useStore(leadStatuses)

    const leadsByStatus = computed(() =>
        Object.assign(
            fromPairs(statuses.value.map(s => [s.id, []])),
            groupBy(
                leads.value.filter(lead => lead.id),
                'idStatus',
            ),
        ),
    )

    const changeStatus = async (evt: any) => {
        const idStatus = evt.target.getAttribute('status-id')
        const id = evt.item.getAttribute('lead-id')

        await ('lead/update', { id }, { idStatus })
        const lead = find(leads.value, ['id', parseInt(id)])
        assert(!!lead)
        lead.idStatus = idStatus
    }

This works just fine. But now I want to add the possibility to filter on the seller assigned to the lead and I can't manage to work together in the opportunities computed. I have a seller-select that I'm importing and using in the template:

        <user-select
            v-model="sellerFilter"
            :label="$tc('Filter on sales person')"
        />

I've tried doing something like this in the "opportunities" computed:

    const leadsByStatus = computed(() => {
        function filterOnSeller(filterSeller: number | null, leadSeller: number | null) {
            return filterSeller && filterSeller !== dealSeller
        }
        return Object.assign(
            fromPairs(statuses.value.map(s => [s.id, []])),
            groupBy(
                opportunities.value.filter(lead => {
                    if (filterSeller(sellerFilter.value, lead.salesId)) {
                        return true
                    }
                    return lead.salesId
                }),
                'idStatus',
            ),
        )
    })

But I can't manage to get above work when I want to make the filter on seller part work.

In the template I'm also using a v-for to iterate through all the leads:

                <v-card
                    v-for="lead in leadsByStatus[status.id]"
                    :key="lead.id"
                   
                    :lead-id="lead.id"
                >

So if there's anyone that's know what I'm doing wrong? :)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!