1
1
import React , { useEffect , useMemo , useState } from "react" ;
2
2
import { IScrapEntry , ScrapType } from "../../../serverApi/IScrapEntry" ;
3
3
import { useAppContext } from "../../../AppContext" ;
4
- import { Button } from "@mui/material" ;
4
+ import { Button , Typography } from "@mui/material" ;
5
5
import { IUpsertScrapsEntryCommand } from "../../../serverApi/commands/IUpsertScrapsEntryCommand" ;
6
6
import { useUpsertEntryMutation } from "../../../serverApi/reactQuery/mutations/useUpsertEntryMutation" ;
7
7
import { JournalType } from "../../../serverApi/JournalType" ;
@@ -18,6 +18,7 @@ import { useDialogContext } from "../../layout/dialogs/DialogContext";
18
18
import { IJournal } from "../../../serverApi/IJournal" ;
19
19
import { AddNewScrapStorage } from "./AddNewScrapStorage" ;
20
20
import { IScrapListItem } from "./list/IScrapListItem" ;
21
+ import { DialogFormButtonContainer } from "../../common/FormButtonContainer" ;
21
22
22
23
export const ScrapContextProvider : React . FC < {
23
24
children : React . ReactNode ;
@@ -161,59 +162,45 @@ export const ScrapContextProvider: React.FC<{
161
162
genericNotes : string [ ] ,
162
163
targetType : ScrapType ,
163
164
) {
164
- setAppAlert ( {
165
- message : (
166
- < >
167
- < div >
168
- Would you like to change the type? Certain formatting might be lost.
169
- </ div >
170
- < div style = { { margin : "8px 0" } } >
171
- < Button
172
- sx = { {
173
- color : "common.white" ,
174
- border : "1px solid white;" ,
175
- marginRight : "10px" ,
176
- } }
177
- variant = { "outlined" }
178
- onClick = { ( ) => {
179
- const newNotes = convertNotesToTargetType (
180
- targetType ,
181
- genericNotes ,
182
- ) ;
165
+ renderDialog ( {
166
+ title : "Are you sure?" ,
167
+ render : ( closeDialog ) => {
168
+ return (
169
+ < >
170
+ < Typography >
171
+ Do you really want to change the type to { targetType } ? Certain
172
+ formatting might be lost.
173
+ </ Typography >
183
174
184
- setNotes ( newNotes ) ;
175
+ < DialogFormButtonContainer >
176
+ < Button variant = { "contained" } onClick = { closeDialog } >
177
+ No
178
+ </ Button >
179
+ < Button
180
+ variant = { "outlined" }
181
+ onClick = { ( ) => {
182
+ const newNotes = convertNotesToTargetType (
183
+ targetType ,
184
+ genericNotes ,
185
+ ) ;
185
186
186
- setScrapToRender ( {
187
- ...scrapToRender ,
188
- notes : newNotes ,
189
- scrapType : targetType ,
190
- } ) ;
187
+ setNotes ( newNotes ) ;
191
188
192
- setAppAlert ( null ) ;
193
- } }
194
- >
195
- YES
196
- </ Button >
189
+ setScrapToRender ( {
190
+ ... scrapToRender ,
191
+ notes : newNotes ,
192
+ scrapType : targetType ,
193
+ } ) ;
197
194
198
- < Button
199
- sx = { {
200
- color : "common.white" ,
201
- border : "1px solid white;" ,
202
- paddingRight : "10px" ,
203
- } }
204
- variant = { "outlined" }
205
- onClick = { ( ) => {
206
- setAppAlert ( null ) ;
207
- } }
208
- >
209
- NO
210
- </ Button >
211
- </ div >
212
- </ >
213
- ) ,
214
- type : "info" ,
215
- hideDurationSec : 2 ,
216
- title : "Change scrap type to " + targetType ,
195
+ closeDialog ( ) ;
196
+ } }
197
+ >
198
+ Yes, convert to { targetType . toLowerCase ( ) }
199
+ </ Button >
200
+ </ DialogFormButtonContainer >
201
+ </ >
202
+ ) ;
203
+ } ,
217
204
} ) ;
218
205
}
219
206
0 commit comments