Skip to content

Commit 153ecff

Browse files
committed
feats
1 parent 0d15de5 commit 153ecff

File tree

2 files changed

+28
-9
lines changed

2 files changed

+28
-9
lines changed

frontend/src/pages/AdminConditionPage/AdminConditionPage.tsx

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export const AdminConditionPage = () => {
4040
const isSaved = useIsSaved()
4141
const condition = useCondition()
4242

43-
const [isDialogOpen, setIsDialogOpen] = useState(false)
43+
const [isDialogDeleteOpen, setIsDialogDeleteOpen] = useState(false)
44+
const [isDialogSaveOpen, setIsDialogSaveOpen] = useState(false)
4445

4546
const { isLoading: conditionIsLoading } = useAdminConditionQuery({
4647
conditionId,
@@ -90,7 +91,7 @@ export const AdminConditionPage = () => {
9091
if (!condition) return
9192

9293
if (!isSaved) {
93-
console.log('modal: not saved')
94+
setIsDialogSaveOpen(true)
9495
return
9596
}
9697

@@ -102,7 +103,7 @@ export const AdminConditionPage = () => {
102103
return
103104
}
104105
hapticFeedback('soft')
105-
setIsDialogOpen(true)
106+
setIsDialogDeleteOpen(true)
106107
}
107108

108109
const handleDeleteCondition = async () => {
@@ -115,16 +116,25 @@ export const AdminConditionPage = () => {
115116
chatSlug,
116117
type: condition.type,
117118
})
118-
setIsDialogOpen(false)
119+
setIsDialogDeleteOpen(false)
119120
navigate(`/admin/chat/${chatSlug}`)
120121
}
121122

122-
const handleCloseDialog = () => {
123+
const handleCloseDialogDelete = () => {
123124
if (!condition || deleteConditionIsPending) {
124125
return
125126
}
126127
hapticFeedback('soft')
127-
setIsDialogOpen(false)
128+
setIsDialogDeleteOpen(false)
129+
}
130+
131+
const handleCloseDialogSave = () => {
132+
if (!condition || updateConditionIsPending) {
133+
return
134+
}
135+
hapticFeedback('soft')
136+
setIsDialogSaveOpen(false)
137+
navigate(`/admin/chat/${chatSlug}`)
128138
}
129139

130140
return (
@@ -154,14 +164,23 @@ export const AdminConditionPage = () => {
154164
/>
155165
</BlockNew>
156166
<DialogModal
157-
active={isDialogOpen}
167+
active={isDialogDeleteOpen}
158168
title="Remove Condition?"
159169
description="Removing this condition will delete all created dependencies. Are you sure you want to remove?"
160170
confirmText="Remove"
161171
closeText="Cancel"
162-
onClose={handleCloseDialog}
172+
onClose={handleCloseDialogDelete}
163173
onDelete={handleDeleteCondition}
164174
/>
175+
<DialogModal
176+
active={isDialogSaveOpen}
177+
title="Condition is not saved"
178+
description="Are you sure you want to leave the page? Your changes will not be saved."
179+
confirmText="Save"
180+
closeText="Leave"
181+
onClose={handleCloseDialogSave}
182+
onConfirm={handleUpdateCondition}
183+
/>
165184
</PageLayoutNew>
166185
)
167186
}

frontend/src/store-new/condition/transformers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const transformCondition = (condition: Condition): ConditionMutated => {
66
expected: condition?.expected || 0,
77
category: condition?.category || null,
88
groupId: condition?.groupId || null,
9-
isEnabled: condition?.isEnabled || true,
9+
isEnabled: !!condition?.isEnabled,
1010
address: condition?.blockchainAddress || null,
1111
asset: condition?.asset || null,
1212
emojiId: condition?.emojiId || null,

0 commit comments

Comments
 (0)