Upgrade react-zen and migrate attribution and menu controls to updated components

This commit is contained in:
Mike Cao committed 2026-07-31 22:14:31 -07:00
1 parent cfe8020831
commit df302595c0
7 files changed
+48 -130

No files matched your search

@@ -1,12 +1,13 @@
'use client';
import { Column, Grid, Label, ListItem, Loading, Select } from '@umami/react-zen';
import { Column, Grid, ListItem, Select } from '@umami/react-zen';
import { useState } from 'react';
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
import { Empty } from '@/components/common/Empty';
import { MultiSelect, MultiSelectItem } from '@/components/common/MultiSelect';
import { useDateRange, useMessages, useWebsiteValuesQuery } from '@/components/hooks';
import { Attribution } from './Attribution';
const stepPlaceholder = 'Select an item';
export function AttributionPage({ websiteId }: { websiteId: string }) {
const [model, setModel] = useState('first-click');
const [type, setType] = useState('path');
@@ -31,10 +32,6 @@ export function AttributionPage({ websiteId }: { websiteId: string }) {
setSearch('');
};
const handleStepChange = (values: string[]) => {
setStep(values.filter(value => value !== step).pop() ?? '');
};
return (
<Column gap="6">
<WebsiteControls websiteId={websiteId} />
@@ -62,21 +59,24 @@ export function AttributionPage({ websiteId }: { websiteId: string }) {
</Select>
</Column>
<Column>
<Label>{t(labels.conversionStep)}</Label>
<MultiSelect
value={step ? [step] : []}
onChange={handleStepChange}
<Select
label={t(labels.conversionStep)}
value={step}
onChange={value => setStep(value?.toString() ?? '')}
placeholder={stepPlaceholder}
renderValue={({ defaultChildren }) => (step ? defaultChildren : stepPlaceholder)}
isLoading={isLoading}
searchValue={search}
onSearch={setSearch}
renderEmptyState={() => (isLoading ? <Loading icon="dots" /> : <Empty />)}
maxHeight={320}
allowSearch
>
{items.map(({ value }) => (
<MultiSelectItem key={value} value={value}>
<ListItem key={value} id={value}>
{value}
</MultiSelectItem>
</ListItem>
))}
</MultiSelect>
</Select>
</Column>
</Grid>
{step ? (
+1 -1
View File
@@ -5,7 +5,7 @@ import type { ReactElement } from 'react';
export function ControlledDialog({ children }: { children: ReactElement }) {
return (
<DialogTrigger>
<span hidden />
<button type="button" hidden />
{children}
</DialogTrigger>
);
+26 -29
View File
@@ -1,6 +1,5 @@
import {
Button,
Column,
Icon,
Menu,
MenuItem,
@@ -72,36 +71,34 @@ export function TeamsButton() {
</Icon>
</Button>
<Popover side="bottom" align="start">
<Column minWidth="300px">
<Menu selectionMode="single" selectedKeys={selectedKeys}>
<MenuSection title={t(labels.myAccount)}>
<MenuItem id="user" onAction={handleAction}>
<IconLabel icon={<User />} label={user.username} />
<Menu className="min-w-[300px]" selectionMode="single" selectedKeys={selectedKeys}>
<MenuSection title={t(labels.myAccount)}>
<MenuItem id="user" onAction={handleAction}>
<IconLabel icon={<User />} label={user.username} />
</MenuItem>
</MenuSection>
<MenuSeparator />
<MenuSection title={t(labels.teams)}>
{user?.teams?.map(({ id, name }) => (
<MenuItem key={id} id={id} onAction={() => handleNavigate(getUrl(`/teams/${id}`))}>
<IconLabel icon={<Users />}>
<Text wrap="nowrap">{name}</Text>
</IconLabel>
</MenuItem>
</MenuSection>
))}
<MenuSeparator />
<MenuSection title={t(labels.teams)}>
{user?.teams?.map(({ id, name }) => (
<MenuItem key={id} id={id} onAction={() => handleNavigate(getUrl(`/teams/${id}`))}>
<IconLabel icon={<Users />}>
<Text wrap="nowrap">{name}</Text>
</IconLabel>
</MenuItem>
))}
<MenuSeparator />
<MenuItem id="manage-teams">
<a href="/settings/teams" style={{ width: '100%' }}>
<Row alignItems="center" justifyContent="space-between" gap>
<Text align="center">Manage teams</Text>
<Icon>
<ArrowRight />
</Icon>
</Row>
</a>
</MenuItem>
</MenuSection>
</Menu>
</Column>
<MenuItem id="manage-teams">
<a href="/settings/teams" style={{ width: '100%' }}>
<Row alignItems="center" justifyContent="space-between" gap>
<Text align="center">Manage teams</Text>
<Icon>
<ArrowRight />
</Icon>
</Row>
</a>
</MenuItem>
</MenuSection>
</Menu>
</Popover>
</MenuTrigger>
);