Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
ivrnet_payment
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Muhammad
ivrnet_payment
Commits
a4348b96
Commit
a4348b96
authored
Nov 20, 2023
by
Bilal
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated snackbar handling
parent
0e44734a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
28 deletions
+22
-28
src/component/Telepay.js
src/component/Telepay.js
+22
-28
No files found.
src/component/Telepay.js
View file @
a4348b96
...
@@ -21,7 +21,7 @@ const TelepayForm = () => {
...
@@ -21,7 +21,7 @@ const TelepayForm = () => {
{
description
:
''
,
amount
:
''
},
{
description
:
''
,
amount
:
''
},
],
],
});
});
const
[
snackbarOpen
,
set
SnackbarOpen
]
=
React
.
useState
(
false
);
const
[
errorSnackbarOpen
,
setError
SnackbarOpen
]
=
React
.
useState
(
false
);
const
[
submitted
,
setSubmitted
]
=
React
.
useState
(
false
);
const
[
submitted
,
setSubmitted
]
=
React
.
useState
(
false
);
const
handleChange
=
(
field
,
value
)
=>
{
const
handleChange
=
(
field
,
value
)
=>
{
...
@@ -69,11 +69,11 @@ const TelepayForm = () => {
...
@@ -69,11 +69,11 @@ const TelepayForm = () => {
}
else
{
}
else
{
const
errorData
=
await
response
.
json
();
const
errorData
=
await
response
.
json
();
setError
(
errorData
.
error
||
'
An error occurred
'
);
setError
(
errorData
.
error
||
'
An error occurred
'
);
setSnackbarOpen
(
true
);
set
Error
SnackbarOpen
(
true
);
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
setError
(
'
An error occurred while making the API request
'
);
setError
(
'
An error occurred while making the API request
'
);
setSnackbarOpen
(
true
);
set
Error
SnackbarOpen
(
true
);
}
finally
{
}
finally
{
setSubmitted
(
false
);
setSubmitted
(
false
);
}
}
...
@@ -88,37 +88,31 @@ const TelepayForm = () => {
...
@@ -88,37 +88,31 @@ const TelepayForm = () => {
});
});
};
};
const
handleClose
=
(
event
,
reason
)
=>
{
return
(
if
(
reason
===
'
clickaway
'
)
{
<
div
>
return
;
<
Snackbar
open
=
{
errorSnackbarOpen
}
autoHideDuration
=
{
3000
}
onClose
=
{(
event
,
reason
)
=>
{
if
(
reason
!==
'
clickaway
'
)
{
setErrorSnackbarOpen
(
false
);
}
}
}}
setSnackbarOpen
(
false
);
message
=
{
error
}
};
action
=
{
const
action
=
(
<
React
.
Fragment
>
<
React
.
Fragment
>
<
IconButton
<
IconButton
size
=
'
small
'
size
=
'
small
'
aria
-
label
=
'
close
'
aria
-
label
=
'
close
'
color
=
'
inherit
'
color
=
'
inherit
'
onClick
=
{
handleClose
}
onClick
=
{()
=>
setErrorSnackbarOpen
(
false
)
}
>
>
<
CloseOutlined
fontSize
=
'
small
'
/>
<
CloseOutlined
fontSize
=
'
small
'
/>
<
/IconButton
>
<
/IconButton
>
<
/React.Fragment
>
<
/React.Fragment
>
);
}
return
(
<
div
>
<
Snackbar
open
=
{
snackbarOpen
}
autoHideDuration
=
{
3000
}
onClose
=
{
handleClose
}
message
=
{
error
}
action
=
{
action
}
>
>
<
Alert
onClose
=
{
handleClose
}
severity
=
'
error
'
sx
=
{{
width
:
'
100%
'
}}
>
<
Alert
onClose
=
{
()
=>
setErrorSnackbarOpen
(
false
)
}
severity
=
'
error
'
sx
=
{{
width
:
'
100%
'
}}
>
{
error
}
{
error
}
<
/Alert
>
<
/Alert
>
<
/Snackbar
>
<
/Snackbar
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment