Added some small enchances
This commit is contained in:
@@ -172,12 +172,19 @@ function SalesDashboard({ data, user }: { data: Data; user: User }) {
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-9">
|
||||
{data.distribution.map((d) => (
|
||||
<Link
|
||||
className="min-h-11 rounded-md p-1"
|
||||
className="flex min-h-11 flex-col gap-2 rounded-md p-1"
|
||||
key={d.status}
|
||||
to={`/app/merchants?status=${d.status}`}
|
||||
>
|
||||
<span className="text-xs text-muted-foreground">{t(`statuses.${d.status}`)}</span>
|
||||
<span className="mt-2 block text-lg font-semibold tabular-nums">
|
||||
<span className="flex items-start gap-2 text-xs text-muted-foreground">
|
||||
<span
|
||||
className="mt-1 size-2 shrink-0 rounded-full"
|
||||
style={{ backgroundColor: stageColors[d.status] }}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span>{t(`statuses.${d.status}`)}</span>
|
||||
</span>
|
||||
<span className="mt-auto block text-lg font-semibold tabular-nums">
|
||||
{f.number(d.count)}
|
||||
</span>
|
||||
</Link>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { Controller, useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { ArrowUpRight, Check, LoaderCircle } from 'lucide-react';
|
||||
import {
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
type PublicLeadInput,
|
||||
} from '@merchantflow/contracts';
|
||||
import { Input } from '@merchantflow/ui/components/input';
|
||||
import { NativeSelect } from '@merchantflow/ui/components/native-select';
|
||||
import { Select, SelectOption } from '@merchantflow/ui/components/select';
|
||||
import { FormField } from '@merchantflow/ui/components/form-field';
|
||||
import { Button } from '@merchantflow/ui/components/button';
|
||||
import { api, ApiError } from '../lib/api';
|
||||
@@ -202,37 +202,59 @@ export function LeadForm() {
|
||||
</FormField>
|
||||
))}
|
||||
<FormField id="lead-country" label={t('landing.country')} error={errorText('country')}>
|
||||
<NativeSelect
|
||||
{...form.register('country')}
|
||||
{...accessibility('country')}
|
||||
autoComplete="country"
|
||||
className="w-full"
|
||||
>
|
||||
<option value="" disabled>
|
||||
{t('landing.countryPlaceholder')}
|
||||
</option>
|
||||
{countries.map(({ code, name }) => (
|
||||
<option key={code} value={code}>
|
||||
{name}
|
||||
</option>
|
||||
))}
|
||||
</NativeSelect>
|
||||
<Controller
|
||||
name="country"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
name={field.name}
|
||||
disabled={mutation.isPending}
|
||||
ref={field.ref}
|
||||
value={field.value ?? ''}
|
||||
onValueChange={field.onChange}
|
||||
onBlur={field.onBlur}
|
||||
{...accessibility('country')}
|
||||
autoComplete="country"
|
||||
className="w-full"
|
||||
>
|
||||
<SelectOption value="" disabled>
|
||||
{t('landing.countryPlaceholder')}
|
||||
</SelectOption>
|
||||
{countries.map(({ code, name }) => (
|
||||
<SelectOption key={code} value={code}>
|
||||
{name}
|
||||
</SelectOption>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
</FormField>
|
||||
<FormField id="lead-industry" label={t('landing.industry')} error={errorText('industry')}>
|
||||
<NativeSelect
|
||||
{...form.register('industry')}
|
||||
{...accessibility('industry')}
|
||||
className="w-full"
|
||||
>
|
||||
<option value="" disabled>
|
||||
{t('landing.industryPlaceholder')}
|
||||
</option>
|
||||
{industries.map((industry) => (
|
||||
<option key={industry} value={industry}>
|
||||
{t(`industry.${industry}`)}
|
||||
</option>
|
||||
))}
|
||||
</NativeSelect>
|
||||
<Controller
|
||||
name="industry"
|
||||
control={form.control}
|
||||
render={({ field }) => (
|
||||
<Select
|
||||
name={field.name}
|
||||
disabled={mutation.isPending}
|
||||
ref={field.ref}
|
||||
value={field.value ?? ''}
|
||||
onValueChange={field.onChange}
|
||||
onBlur={field.onBlur}
|
||||
{...accessibility('industry')}
|
||||
className="w-full"
|
||||
>
|
||||
<SelectOption value="" disabled>
|
||||
{t('landing.industryPlaceholder')}
|
||||
</SelectOption>
|
||||
{industries.map((industry) => (
|
||||
<SelectOption key={industry} value={industry}>
|
||||
{t(`industry.${industry}`)}
|
||||
</SelectOption>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
</FormField>
|
||||
<div className="lead-volume">
|
||||
<FormField
|
||||
|
||||
@@ -74,6 +74,7 @@ export function ReminderInbox() {
|
||||
<TaskRow task={task} onNavigate={() => setOpen(false)} />
|
||||
<Button
|
||||
variant="outline"
|
||||
className="mt-3"
|
||||
disabled={dismissal.isPending}
|
||||
onClick={() => dismissal.mutate(task)}
|
||||
>
|
||||
|
||||
@@ -140,7 +140,7 @@ export function ActionableTask({ task }: { task: Task }) {
|
||||
return (
|
||||
<div id={`task-${task.id}`} className="border-t first:border-0 scroll-mt-5">
|
||||
<TaskRow task={task} />
|
||||
<div className="flex flex-wrap items-center gap-2 px-5 pb-4">
|
||||
<div className="flex flex-wrap items-center gap-2 px-5 py-4">
|
||||
{task.capabilities.edit && (
|
||||
<Button variant="outline" onClick={() => setEditing(task)}>
|
||||
{t('workflow.editTask')}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useId, useState, type ReactNode } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { Controller, useForm } from 'react-hook-form';
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { z } from 'zod';
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
SheetDescription,
|
||||
} from '@merchantflow/ui/components/sheet';
|
||||
import { Input } from '@merchantflow/ui/components/input';
|
||||
import { NativeSelect } from '@merchantflow/ui/components/native-select';
|
||||
import { Select, SelectOption } from '@merchantflow/ui/components/select';
|
||||
import { FormField } from '@merchantflow/ui/components/form-field';
|
||||
import { api, ApiError, queryClient } from '../lib/api';
|
||||
import { Button } from './shared';
|
||||
@@ -107,13 +107,29 @@ export function Editor({
|
||||
error={errors[field.name]}
|
||||
>
|
||||
{field.options ? (
|
||||
<NativeSelect {...props}>
|
||||
{field.options.map((option) => (
|
||||
<option key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</option>
|
||||
))}
|
||||
</NativeSelect>
|
||||
<Controller
|
||||
name={field.name}
|
||||
control={form.control}
|
||||
render={({ field: control }) => (
|
||||
<Select
|
||||
id={fieldId}
|
||||
name={control.name}
|
||||
ref={control.ref}
|
||||
value={control.value ?? ''}
|
||||
onValueChange={control.onChange}
|
||||
onBlur={control.onBlur}
|
||||
disabled={pending || field.disabled}
|
||||
aria-invalid={!!errors[field.name]}
|
||||
aria-describedby={props['aria-describedby']}
|
||||
>
|
||||
{field.options!.map((option) => (
|
||||
<SelectOption key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</SelectOption>
|
||||
))}
|
||||
</Select>
|
||||
)}
|
||||
/>
|
||||
) : field.type === 'textarea' ? (
|
||||
<textarea
|
||||
{...props}
|
||||
|
||||
@@ -17,6 +17,18 @@ it('canonicalizes invalid/default query values while retaining search typing and
|
||||
).toBe('');
|
||||
expect(directoryParams(new URLSearchParams('page=1'), 'HEAD_OF_SALES').toString()).toBe('');
|
||||
});
|
||||
it('retains supported page sizes and drops unsupported values', () => {
|
||||
for (const size of ['10', '20', '30'])
|
||||
expect(
|
||||
directoryParams(new URLSearchParams(`pageSize=${size}&page=2`), 'HEAD_OF_SALES').get(
|
||||
'pageSize',
|
||||
),
|
||||
).toBe(size);
|
||||
for (const size of ['8', '15', '0', '1000', 'invalid'])
|
||||
expect(
|
||||
directoryParams(new URLSearchParams(`pageSize=${size}`), 'HEAD_OF_SALES').has('pageSize'),
|
||||
).toBe(false);
|
||||
});
|
||||
it('removes owner controls from manager URLs without dropping the rest of their search', () => {
|
||||
const result = directoryParams(
|
||||
new URLSearchParams('search=hello&ownerId=user-manager2&country=GB&page=3'),
|
||||
|
||||
@@ -11,6 +11,7 @@ export function directoryParams(input: URLSearchParams, role: Role) {
|
||||
'industry',
|
||||
'ownerId',
|
||||
'page',
|
||||
'pageSize',
|
||||
'createdFrom',
|
||||
'createdTo',
|
||||
'cohort',
|
||||
|
||||
@@ -27,6 +27,7 @@ export const en = {
|
||||
next: 'Next',
|
||||
page: 'Page {{page}} of {{total}}',
|
||||
showing: '{{from}}–{{to}} of {{total}} merchants',
|
||||
perPage: 'Show per page',
|
||||
all: 'All',
|
||||
language: 'Language',
|
||||
logout: 'Sign out',
|
||||
@@ -262,6 +263,7 @@ export const ru = {
|
||||
next: 'Далее',
|
||||
page: 'Страница {{page}} из {{total}}',
|
||||
showing: '{{from}}–{{to}} из {{total}} мерчантов',
|
||||
perPage: 'На странице',
|
||||
all: 'Все',
|
||||
language: 'Язык',
|
||||
logout: 'Выйти',
|
||||
|
||||
+60
-44
@@ -38,7 +38,7 @@ import {
|
||||
type Merchant,
|
||||
} from '@merchantflow/contracts';
|
||||
import { Input } from '@merchantflow/ui/components/input';
|
||||
import { NativeSelect } from '@merchantflow/ui/components/native-select';
|
||||
import { Select, SelectOption } from '@merchantflow/ui/components/select';
|
||||
import {
|
||||
Table,
|
||||
TableHeader,
|
||||
@@ -245,75 +245,77 @@ export function Merchants() {
|
||||
aria-label={t('workspace.filters')}
|
||||
className="grid gap-2 sm:grid-cols-2 xl:grid-cols-4"
|
||||
>
|
||||
<NativeSelect
|
||||
<Select
|
||||
aria-label={t('merchants.filter')}
|
||||
value={status}
|
||||
onChange={(e) => update('status', e.target.value)}
|
||||
onValueChange={(value) => update('status', value)}
|
||||
className="w-full bg-white sm:min-w-[190px]"
|
||||
>
|
||||
<option value="">{t('merchants.allStages')}</option>
|
||||
<SelectOption value="">{t('merchants.allStages')}</SelectOption>
|
||||
{statuses.map((s) => (
|
||||
<option key={s} value={s}>
|
||||
<SelectOption key={s} value={s}>
|
||||
{t(`statuses.${s}`)}
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
</NativeSelect>
|
||||
<NativeSelect
|
||||
</Select>
|
||||
<Select
|
||||
className="w-full bg-white"
|
||||
aria-label={t('workspace.allCountries')}
|
||||
value={normalized.get('country') ?? ''}
|
||||
onChange={(event) => update('country', event.target.value)}
|
||||
onValueChange={(value) => update('country', value)}
|
||||
>
|
||||
<option value="">{t('workspace.allCountries')}</option>
|
||||
<SelectOption value="">{t('workspace.allCountries')}</SelectOption>
|
||||
{[
|
||||
...new Set([
|
||||
...(filters.data?.countries ?? []),
|
||||
...(normalized.get('country') ? [normalized.get('country')!] : []),
|
||||
]),
|
||||
].map((country) => (
|
||||
<option key={country} value={country}>
|
||||
<SelectOption key={country} value={country}>
|
||||
{f.country(country)}
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
</NativeSelect>
|
||||
<NativeSelect
|
||||
</Select>
|
||||
<Select
|
||||
className="w-full bg-white"
|
||||
aria-label={t('workspace.allIndustries')}
|
||||
value={normalized.get('industry') ?? ''}
|
||||
onChange={(event) => update('industry', event.target.value)}
|
||||
onValueChange={(value) => update('industry', value)}
|
||||
>
|
||||
<option value="">{t('workspace.allIndustries')}</option>
|
||||
<SelectOption value="">{t('workspace.allIndustries')}</SelectOption>
|
||||
{[
|
||||
...new Set([
|
||||
...(filters.data?.industries ?? []),
|
||||
...(normalized.get('industry') ? [normalized.get('industry')!] : []),
|
||||
]),
|
||||
].map((industry) => (
|
||||
<option key={industry} value={industry}>
|
||||
<SelectOption key={industry} value={industry}>
|
||||
{t(`industry.${industry}`)}
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
</NativeSelect>
|
||||
</Select>
|
||||
{filters.data?.canFilterOwner && (
|
||||
<NativeSelect
|
||||
<Select
|
||||
className="w-full bg-white"
|
||||
aria-label={t('workspace.allOwners')}
|
||||
value={normalized.get('ownerId') ?? ''}
|
||||
onChange={(event) => update('ownerId', event.target.value)}
|
||||
onValueChange={(value) => update('ownerId', value)}
|
||||
>
|
||||
<option value="">{t('workspace.allOwners')}</option>
|
||||
<option value="unassigned">{t('workflow.unassigned')}</option>
|
||||
<SelectOption value="">{t('workspace.allOwners')}</SelectOption>
|
||||
<SelectOption value="unassigned">{t('workflow.unassigned')}</SelectOption>
|
||||
{filters.data.owners.map((owner) => (
|
||||
<option key={owner.id} value={owner.id}>
|
||||
<SelectOption key={owner.id} value={owner.id}>
|
||||
{owner.name}
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
{normalized.get('ownerId') &&
|
||||
normalized.get('ownerId') !== 'unassigned' &&
|
||||
!filters.data.owners.some((owner) => owner.id === normalized.get('ownerId')) && (
|
||||
<option value={normalized.get('ownerId')!}>{t('workspace.notProvided')}</option>
|
||||
<SelectOption value={normalized.get('ownerId')!}>
|
||||
{t('workspace.notProvided')}
|
||||
</SelectOption>
|
||||
)}
|
||||
</NativeSelect>
|
||||
</Select>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -363,6 +365,20 @@ export function Merchants() {
|
||||
total: f.number(data.total),
|
||||
})}
|
||||
</p>
|
||||
<label className="flex items-center gap-2 text-xs text-muted-foreground sm:ml-auto">
|
||||
<span>{t('common.perPage')}</span>
|
||||
<Select
|
||||
className="w-20 bg-white"
|
||||
value={normalized.get('pageSize') ?? '10'}
|
||||
onValueChange={(value) => update('pageSize', value)}
|
||||
>
|
||||
{['10', '20', '30'].map((value) => (
|
||||
<SelectOption key={value} value={value}>
|
||||
{f.number(Number(value))}
|
||||
</SelectOption>
|
||||
))}
|
||||
</Select>
|
||||
</label>
|
||||
<nav
|
||||
aria-label={t('common.page', {
|
||||
page: f.number(page),
|
||||
@@ -677,19 +693,19 @@ export function Pipeline() {
|
||||
<QueryBoundary query={query}>
|
||||
{(merchants) => (
|
||||
<>
|
||||
<NativeSelect
|
||||
<Select
|
||||
className="mb-5 w-full md:hidden"
|
||||
aria-label={t('pipeline.stageSelect')}
|
||||
value={stage}
|
||||
onChange={(event) => setParams({ stage: event.target.value })}
|
||||
onValueChange={(value) => setParams({ stage: value })}
|
||||
>
|
||||
{statuses.map((value) => (
|
||||
<option key={value} value={value}>
|
||||
<SelectOption key={value} value={value}>
|
||||
{t(`statuses.${value}`)} (
|
||||
{f.number(merchants.filter((merchant) => merchant.status === value).length)})
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
</NativeSelect>
|
||||
</Select>
|
||||
<div
|
||||
className="flex gap-4 overflow-x-auto pb-4"
|
||||
aria-label={t('pipeline.title')}
|
||||
@@ -813,39 +829,39 @@ export function ReviewQueue() {
|
||||
</label>
|
||||
<label className="space-y-2 text-xs text-muted-foreground">
|
||||
<span>{t('common.owner')}</span>
|
||||
<NativeSelect
|
||||
<Select
|
||||
className="w-full"
|
||||
value={filters.get('ownerId') ?? ''}
|
||||
onChange={(event) => update('ownerId', event.target.value)}
|
||||
onValueChange={(value) => update('ownerId', value)}
|
||||
>
|
||||
<option value="">{t('workspace.allOwners')}</option>
|
||||
<option value="unassigned">{t('workflow.unassigned')}</option>
|
||||
<SelectOption value="">{t('workspace.allOwners')}</SelectOption>
|
||||
<SelectOption value="unassigned">{t('workflow.unassigned')}</SelectOption>
|
||||
{query.data?.owners.map((owner) => (
|
||||
<option key={owner.id} value={owner.id}>
|
||||
<SelectOption key={owner.id} value={owner.id}>
|
||||
{owner.name}
|
||||
</option>
|
||||
</SelectOption>
|
||||
))}
|
||||
</NativeSelect>
|
||||
</Select>
|
||||
</label>
|
||||
<label className="space-y-2 text-xs text-muted-foreground">
|
||||
<span>{t(decided ? 'workflow.decision' : 'onboarding.waitingTime')}</span>
|
||||
<NativeSelect
|
||||
<Select
|
||||
className="w-full"
|
||||
value={filters.get(decided ? 'decision' : 'waiting') ?? 'ALL'}
|
||||
onChange={(event) => update(decided ? 'decision' : 'waiting', event.target.value)}
|
||||
onValueChange={(value) => update(decided ? 'decision' : 'waiting', value)}
|
||||
>
|
||||
{(decided ? ['ALL', 'APPROVED', 'CORRECTIONS', 'REJECTED'] : ['ALL', '24', '72']).map(
|
||||
(value) => (
|
||||
<option key={value} value={value}>
|
||||
<SelectOption key={value} value={value}>
|
||||
{t(
|
||||
decided && value !== 'ALL'
|
||||
? `workflow.${value}`
|
||||
: `onboarding.waiting.${value}`,
|
||||
)}
|
||||
</option>
|
||||
</SelectOption>
|
||||
),
|
||||
)}
|
||||
</NativeSelect>
|
||||
</Select>
|
||||
</label>
|
||||
</section>
|
||||
<QueryBoundary query={query}>
|
||||
|
||||
@@ -294,7 +294,7 @@
|
||||
min-width: 0;
|
||||
}
|
||||
.lead-fields input,
|
||||
.lead-fields select {
|
||||
.lead-fields [data-slot='select-trigger'] {
|
||||
background: #fcfdf9;
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user