rider partner

This commit is contained in:
2026-09-24 19:06:12 +05:30
parent 2f0836df30
commit 3d404665ab

View File

@@ -194,11 +194,23 @@ export function PartnersPage() {
width: { type: 'pixel', value: 190 },
renderCell: (row) => (
<HStack gap={0.5} justify="end" align="center">
{/* A count when there is one, an instruction when there is not.
This is the ONLY way into a partner's riders, so on a partner
nobody has staffed yet it was a button labelled "0 riders" — which
reads as a figure to note rather than a thing to press, and left
people hunting for an "add rider" control that exists nowhere
else. */}
<Button
label={row.riders === null ? '—' : `${row.riders} rider${row.riders === 1 ? '' : 's'}`}
variant="secondary"
label={
row.riders === null
? '—'
: row.riders === 0
? 'Add riders'
: `${row.riders} rider${row.riders === 1 ? '' : 's'}`
}
variant={row.riders === 0 ? 'primary' : 'secondary'}
size="sm"
icon={<Bike size={13} />}
icon={row.riders === 0 ? <Plus size={13} /> : <Bike size={13} />}
onClick={() => {
const found = partners.data.find((p) => p.partnerid === row.partnerid);
if (found) setRidersFor(found);
@@ -291,6 +303,13 @@ export function PartnersPage() {
<PartnerDrawer
partner={editing === 'new' ? null : editing}
onClose={() => setEditing(null)}
/* Straight into staffing it, which is what onboarding a partner is
for. Falls back silently if the row has not landed yet — a missed
hand-off is a drawer that does not open, not a wrong one. */
onCreated={(partnerid) => {
const created = partners.data.find((p) => p.partnerid === partnerid);
if (created) setRidersFor(created);
}}
/>
) : null}
</VStack>
@@ -381,7 +400,24 @@ const EMPTY: FormState = {
locationid: 0,
};
function PartnerDrawer({ partner, onClose }: { partner: Partner | null; onClose: () => void }) {
function PartnerDrawer({
partner,
onClose,
onCreated,
}: {
partner: Partner | null;
onClose: () => void;
/**
* A partner that has just been onboarded, so the list can offer the next step.
*
* Onboarding a partner and staffing it are one job done in two places, and
* the join between them was a dead end: the drawer closed, and the only way
* back in was a button in the Fleet column labelled "0 riders" — a statistic,
* not an action. People read that as a count and went looking for an "add
* rider" control that does not exist anywhere else.
*/
onCreated?: (partnerid: number) => void;
}) {
const client = useQueryClient();
const regions = useAppRegions();
const isNew = partner === null;
@@ -486,6 +522,10 @@ function PartnerDrawer({ partner, onClose }: { partner: Partner | null; onClose:
await client.invalidateQueries({ queryKey: queryKeys.partners.all });
await client.invalidateQueries({ queryKey: queryKeys.tenants.all });
onClose();
// Only for a NEW partner, and only once the list has been refetched —
// the riders drawer reads the partner it is handed, and one that is not
// in the list yet would open against a row that does not exist.
if (!partner && partnerid > 0) onCreated?.(partnerid);
},
onError: (cause) => setError(errorMessage(cause)),
});