mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-13 15:13:07 +00:00
chore: format + e2e manifest mappings for B128 omnibox modules
This commit is contained in:
parent
0903576f9e
commit
f59d4a6736
18 changed files with 73 additions and 42 deletions
|
|
@ -46,6 +46,7 @@ export const E2E_AFFECTED_MANIFEST = [
|
|||
`${CAMPAIGN_APP}/atividades`,
|
||||
'src/components/campaign/activity',
|
||||
'src/utilities/activity',
|
||||
'src/utilities/activityOmnibox',
|
||||
'src/lib/activityQuickActions',
|
||||
],
|
||||
specs: ['campaignActivity'],
|
||||
|
|
@ -107,6 +108,15 @@ export const E2E_AFFECTED_MANIFEST = [
|
|||
'src/components/campaign/supporter',
|
||||
'src/components/campaign/votePledge',
|
||||
'src/components/campaign/auth',
|
||||
'src/lib/searchOnlyListOmnibox',
|
||||
'src/utilities/advisor',
|
||||
'src/utilities/advisorData',
|
||||
'src/utilities/campaignDemandData',
|
||||
'src/utilities/demand',
|
||||
'src/utilities/organization',
|
||||
'src/utilities/organizationData',
|
||||
'src/utilities/stateDeputyOmnibox',
|
||||
'src/utilities/supporter/supporterOmnibox',
|
||||
`${CAMPAIGN_APP}/acoes`,
|
||||
'src/components/campaign/shared/WizardMunicipality',
|
||||
'src/components/campaign/shared/useCampaignListFilterNavigation',
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
import Link from 'next/link'
|
||||
import { useMemo, useState } from 'react'
|
||||
|
||||
import type { RelationOption } from '@/components/campaign/shared/RelationMultiSelect'
|
||||
import { CampaignListOmnibox } from '@/components/campaign/shared/CampaignListOmnibox'
|
||||
import type { RelationOption } from '@/components/campaign/shared/RelationMultiSelect'
|
||||
import { useCampaignListFilterNavigation } from '@/components/campaign/shared/useCampaignListFilterNavigation'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { useMemo, useState } from 'react'
|
|||
|
||||
import { CampaignListOmnibox } from '@/components/campaign/shared/CampaignListOmnibox'
|
||||
import { useCampaignListFilterNavigation } from '@/components/campaign/shared/useCampaignListFilterNavigation'
|
||||
import { buildDemandListHref } from '@/utilities/demand/demandListUrl'
|
||||
import {
|
||||
applyDemandOmniboxSuggestion,
|
||||
buildDemandOmniboxChips,
|
||||
|
|
@ -14,7 +15,6 @@ import {
|
|||
type DemandListState,
|
||||
type DemandOmniboxAction,
|
||||
} from '@/utilities/demand/demandOmnibox'
|
||||
import { buildDemandListHref } from '@/utilities/demand/demandListUrl'
|
||||
|
||||
export const DemandFilters = ({ state }: { state: DemandListState }) => {
|
||||
const { navigate, isPending } = useCampaignListFilterNavigation({
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@ import { useMemo, useState } from 'react'
|
|||
|
||||
import { CampaignListOmnibox } from '@/components/campaign/shared/CampaignListOmnibox'
|
||||
import { useCampaignListFilterNavigation } from '@/components/campaign/shared/useCampaignListFilterNavigation'
|
||||
import { buildTerritoryListHref, type TerritoryListState } from '@/utilities/territory/territoryListUrl'
|
||||
import type { TerritoryFilterOption } from '@/utilities/territory/territoryListFilters'
|
||||
import {
|
||||
buildTerritoryListHref,
|
||||
type TerritoryListState,
|
||||
} from '@/utilities/territory/territoryListUrl'
|
||||
import {
|
||||
applyTerritoryOmniboxSuggestion,
|
||||
buildTerritoryOmniboxChips,
|
||||
|
|
|
|||
|
|
@ -24,7 +24,10 @@ export const OrganizationFilters = ({ state }: { state: OrganizationListState })
|
|||
})
|
||||
const [query, setQuery] = useState('')
|
||||
|
||||
const withPageReset = (next: OrganizationListState): OrganizationListState => ({ ...next, page: 1 })
|
||||
const withPageReset = (next: OrganizationListState): OrganizationListState => ({
|
||||
...next,
|
||||
page: 1,
|
||||
})
|
||||
|
||||
const chips = useMemo(() => buildSearchOnlyOmniboxChips(state), [state])
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
import { useMemo, useState } from 'react'
|
||||
|
||||
import type { RelationOption } from '@/components/campaign/shared/RelationMultiSelect'
|
||||
import { CampaignListOmnibox } from '@/components/campaign/shared/CampaignListOmnibox'
|
||||
import type { RelationOption } from '@/components/campaign/shared/RelationMultiSelect'
|
||||
import { useCampaignListFilterNavigation } from '@/components/campaign/shared/useCampaignListFilterNavigation'
|
||||
import { municipalityComboboxOptions } from '@/utilities/territory/territoryComboboxOptions'
|
||||
import {
|
||||
applySupporterOmniboxSuggestion,
|
||||
buildSupporterOmniboxChips,
|
||||
|
|
@ -16,6 +15,7 @@ import {
|
|||
type SupporterOmniboxAction,
|
||||
} from '@/utilities/supporter/supporterOmnibox'
|
||||
import { buildSupporterListHref, type SupporterListState } from '@/utilities/supporter/supporterUi'
|
||||
import { municipalityComboboxOptions } from '@/utilities/territory/territoryComboboxOptions'
|
||||
|
||||
export const SupporterFilters = ({
|
||||
state,
|
||||
|
|
@ -39,7 +39,8 @@ export const SupporterFilters = ({
|
|||
}, [municipalityOptions])
|
||||
|
||||
const cityOptions = useMemo(
|
||||
() => municipalityComboboxOptions().map((option) => ({ value: option.value, label: option.label })),
|
||||
() =>
|
||||
municipalityComboboxOptions().map((option) => ({ value: option.value, label: option.label })),
|
||||
[],
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,12 @@ export type SearchOnlyOmniboxAction<T extends SearchOnlyListState> =
|
|||
|
||||
const chipLabel = (dimension: string, value: string): string => `${dimension}: ${value}`
|
||||
|
||||
export const buildSearchOnlyOmniboxChips = (state: SearchOnlyListState): CampaignListOmniboxChip[] =>
|
||||
state.q ? [{ id: 'q', label: chipLabel('Busca', state.q) }] : []
|
||||
export const buildSearchOnlyOmniboxChips = (
|
||||
state: SearchOnlyListState,
|
||||
): CampaignListOmniboxChip[] => (state.q ? [{ id: 'q', label: chipLabel('Busca', state.q) }] : [])
|
||||
|
||||
export const buildSearchOnlyOmniboxSuggestions = (
|
||||
query: string,
|
||||
): CampaignListOmniboxSuggestion[] => filterOmniboxSuggestionSeeds([], query)
|
||||
export const buildSearchOnlyOmniboxSuggestions = (query: string): CampaignListOmniboxSuggestion[] =>
|
||||
filterOmniboxSuggestionSeeds([], query)
|
||||
|
||||
export const applySearchOnlyOmniboxSuggestion = <T extends SearchOnlyListState>({
|
||||
state,
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
* Activity list omnibox adapter (B128). Pure / client-safe.
|
||||
* Tab preset stays outside the omnibox (product map).
|
||||
*/
|
||||
import { activityKindLabels, activityStatusLabels } from '@/lib/schemas/activity'
|
||||
import {
|
||||
createOmniboxSuggestionSeed,
|
||||
filterOmniboxSuggestionSeeds,
|
||||
type CampaignListOmniboxChip,
|
||||
type CampaignListOmniboxSuggestion,
|
||||
} from '@/lib/campaignListOmnibox'
|
||||
import { activityKindLabels, activityStatusLabels } from '@/lib/schemas/activity'
|
||||
import {
|
||||
buildActivityListSearchParams,
|
||||
parseActivityListParams,
|
||||
|
|
@ -29,8 +29,9 @@ const chipLabel = (dimension: string, value: string): string => `${dimension}: $
|
|||
|
||||
const withPageReset = (state: ActivityListState): ActivityListState => ({ ...state, page: 1 })
|
||||
|
||||
const parseStateFromParams = (raw: Record<string, string | string[] | undefined>): ActivityListState =>
|
||||
parseActivityListParams(raw)
|
||||
const parseStateFromParams = (
|
||||
raw: Record<string, string | string[] | undefined>,
|
||||
): ActivityListState => parseActivityListParams(raw)
|
||||
|
||||
const setExclusiveField = (
|
||||
state: ActivityListState,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ import {
|
|||
type AdvisorListState,
|
||||
} from '@/utilities/advisor/advisorListUrl'
|
||||
|
||||
export type { AdvisorListState }
|
||||
export { advisorListHrefForPage, parseAdvisorListParams }
|
||||
export type { AdvisorListState }
|
||||
|
||||
type AdvisorMunicipalityViewModel = {
|
||||
id: number
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ import {
|
|||
loadMunicipalityLabelsByIds,
|
||||
} from '@/utilities/loadNamesByIds'
|
||||
|
||||
export type { DemandListState }
|
||||
export { buildDemandListHref, parseDemandListParams }
|
||||
export type { DemandListState }
|
||||
|
||||
const demandPageSize = 25
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,10 @@ export const parseDemandListParams = (searchParams: RawSearchParams): DemandList
|
|||
}
|
||||
}
|
||||
|
||||
const buildDemandListSearchParams = (state: DemandListState, page = state.page): URLSearchParams => {
|
||||
const buildDemandListSearchParams = (
|
||||
state: DemandListState,
|
||||
page = state.page,
|
||||
): URLSearchParams => {
|
||||
const params = new URLSearchParams()
|
||||
if (state.status) params.set('status', state.status)
|
||||
if (state.kind) params.set('kind', state.kind)
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@
|
|||
* Demand list omnibox adapter (B128). Status-only; kind/activity deep-links
|
||||
* stay URL-only without new list UI. Pure / client-safe.
|
||||
*/
|
||||
import {
|
||||
campaignDemandStatusLabels,
|
||||
campaignDemandStatuses,
|
||||
type CampaignDemandStatus,
|
||||
} from '@/lib/schemas/campaignDemand'
|
||||
import {
|
||||
createOmniboxSuggestionSeed,
|
||||
filterOmniboxSuggestionSeeds,
|
||||
type CampaignListOmniboxChip,
|
||||
type CampaignListOmniboxSuggestion,
|
||||
} from '@/lib/campaignListOmnibox'
|
||||
import {
|
||||
campaignDemandStatusLabels,
|
||||
campaignDemandStatuses,
|
||||
type CampaignDemandStatus,
|
||||
} from '@/lib/schemas/campaignDemand'
|
||||
import type { DemandListState } from '@/utilities/demand/demandListUrl'
|
||||
|
||||
export type { DemandListState }
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ import {
|
|||
type CampaignListOmniboxChip,
|
||||
type CampaignListOmniboxSuggestion,
|
||||
} from '@/lib/campaignListOmnibox'
|
||||
import {
|
||||
leadershipAccessFilterLabels,
|
||||
supportStatusLabels,
|
||||
} from '@/utilities/leadership/leadershipLabels'
|
||||
import {
|
||||
clearLeadershipListFilters,
|
||||
leadershipAccessFilterOptions,
|
||||
|
|
@ -23,10 +27,6 @@ import {
|
|||
type LeadershipListSortKey,
|
||||
type LeadershipListState,
|
||||
} from '@/utilities/leadership/leadershipListUrl'
|
||||
import {
|
||||
leadershipAccessFilterLabels,
|
||||
supportStatusLabels,
|
||||
} from '@/utilities/leadership/leadershipLabels'
|
||||
|
||||
const DEFAULT_LEADERSHIP_LIST_SORT_KEY: LeadershipListSortKey = 'updatedAt'
|
||||
const DEFAULT_LEADERSHIP_LIST_SORT_DIR: LeadershipListSortDirection = 'desc'
|
||||
|
|
@ -95,7 +95,9 @@ export const buildLeadershipOmniboxChips = ({
|
|||
|
||||
if (!isDefaultLeadershipListSort(state)) {
|
||||
const { sort, dir } = resolveLeadershipListSort(state)
|
||||
const option = leadershipListSortOptions.find((entry) => entry.key === sort && entry.dir === dir)
|
||||
const option = leadershipListSortOptions.find(
|
||||
(entry) => entry.key === sort && entry.dir === dir,
|
||||
)
|
||||
chips.push({
|
||||
id: 'sort',
|
||||
label: chipLabel('Ordenação', option?.label ?? `${sort} ${dir}`),
|
||||
|
|
|
|||
|
|
@ -6,15 +6,15 @@ import { relationshipId } from '@/lib/relationship'
|
|||
import type { OrganizationKind } from '@/lib/schemas/organization'
|
||||
import type { CampaignUser, Organization } from '@/payload-types'
|
||||
import type { ActivityStatus } from '@/utilities/activityUi'
|
||||
import { loadMunicipalityLabelsByIds } from '@/utilities/loadNamesByIds'
|
||||
import {
|
||||
buildOrganizationListHref,
|
||||
parseOrganizationListParams,
|
||||
type OrganizationListState,
|
||||
} from '@/utilities/organization/organizationListUrl'
|
||||
import { loadMunicipalityLabelsByIds } from '@/utilities/loadNamesByIds'
|
||||
|
||||
export type { OrganizationListState }
|
||||
export { buildOrganizationListHref, parseOrganizationListParams }
|
||||
export type { OrganizationListState }
|
||||
|
||||
const organizationPageSize = 25
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@ const isDefaultStateDeputyListSort = (state: StateDeputyListState): boolean => {
|
|||
const partyChipLabel = (party: string): string =>
|
||||
party === NO_PARTY_FILTER_VALUE ? noPartyFilterLabel : party
|
||||
|
||||
export const buildStateDeputyOmniboxChips = (state: StateDeputyListState): CampaignListOmniboxChip[] => {
|
||||
export const buildStateDeputyOmniboxChips = (
|
||||
state: StateDeputyListState,
|
||||
): CampaignListOmniboxChip[] => {
|
||||
const chips: CampaignListOmniboxChip[] = []
|
||||
|
||||
if (state.q) chips.push({ id: 'q', label: chipLabel('Busca', state.q) })
|
||||
|
|
@ -127,7 +129,9 @@ export const applyStateDeputyOmniboxSuggestion = ({
|
|||
if (suggestionId.startsWith('sort:')) {
|
||||
const raw = suggestionId.slice(5)
|
||||
const [key, dir] = raw.split('|')
|
||||
const option = stateDeputyListSortOptions.find((entry) => entry.key === key && entry.dir === dir)
|
||||
const option = stateDeputyListSortOptions.find(
|
||||
(entry) => entry.key === key && entry.dir === dir,
|
||||
)
|
||||
if (!option) return { kind: 'url', state }
|
||||
const next = withPageReset({ ...state, sort: option.key, dir: option.dir })
|
||||
if (isDefaultStateDeputyListSort(next)) {
|
||||
|
|
|
|||
|
|
@ -27,8 +27,9 @@ const chipLabel = (dimension: string, value: string): string => `${dimension}: $
|
|||
|
||||
const withPageReset = (state: SupporterListState): SupporterListState => ({ ...state, page: 1 })
|
||||
|
||||
const parseStateFromParams = (raw: Record<string, string | string[] | undefined>): SupporterListState =>
|
||||
parseSupporterListParams(raw)
|
||||
const parseStateFromParams = (
|
||||
raw: Record<string, string | string[] | undefined>,
|
||||
): SupporterListState => parseSupporterListParams(raw)
|
||||
|
||||
export const buildSupporterOmniboxChips = ({
|
||||
state,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@ const isDefaultTerritoryListSort = (state: TerritoryListState): boolean => {
|
|||
return sort === DEFAULT_TERRITORY_LIST_SORT_KEY && dir === DEFAULT_TERRITORY_LIST_SORT_DIR
|
||||
}
|
||||
|
||||
export const buildTerritoryOmniboxChips = (state: TerritoryListState): CampaignListOmniboxChip[] => {
|
||||
export const buildTerritoryOmniboxChips = (
|
||||
state: TerritoryListState,
|
||||
): CampaignListOmniboxChip[] => {
|
||||
const chips: CampaignListOmniboxChip[] = []
|
||||
|
||||
if (state.q) chips.push({ id: 'q', label: chipLabel('Busca', state.q) })
|
||||
|
|
@ -161,7 +163,8 @@ export const removeTerritoryOmniboxChip = ({
|
|||
chipId: string
|
||||
}): TerritoryOmniboxAction => {
|
||||
if (chipId === 'q') return { kind: 'url', state: { ...state, q: undefined } }
|
||||
if (chipId === 'sort') return { kind: 'url', state: { ...state, sort: undefined, dir: undefined } }
|
||||
if (chipId === 'sort')
|
||||
return { kind: 'url', state: { ...state, sort: undefined, dir: undefined } }
|
||||
|
||||
if (chipId.startsWith('region:')) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,15 @@
|
|||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { parseActivityListParams } from '@/utilities/activityUi'
|
||||
import {
|
||||
applySearchOnlyOmniboxSuggestion,
|
||||
buildSearchOnlyOmniboxChips,
|
||||
} from '@/lib/searchOnlyListOmnibox'
|
||||
import {
|
||||
applyActivityOmniboxSuggestion,
|
||||
buildActivityOmniboxChips,
|
||||
clearActivityOmnibox,
|
||||
} from '@/utilities/activityOmnibox'
|
||||
import { parseActivityListParams } from '@/utilities/activityUi'
|
||||
import { parseDemandListParams } from '@/utilities/demand/demandListUrl'
|
||||
import {
|
||||
applyDemandOmniboxSuggestion,
|
||||
|
|
@ -23,11 +27,11 @@ import {
|
|||
applyStateDeputyOmniboxSuggestion,
|
||||
buildStateDeputyOmniboxChips,
|
||||
} from '@/utilities/stateDeputyOmnibox'
|
||||
import { parseSupporterListParams } from '@/utilities/supporter/supporterUi'
|
||||
import {
|
||||
applySupporterOmniboxSuggestion,
|
||||
buildSupporterOmniboxChips,
|
||||
} from '@/utilities/supporter/supporterOmnibox'
|
||||
import { parseSupporterListParams } from '@/utilities/supporter/supporterUi'
|
||||
import { parseTerritoryListParams } from '@/utilities/territory/territoryListUrl'
|
||||
import {
|
||||
applyTerritoryOmniboxSuggestion,
|
||||
|
|
@ -35,10 +39,6 @@ import {
|
|||
buildTerritoryOmniboxSuggestionSeeds,
|
||||
filterTerritoryOmniboxSuggestions,
|
||||
} from '@/utilities/territory/territoryOmnibox'
|
||||
import {
|
||||
applySearchOnlyOmniboxSuggestion,
|
||||
buildSearchOnlyOmniboxChips,
|
||||
} from '@/lib/searchOnlyListOmnibox'
|
||||
|
||||
describe('list omnibox adapters (B128)', () => {
|
||||
it('territory builds chips and applies search', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue