Waysdrop
On-demand delivery, connecting people, stores and couriers.
- Role
- Frontend developer
- When
- May 2025 – Jun 2026
- Built with
- Next.js, TanStack Query and Table, Google Maps, Socket.IO
- Links
- waysdrop.com
Waysdrop connects people, stores and couriers for on-demand delivery. I built its web side across eight repos: the customer app, the admin, agent and support dashboards, and the chat widget they share. The internal tools grew to dozens of screens, so the work that mattered most was the small set of components and hooks every screen is made from.
Every list is the same two components
Almost every admin screen is a Stats block over a TableList. A page passes an endpoint and its columns; the table brings search, filters, pagination kept in the URL, columns you can hide and that stay hidden, and an export button that appears whenever the API offers one. The admin alone has 49 list pages and 33 stats blocks built this way, and the agent and global admin dashboards reuse the same pieces.
Every write goes through one mutation hook and then invalidates the queries it touched, so a POST, PUT or DELETE shows up on screen the moment the server confirms it, with no reload and no stale row. Route parameters ride in the same typed object as the body: keys starting with an underscore build the URL and are stripped before the request is sent.
"use client"
import {
useQuery,
useMutation,
UseQueryResult,
UseQueryOptions,
UseMutationResult,
UseMutationOptions,
} from "@tanstack/react-query"
import api from "@/lib/axios"
import { ApiError } from "@/types"
import { AxiosError } from "axios"
export function useApiQuery<TResponse>(
key: unknown[],
url: string,
options?: Omit<
UseQueryOptions<TResponse, AxiosError<ApiError>>,
"queryKey" | "queryFn"
>
): UseQueryResult<TResponse, AxiosError<ApiError>> {
return useQuery<TResponse, AxiosError<ApiError>>({
queryKey: key,
queryFn: async () => {
const { data } = await api.get<TResponse>(url)
return data
},
...options,
})
}
function stripRouteKeys<T extends object>(variables: T): Omit<T, `_${string}`> {
return Object.fromEntries(
Object.entries(variables).filter(([k]) => !k.startsWith("_"))
) as Omit<T, `_${string}`>
}
export function useApiMutation<TResponse, TVariables = unknown>(
url: string | ((variables: TVariables) => string),
method: "post" | "put" | "patch" | "delete",
options?: Omit<
UseMutationOptions<TResponse, AxiosError<ApiError>, TVariables>,
"mutationFn"
>
): UseMutationResult<TResponse, AxiosError<ApiError>, TVariables, unknown> {
return useMutation<TResponse, AxiosError<ApiError>, TVariables, unknown>({
mutationFn: async (variables) => {
const resolvedUrl =
typeof url === "function" ? url(variables) : url
const body =
variables && typeof variables === "object"
? stripRouteKeys(variables as object)
: variables
const { data } = await api.request<TResponse>({
url: resolvedUrl,
method,
data: body,
})
return data
},
...options,
})
}Couriers on a live map
The admin's map follows every courier live. Positions arrive as batches over Server-Sent Events, and each batch is diffed against what's on the map: new couriers get a marker, moved ones have their existing marker repositioned, and ones that went offline are removed. Nothing is redrawn between batches, and nearby markers cluster into counts until you zoom in.
const toRemove = Array.from(existingLocationIds).filter(
(id) => !newLocationIds.has(id),
);
toRemove.forEach((id) => {
removeMarker(id);
locationsMapRef.current.delete(id);
});
newLocations.forEach((location) => {
const existing = locationsMapRef.current.get(location.id);
if (!existing) {
locationsMapRef.current.set(location.id, location);
updateMarkerPosition(location);
} else if (existing.lat !== location.lat || existing.lng !== location.lng) {
…
updateMarkerPosition(location);
}
});A chat widget that survives a bad connection
Support chat ships as its own package, @waysdrop/chat, so the customer app and anything else can drop it in with one component. It went through fourteen versions in two months as the support team used it. The last one changed how it treats a bad connection: it now retries forever with backoff capped at five seconds instead of giving up after ten tries, the composer never locks while it's offline so you can keep typing, and typing indicators are only sent while connected, so agents never see a stale one.
socket = io(serverUrl, {
transports: ['websocket', 'polling'],
auth: {
...(token ? { token } : {}),
...(visitorId ? { visitorId } : {}),
},
autoConnect: false,
reconnection: true,
reconnectionAttempts: Infinity,
reconnectionDelay: 500,
reconnectionDelayMax: 5000,
randomizationFactor: 0.5,
timeout: 10000,
})