Add migration to include site_name column in cities table
This commit is contained in:
@@ -370,6 +370,7 @@ function ProvincesTab() {
|
||||
|
||||
const citySchema = z.object({
|
||||
name: z.string().min(1, 'نام الزامی است'),
|
||||
site_name: z.string().optional(),
|
||||
province_id: z.number().nullable().optional(),
|
||||
weight: z.string().optional(),
|
||||
status: z.string().optional(),
|
||||
@@ -436,6 +437,7 @@ function CitiesTab() {
|
||||
status: parseInt(d.status ?? '1'),
|
||||
province_id: d.province_id ?? null,
|
||||
representation_id: d.representation_id ?? null,
|
||||
...(d.site_name?.trim() && { site_name: d.site_name.trim() }),
|
||||
...(d.contact_phone?.trim() && { contact_phone: d.contact_phone.trim() }),
|
||||
...(d.email?.trim() && { email: d.email.trim() }),
|
||||
...(d.description?.trim() && { description: d.description.trim() }),
|
||||
@@ -467,6 +469,7 @@ function CitiesTab() {
|
||||
setEditTarget(c);
|
||||
reset({
|
||||
name: c.name, weight: String(c.weight), status: String(c.status),
|
||||
site_name: c.site_name ?? '',
|
||||
province_id: c.province_id ?? null,
|
||||
representation_id: c.representation_id ?? null,
|
||||
contact_phone: c.contact_phone ?? '',
|
||||
@@ -482,6 +485,7 @@ function CitiesTab() {
|
||||
const columns: Column<City>[] = [
|
||||
{ key: 'id', sortable: true, header: 'شناسه', render: (c) => <span className="muted" style={{ fontFamily: 'monospace', fontSize: 12 }}>{c.id}</span> },
|
||||
{ key: 'name', header: 'نام', render: (c) => <b>{c.name}</b> },
|
||||
{ key: 'site_name', header: 'نام سایت', render: (c) => c.site_name ? <span>{c.site_name}</span> : <span className="muted">—</span> },
|
||||
{ key: 'province_id', header: 'استان', render: (c) => c.province_id ? <span className="chip">{provinceMap[c.province_id] ?? `#${c.province_id}`}</span> : <span className="muted">—</span> },
|
||||
{ key: 'representation_id', header: 'نماینده', render: (c) => c.representation_id ? <span className="muted" style={{ fontSize: 12 }}>{representationMap[c.representation_id] ?? `#${c.representation_id}`}</span> : <span className="muted">—</span> },
|
||||
{ key: 'domain', header: 'دامنه', render: (c) => c.domain ? <span className="muted" style={{ fontFamily: 'monospace', fontSize: 12 }}>{c.domain}</span> : <span className="muted">—</span> },
|
||||
@@ -511,6 +515,10 @@ function CitiesTab() {
|
||||
<input {...register('name')} className="input" placeholder="نام شهر" />
|
||||
{errors.name && <p className="err-text">{errors.name.message}</p>}
|
||||
</div>
|
||||
<div className="form-row" style={{ marginTop: 12 }}>
|
||||
<label>نام سایت</label>
|
||||
<input {...register('site_name')} className="input" placeholder="مثال: یزد نوبت" />
|
||||
</div>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12, marginTop: 12 }}>
|
||||
<div className="form-row">
|
||||
<label>استان</label>
|
||||
|
||||
@@ -230,6 +230,7 @@ export interface City {
|
||||
id: number;
|
||||
uuid: string;
|
||||
name: string;
|
||||
site_name?: string | null;
|
||||
status: number;
|
||||
weight: number;
|
||||
province_id: number | null;
|
||||
|
||||
Reference in New Issue
Block a user