Skip to content

Commit 3bcd687

Browse files
committed
fix(webapp): drop reloadDocument from ApplyCouponDialog and auto-close on success
1 parent 3a0a4cc commit 3bcd687

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

apps/webapp/app/components/admin/ApplyCouponDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function ApplyCouponDialog({ target, open, onOpenChange }: ApplyCouponDia
7373
</Property.Item>
7474
</Property.Table>
7575

76-
<Form method="post" className="flex flex-col gap-3" reloadDocument>
76+
<Form method="post" className="flex flex-col gap-3">
7777
<input type="hidden" name="intent" value="apply" />
7878
<input type="hidden" name="orgId" value={target.orgId} />
7979
<input type="hidden" name="dealKey" value={target.dealKey} />

apps/webapp/app/routes/admin.back-office.coupons.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Form } from "@remix-run/react";
22
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/server-runtime";
3-
import { useState } from "react";
3+
import { useEffect, useState } from "react";
44
import { redirect, typedjson, useTypedActionData, useTypedLoaderData } from "remix-typedjson";
55
import { z } from "zod";
66
import {
@@ -198,6 +198,13 @@ export default function CouponsPage() {
198198
setDialogOpen(true);
199199
};
200200

201+
// Close the dialog after a successful apply: the action redirects with
202+
// ?applied=<dealKey>, the loader echoes that as appliedDealKey, and we
203+
// dismiss the modal so the success banner underneath is visible.
204+
useEffect(() => {
205+
if (appliedDealKey) setDialogOpen(false);
206+
}, [appliedDealKey]);
207+
201208
const appliedDeal = appliedDealKey ? dealsByKey.get(appliedDealKey) : null;
202209

203210
return (

0 commit comments

Comments
 (0)