Skip to content

Commit ed0d215

Browse files
committed
[TOOL-2995]: Fix Engine Contract Subscription UI issue with checkboxes (#5920)
--- title: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" --- If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the user interface for checkbox components in the `batch-lazy-mint.tsx` and `add-contract-subscription-button.tsx` files. It improves the handling of checkbox states and integrates labels more effectively. ### Detailed summary - In `batch-lazy-mint.tsx`, replaced `Checkbox` with a more integrated `CheckboxWithLabel`. - Updated checkbox handling to use `form.watch` and `form.setValue` for state management. - In `add-contract-subscription-button.tsx`, converted checkboxes to use `CheckboxWithLabel` for better labeling. - Simplified checkbox state handling by removing `form.register`. - Adjusted label elements from `<Text>` to `<span>` for consistency. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent c5c6f9d commit ed0d215

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

apps/dashboard/src/app/team/[team_slug]/(team)/~/engine/(instance)/[engineId]/contract-subscriptions/components/add-contract-subscription-button.tsx

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
} from "@3rdweb-sdk/react/hooks/useEngine";
1010
import { useResolveContractAbi } from "@3rdweb-sdk/react/hooks/useResolveContractAbi";
1111
import {
12-
CheckboxGroup,
1312
Collapse,
1413
Flex,
1514
FormControl,
@@ -324,21 +323,21 @@ const ModalBodyInputData = ({
324323
<FormLabel>Processed Data</FormLabel>
325324

326325
<div className="flex flex-col gap-2">
327-
<Checkbox
328-
{...form.register("processEventLogs")}
329-
checked={form.getValues("processEventLogs")}
330-
onCheckedChange={(val) => {
331-
const checked = !!val;
332-
form.setValue("processEventLogs", checked);
333-
if (checked) {
334-
processEventLogsDisclosure.onOpen();
335-
} else {
336-
processEventLogsDisclosure.onClose();
337-
}
338-
}}
339-
>
340-
<Text>Event Logs</Text>
341-
</Checkbox>
326+
<CheckboxWithLabel>
327+
<Checkbox
328+
checked={form.watch("processEventLogs")}
329+
onCheckedChange={(val) => {
330+
const checked = !!val;
331+
form.setValue("processEventLogs", checked);
332+
if (checked) {
333+
processEventLogsDisclosure.onOpen();
334+
} else {
335+
processEventLogsDisclosure.onClose();
336+
}
337+
}}
338+
/>
339+
<span>Event Logs</span>
340+
</CheckboxWithLabel>
342341
{/* Shows all/specific events if processing event logs */}
343342
<Collapse in={processEventLogsDisclosure.isOpen}>
344343
<div className="flex flex-col gap-2 px-4">
@@ -382,8 +381,7 @@ const ModalBodyInputData = ({
382381

383382
<CheckboxWithLabel>
384383
<Checkbox
385-
{...form.register("processTransactionReceipts")}
386-
checked={form.getValues("processTransactionReceipts")}
384+
checked={form.watch("processTransactionReceipts")}
387385
onCheckedChange={(val) => {
388386
const checked = !!val;
389387
form.setValue("processTransactionReceipts", checked);
@@ -394,7 +392,7 @@ const ModalBodyInputData = ({
394392
}
395393
}}
396394
/>
397-
<Text>Transaction Receipts</Text>
395+
<span>Transaction Receipts</span>
398396
</CheckboxWithLabel>
399397
{/* Shows all/specific functions if processing transaction receipts */}
400398
<Collapse in={processTransactionReceiptsDisclosure.isOpen}>
@@ -546,16 +544,21 @@ const FilterSelector = ({
546544
</Text>
547545
) : (
548546
<div className="flex max-h-[300px] flex-col gap-2 overflow-y-auto">
549-
<CheckboxGroup
550-
value={filter}
551-
onChange={(selected: string[]) => setFilter(selected)}
552-
>
553-
{filterNames.map((name) => (
554-
<Checkbox key={name} value={name}>
555-
<Text>{name}</Text>
556-
</Checkbox>
557-
))}
558-
</CheckboxGroup>
547+
{filterNames.map((name) => (
548+
<CheckboxWithLabel key={name}>
549+
<Checkbox
550+
checked={filter.includes(name)}
551+
onCheckedChange={(val) => {
552+
if (val) {
553+
setFilter([...filter, name]);
554+
} else {
555+
setFilter(filter.filter((item) => item !== name));
556+
}
557+
}}
558+
/>
559+
<span>{name}</span>
560+
</CheckboxWithLabel>
561+
))}
559562
</div>
560563
)}
561564
</Card>

apps/dashboard/src/core-ui/batch-upload/batch-lazy-mint.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,11 @@ export const BatchLazyMint: ComponentWithChildren<
251251
{form.watch("revealType") && (
252252
<>
253253
<CheckboxWithLabel>
254-
<Checkbox {...form.register("shuffle")} className="mt-3" />
254+
<Checkbox
255+
className="mt-3"
256+
checked={form.watch("shuffle")}
257+
onCheckedChange={(val) => form.setValue("shuffle", !!val)}
258+
/>
255259
<div className="flex flex-col items-center gap-1 md:flex-row">
256260
<p>Shuffle the order of the NFTs before uploading.</p>
257261
<em>This is an off-chain operation and is not provable.</em>

0 commit comments

Comments
 (0)