Skip to content
Work

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

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.

Fig. 1Disable, confirm, and the row updates in place. Run locally against a mock API.
lib/hooks/use-api.ts · ts
"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,
  })
}
The whole hook, from the support dashboard.

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.

Fig. 2Couriers moving across Lagos as batches arrive. The stream here is simulated; the map is the real component.
components/custom/map/GoogleMaps.tsx · ts
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);
  }
});
Excerpt, trimmed with …

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.

Fig. 3A question answered, then the connection drops and comes back while you keep typing. The widget is the published package; the server is a local mock.
src/lib/socket.ts · ts
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,
})
Excerpt, trimmed with …