WarehouseDetailsCard
The Gift stock page's "Warehouse details" card (the mock's form under the list, saveWH): Address and Receiving hours side by side, Phone for brand questions below, Save in the header. Address and phone are required (each field says so); every brand sees the saved details.
import { WarehouseDetailsCard } from '@ergasti/bricks';Examples
Record gifts a brand sent without a claim: the warehouse banner, the brand's products with units, boxes and where they are now
Code
import { useState } from 'react';
import { Button, RecordGiftsDialog, type WarehouseDetails } from '@ergasti/bricks';
const WH: WarehouseDetails = { address: 'Warehouse 4, Industrial Zone 3, 6th of October City, Giza (sample)', hours: 'Sun–Thu · 10:00–17:00', phone: '+20 100 000 0000' };
const brands = [
{ id: 'glow', name: 'Glow Lab', products: ['Red lipstick', 'Eyeshadow palette', 'Lash mascara'].map((name, i) => ({ id: `g${i}`, name, sku: `GL-${101 + i}` })) },
{ id: 'nile', name: 'Nile Threads', products: ['Linen shirt', 'Cotton tote'].map((name, i) => ({ id: `n${i}`, name, sku: `NI-${101 + i}` })) },
];
function RecordGifts() {
const [open, setOpen] = useState(false);
const [last, setLast] = useState('');
return (
<>
<Button onClick={() => setOpen(true)}>Record gifts for a brand</Button> <small>{last}</small>
<RecordGiftsDialog open={open} onClose={() => setOpen(false)} brands={brands} warehouse={WH}
onSave={(g) => { setLast(`${g.lines.reduce((a, l) => a + l.units, 0)} units, ${g.boxes} boxes, ${g.state}`); setOpen(false); }} />
</>
);
}Where brands send gifts: the "Send to:" banner (with a Maps link) and the card PR edits it in
Code
import { useState } from 'react';
import { WarehouseDetailsCard, WarehouseNote, type WarehouseDetails } from '@ergasti/bricks';
const WH: WarehouseDetails = { address: 'Warehouse 4, Industrial Zone 3, 6th of October City, Giza (sample)', hours: 'Sun–Thu · 10:00–17:00', phone: '+20 100 000 0000' };
function Warehouse() {
const [wh, setWh] = useState(WH);
return (
<div style={{ display: 'grid', gap: 16 }}>
<WarehouseNote warehouse={wh} />
<WarehouseDetailsCard value={wh} onSave={setWh} />
</div>
);
}Saving
Pass busy while your request runs: Save is disabled. defaultBrandId opens the dialog on one brand (from that brand's page).
Code
import { RecordGiftsDialog, type WarehouseDetails } from '@ergasti/bricks';
const WH: WarehouseDetails = { address: 'Warehouse 4, Industrial Zone 3, 6th of October City, Giza (sample)', hours: 'Sun–Thu · 10:00–17:00', phone: '+20 100 000 0000' };
const brands = [
{ id: 'glow', name: 'Glow Lab', products: ['Red lipstick', 'Eyeshadow palette', 'Lash mascara'].map((name, i) => ({ id: `g${i}`, name, sku: `GL-${101 + i}` })) },
{ id: 'nile', name: 'Nile Threads', products: ['Linen shirt', 'Cotton tote'].map((name, i) => ({ id: `n${i}`, name, sku: `NI-${101 + i}` })) },
];
function Busy() {
return <RecordGiftsDialog open onClose={() => {}} onSave={() => {}} busy defaultBrandId="nile" brands={brands} warehouse={WH} />;
}Server error
When saving fails, pass its message as error: it is announced in the footer and what the user filled in stays.
Code
import { RecordGiftsDialog, type WarehouseDetails } from '@ergasti/bricks';
const WH: WarehouseDetails = { address: 'Warehouse 4, Industrial Zone 3, 6th of October City, Giza (sample)', hours: 'Sun–Thu · 10:00–17:00', phone: '+20 100 000 0000' };
const brands = [
{ id: 'glow', name: 'Glow Lab', products: ['Red lipstick', 'Eyeshadow palette', 'Lash mascara'].map((name, i) => ({ id: `g${i}`, name, sku: `GL-${101 + i}` })) },
{ id: 'nile', name: 'Nile Threads', products: ['Linen shirt', 'Cotton tote'].map((name, i) => ({ id: `n${i}`, name, sku: `NI-${101 + i}` })) },
];
function ServerError() {
return <RecordGiftsDialog open onClose={() => {}} onSave={() => {}} error="We could not save these gifts. Try again." brands={brands} warehouse={WH} />;
}Another cap
maxUnits (default 999, the mock's rule) is the most units one product may hold; set it, and the error names the range ("Enter 1 to 5,000 units for each ticked product"). Tick a product, type 6000 and Save to see it.
Code
import { RecordGiftsDialog } from '@ergasti/bricks';
const brands = [
{ id: 'glow', name: 'Glow Lab', products: ['Red lipstick', 'Eyeshadow palette', 'Lash mascara'].map((name, i) => ({ id: `g${i}`, name, sku: `GL-${101 + i}` })) },
{ id: 'nile', name: 'Nile Threads', products: ['Linen shirt', 'Cotton tote'].map((name, i) => ({ id: `n${i}`, name, sku: `NI-${101 + i}` })) },
];
function MaxUnits() {
return <RecordGiftsDialog open onClose={() => {}} onSave={() => {}} maxUnits={5000} brands={brands} />;
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key prWarehouse, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
sendTo | Send to: | ابعت على: |
maps | Open location in Maps ↗ | افتح المكان على الخريطة ↗ |
newTab | (opens in a new tab) | (بيفتح في تاب جديد) |
title | Warehouse details | بيانات المخزن |
sub | Every brand sees these on its Gifts page | كل براند بتشوف البيانات دي في صفحة الهدايا بتاعتها |
save | Save | احفظ |
address | Address | العنوان |
hours | Receiving hours | مواعيد الاستلام |
phone | Phone for brand questions | تليفون لأسئلة البراندات |
addressErr | Address is needed | لازم تكتب العنوان |
phoneErr | Phone is needed | لازم تكتب التليفون |
loading | Loading the warehouse details… | بنحمّل بيانات المخزن… |
loadError | Couldn’t load the warehouse details. Try again. | مقدرناش نحمّل بيانات المخزن. جرّب تاني. |
retry | Try again | جرّب تاني |
Design guidance
How the BRICKS design system uses WarehouseDetailsCard. Written in docs/content/components/WarehouseDetailsCard.md; the props above are read from the code, which wins where the two disagree.
The Gift stock page's "Warehouse details" form card (Address, Receiving hours, Phone for brand questions, Save); use it where PR edits the one address every brand ships gifts to.
It is the card under the PR Portal's Gift stock list (mock P.gifts, saveWH). The fields start from the saved value and reset whenever it changes; Save checks that address and phone are filled, then calls onSave with trimmed values. Every brand sees the result in WarehouseNote.
Anatomy
- Card (
Cardwith.kit-pr-gwh): a<section>named by its header. - Header: title "Warehouse details", sub "Every brand sees these on its Gifts page", and Save (
Button size="sm" variant="ink") at the end. - Fields grid (
.kit-pr-gwh-f): two equal columns, gap 14; one column at 600px and below.- Address (
FormField,<input dir="auto" autoComplete="street-address" required>). - Receiving hours (
FormField,<input dir="auto">), optional. - Phone for brand questions (
FormField,<input type="tel" dir="ltr" autoComplete="tel" required>), on the second row.
- Address (
- Field errors (
.kit-field-err,--bad, 12px 600): "Address is needed", "Phone is needed". - Save error (optional,
<p role="alert">.kit-field-err.kit-pr-gerr): theerrornode under the fields.
Variants
No visual variants. Behaviour varies by props only (busy, error).
States
| State | Trigger | Look |
|---|---|---|
| Default | value loaded | Fields filled, Save enabled. |
| Editing | User types | Local state only; nothing is saved until Save. |
| Missing required | Save pressed with address or phone blank (after trim) | Red border and "Address is needed" / "Phone is needed" under the field; onSave is not called. |
| Saving | busy | Save disabled. |
| Save failed | error | Alert text under the fields. |
| Reset | value changes (address, hours or phone) | Fields reload from it, errors clear. |
| Field hover / focus | Pointer / keyboard | #CFD1DA border on hover; --rasp border and --focus-ring-field on focus. |
Types
WarehouseDetails (value): { address, hours, phone }. PrWarehouseCopy (labels): title, sub, save, address, hours, phone, addressErr, phoneErr, and the optional loading, loadError, retry; also labels.prWarehouse on the provider.
Usage
// PR Portal › Gift stock: under the shipments table
function GiftStockPage({ rows, brands }: { rows: GiftShipmentRow[]; brands: GiftBrand[] }) {
const words = useGiftColumnsCopy('en');
const [open, setOpen] = useState(false);
const [wh, setWh] = useState<WarehouseDetails>({
address: 'Warehouse 4, Industrial Zone 3, 6th of October City, Giza',
hours: 'Sun–Thu · 10:00–17:00',
phone: '+20 100 000 0000',
});
return (
<>
<DataTable label={words.label} columns={giftShipmentColumns('en', words)} rows={rows} rowKey={(r) => r.id}
footer={<Pager page={1} lastPage={1} total={rows.length} loading={false} label={words.label} onPage={() => {}} />} />
<WarehouseDetailsCard value={wh} onSave={setWh} />
<RecordGiftsDialog open={open} onClose={() => setOpen(false)} onSave={() => setOpen(false)} brands={brands} warehouse={wh} />
</>
);
}// With a server round-trip
const save = useMutation(api.saveWarehouse);
<WarehouseDetailsCard
value={data.warehouse}
busy={save.isPending}
error={save.isError ? "We couldn't save the warehouse details. Try again." : undefined}
onSave={(next) => save.mutate(next)}
/>Where it appears
- PR Portal › Gift stock › "Warehouse details" card, the last card on the page (mock
P.gifts). Gallery screengifts; screen PR · Gift stock.
Guidelines
Do
- Pass the server's saved value; after a successful save, pass the new value so the form resets to it.
- Show a plain-language
errorthat says what to do ("Try again."). - Use the same details for
WarehouseNoteandRecordGiftsDialog'swarehouse. - Confirm a save with a toast, as the mock does ("Saved · brands see the new details"): the card shows no success state of its own.
Don't
- Don't validate the phone format yourself in the card: it checks presence only; validate on the server.
- Don't place it in a dialog: it is a screen with its own Save.
- Don't make hours required: the mock leaves them optional.
RTL and Arabic
- The grid mirrors: Address on the right, Receiving hours on the left; Save moves to the left of the header.
- Address and hours use
dir="auto"(Arabic or Latin per content); phone is alwaysdir="ltr". - Arabic copy: "بيانات المخزن", "العنوان", "مواعيد الاستلام", "تليفون لأسئلة البراندات", "احفظ", errors "لازم تكتب العنوان", "لازم تكتب التليفون".
Tokens
--card, --line, --r-lg, --ink, --ink-3, --bad, --rasp, --focus-ring-field, --field-h, --field-radius, --min-touch-target (fields grow to it at 1024px and below), --font-family-display.
Accessibility
<section>named "Warehouse details"; eachFormFieldties<label htmlFor>to its input and setsaria-describedbyandaria-invalidfrom the error, so the error is read with the field.- Address and phone carry
required;autoCompletehints (street-address,tel) help autofill. - The save error is a
<p role="alert">that mounts together with its text. Most screen readers read an inserted alert, but not all do reliably; keep the message visible and short. - Save is a real button; when
busyit isdisabled.
Found in the source
- Roles in the markup:
alert.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
WarehouseNote: the read-only "Send to:" banner built from these details.RecordGiftsDialog: shows that banner at its top.FormField/Card: the kit parts it composes;SettingRowfor switch-style settings.
See also: Banner · Button · useLanguage · BrandGiftStockCard · GiftAttentionList · GiftClaimCheck · GiftShipmentCard
Source
src/pr/gifts/Warehouse.tsx (line 98) on GitHub.