Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion apps/map/src/app/_components/modal/admin-regions-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export default function AdminRegionsModal({
const form = useForm({
schema: RegionInsertSchema.extend({
badImage: z.boolean().default(false),
regionLocationShortDescription: z.string().optional(),
}),
defaultValues: {
id: region?.id ?? undefined,
Expand All @@ -93,6 +94,8 @@ export default function AdminRegionsModal({
instagram: region?.instagram ?? null,
lastAnnualReview: region?.lastAnnualReview ?? null,
meta: region?.meta ?? {},
regionLocationShortDescription:
region?.meta?.region_location_short_description ?? "",
badImage: false,
},
});
Expand All @@ -113,6 +116,8 @@ export default function AdminRegionsModal({
instagram: region?.instagram ?? null,
lastAnnualReview: region?.lastAnnualReview ?? null,
meta: region?.meta ?? null,
regionLocationShortDescription:
region?.meta?.region_location_short_description ?? "",
});
}, [form, region]);

Expand Down Expand Up @@ -159,8 +164,14 @@ export default function AdminRegionsModal({
async (data) => {
setIsSubmitting(true);
try {
const { regionLocationShortDescription, ...rest } = data;
await crupdateRegion.mutateAsync({
...data,
...rest,
meta: {
...rest.meta,
region_location_short_description:
regionLocationShortDescription?.trim() || undefined,
},
orgType: "region",
});
} catch (error) {
Expand Down Expand Up @@ -443,6 +454,25 @@ export default function AdminRegionsModal({
/>
</div>
<div className="mb-4 w-full px-2 sm:w-1/2">
<FormField
control={form.control}
name="regionLocationShortDescription"
render={({ field }) => (
<FormItem>
<FormLabel>Short Location Description</FormLabel>
<FormControl>
<Input
placeholder="e.g. Denver, CO"
{...field}
value={field.value ?? ""}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="mb-4 w-1/2 px-2">
<FormField
control={form.control}
name="isActive"
Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ export type LocationMeta = {
export type OrgMeta = {
latLonKey?: string;
mapSeed?: boolean;
region_location_short_description?: string;
} & Record<string, unknown>;

export type UpdateRequestMeta = Record<string, unknown>;
Expand Down
Loading