File tree 2 files changed +12
-6
lines changed
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -26,18 +26,25 @@ const CopyOption = ({ currentOption, className }: Props) => {
26
26
27
27
//TODO (thePeras): Add link here
28
28
const optionToString = ( selectedOption : CourseOption [ ] ) => {
29
+ if ( selectedOption . filter ( ( course ) => ! course . picked_class_id ) . length === selectedOption . length ) return "" ;
30
+
29
31
const copyOption = selectedOption . map ( ( element ) => {
30
- if ( ! element . picked_class_id ) return '' ;
31
32
return element . course_id + '#' + element . picked_class_id ;
32
33
} ) . join ( ';' ) ;
33
34
34
35
return Buffer . from ( copyOption ) . toString ( 'base64' )
35
36
}
36
37
37
38
const copyOption = ( ) => {
38
- navigator . clipboard . writeText ( optionToString ( currentOption ) )
39
- setIcon ( true )
40
- toast ( { title : 'Horário copiado' , description : 'Podes colar o horário noutra opção ou enviar a um amigo.' } )
39
+ const scheduleHash = optionToString ( currentOption ) ;
40
+ navigator . clipboard . writeText ( scheduleHash ) ;
41
+ setIcon ( true ) ;
42
+
43
+ if ( scheduleHash === "" ) {
44
+ toast ( { title : 'Horário não copiado' , description : 'Não tens nenhuma aula selecionada para copiar.' } )
45
+ } else {
46
+ toast ( { title : 'Horário copiado' , description : 'Podes colar o horário noutra opção ou enviar a um amigo.' } )
47
+ }
41
48
setTimeout ( ( ) => {
42
49
setIcon ( false )
43
50
} , 1500 )
Original file line number Diff line number Diff line change @@ -35,11 +35,10 @@ const PasteOption = () => {
35
35
const isImporteFromClipboard : boolean = value
36
36
37
37
if ( ! isValidURL ( decoded_url ) ) {
38
-
39
38
const description = isImporteFromClipboard
40
39
? 'O texto do clipboard não é uma opção válida'
41
40
: 'O texto inserido não é uma opção válida'
42
- console . log ( description )
41
+
43
42
toast ( {
44
43
title : 'Erro ao colar opção' ,
45
44
description,
You can’t perform that action at this time.
0 commit comments