11import React , { useRef , useState } from 'react' ;
22import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
33import { faCopy } from '@fortawesome/free-solid-svg-icons' ;
4- import Swal from 'sweetalert2/dist/sweetalert2.js ';
5- import 'sweetalert2/src/sweetalert2.scss ';
4+ import 'toastr/build/toastr.min.css ';
5+ import toastr from 'toastr ';
66import axios from 'axios' ;
77
88const Hero = ( ) => {
@@ -21,27 +21,14 @@ const Hero = () => {
2121 if ( response . data ) {
2222 const newShortUrl = response . data [ "short-link" ] ;
2323 setShortUrl ( newShortUrl ) ;
24- Swal . fire ( {
25- position : 'top-end' ,
26- icon : 'success' ,
27- title : 'URL shortened successfully!' ,
28- showConfirmButton : false ,
29- timer : 1500 ,
30- } ) ;
24+ toastr . success ( "URL shortened successfully!" ) ;
3125 }
3226 } catch ( error ) {
3327 let errorMessage = 'Failed to shorten URL!' ;
3428 if ( error . response && error . response . data ) {
3529 errorMessage = error . response . data . message || errorMessage ;
3630 }
37-
38- Swal . fire ( {
39- position : 'top-end' ,
40- icon : 'error' ,
41- title : errorMessage ,
42- showConfirmButton : false ,
43- timer : 1500 ,
44- } ) ;
31+ toastr . error ( errorMessage ) ;
4532 }
4633 } ;
4734
@@ -52,21 +39,9 @@ const Hero = () => {
5239
5340 try {
5441 document . execCommand ( 'copy' ) ;
55- Swal . fire ( {
56- position : 'top-end' ,
57- icon : 'success' ,
58- title : 'URL copied to clipboard!' ,
59- showConfirmButton : false ,
60- timer : 1500 ,
61- } ) ;
42+ toastr . success ( "URL copied to clipboard!" ) ;
6243 } catch ( err ) {
63- Swal . fire ( {
64- position : 'top-end' ,
65- icon : 'error' ,
66- title : 'Failed to copy URL!' ,
67- showConfirmButton : false ,
68- timer : 1500 ,
69- } ) ;
44+ toastr . error ( "Failed to copy URL!" ) ;
7045 }
7146 }
7247 } ;
@@ -85,7 +60,7 @@ const Hero = () => {
8560 < button type = "button" onClick = { GetShort } className = "flex-none rounded-md bg-primary px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm bc-primary hover:bg-cyan-800 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-500" > Shorten</ button >
8661 </ div >
8762 < div className = "relative w-full max-w-sm mt-3" >
88- < input ref = { inputRef } readOnly id = "ShortedUrl" type = "text" value = { shortUrl } className = "w-full pr-12 rounded-md border-0 bg-white/5 px-3.5 py-2 text-white shadow-sm ring-1 ring-inset ring-white/10 focus:ring-2 focus:ring-inset focus:ring-indigo-500 sm:text-sm sm:leading-6" placeholder = "shortened link placed here" />
63+ < input disabled ref = { inputRef } readOnly id = "ShortedUrl" type = "text" value = { shortUrl } className = "w-full pr-12 rounded-md border-0 bg-white/5 px-3.5 py-2 text-white shadow-sm ring-1 ring-inset ring-white/10 focus:ring-2 focus:ring-inset focus:ring-indigo-500 sm:text-sm sm:leading-6" placeholder = "shortened link placed here" />
8964 < button onClick = { copyToClipboard } className = "absolute inset-y-0 right-0 px-3 flex items-center text-white hover:text-indigo-500" >
9065 < FontAwesomeIcon className = "tc-primary text-xl" icon = { faCopy } />
9166 </ button >
0 commit comments