@@ -26,18 +26,7 @@ class PaperModal extends Component
2626
2727 public $ currentProject ;
2828 public $ projectId ;
29- public $ paper = [
30- 'id_paper ' => null ,
31- 'title ' => '' ,
32- 'author ' => '' ,
33- 'year ' => '' ,
34- 'doi ' => '' ,
35- 'url ' => '' ,
36- 'data_base ' => null ,
37- 'database_name ' => '' ,
38- 'status_selection ' => null ,
39- 'status_description ' => 'None ' ,
40- ];
29+ public $ paper = null ;
4130 public $ canEdit = false ;
4231
4332 public $ criterias ;
@@ -52,7 +41,6 @@ public function mount()
5241 {
5342 $ this ->projectId = request ()->segment (2 );
5443 $ this ->currentProject = Project::findOrFail ($ this ->projectId );
55-
5644 }
5745 #[On('showPaper ' )]
5846 public function showPaper ($ paper , $ criterias )
@@ -70,22 +58,13 @@ public function showPaper($paper, $criterias)
7058 ->values ()
7159 ->toArray ();
7260
73- // Se showPaper for chamado com o ID do paper, carrega o objeto e converte para array
74- // Se o paper for passado como um array de dados, usa o id_paper
75- $ paperId = is_array ($ paper ) ? $ paper ['id_paper ' ] : $ paper ;
76-
77- if (!$ paperId ) {
78- Log::error ('showPaper called without a valid paper ID or data. ' );
79- return ;
80- }
81-
82- $ this ->paper = Papers::where ('id_paper ' , $ paperId )->first ()->toArray ();
61+ $ this ->paper = $ paper ;
8362
8463 $ databaseName = DB ::table ('data_base ' )
8564 ->where ('id_database ' , $ this ->paper ['data_base ' ])
8665 ->value ('name ' );
8766
88- $ this ->paper ['database_name ' ] = $ databaseName ?? ' Unknown ' ;
67+ $ this ->paper ['database_name ' ] = $ databaseName ;
8968
9069 // Buscar o membro específico para o projeto atual
9170 $ member = Member::where ('id_user ' , auth ()->user ()->id )
@@ -101,7 +80,7 @@ public function showPaper($paper, $criterias)
10180 $ this ->temp_selected_criterias = $ this ->selected_criterias ;
10281
10382 //status selecionado com base no status salvo no banco de dados
104- $ this ->selected_status = $ this ->getPaperStatusDescription ( $ this -> paper ['status_selection ' ]) ;
83+ $ this ->selected_status = $ this ->paper ['status_description ' ] ;
10584
10685 // Carregar a nota existente
10786 $ paperSelection = PapersSelection::where ('id_paper ' , $ this ->paper ['id_paper ' ])
@@ -221,15 +200,24 @@ public function saveSelectedCriterias()
221200 $ this ->selected_criterias = $ this ->temp_selected_criterias ;
222201
223202 // Atualizar o status do paper
224- $ criterias = Criteria::whereIn ('id_criteria ' , $ this ->selected_criterias )->get ();
225- foreach ($ criterias as $ criteria ) {
203+
204+ $ criteria = Criteria::find (reset ($ addedCriterias ));
205+ if ($ criteria ) {
226206 $ this ->updatePaperStatus ($ criteria ->type );
227207 }
208+ /*
209+ $criteria = null;
210+ if (!empty($addedCriterias)) {
211+ $criteria = Criteria::find(reset($addedCriterias));
212+ }
213+
214+ if ($criteria) {
215+ $this->updatePaperStatus($criteria->type);
216+ }*/
228217
229218 session ()->flash ('successMessage ' , 'Critérios salvos com sucesso ' );
230219 $ this ->dispatch ('show-success ' );
231220 $ this ->dispatch ('refreshPaperStatus ' );
232-
233221 }
234222
235223 // Método auxiliar para obter a descrição do status
@@ -296,12 +284,6 @@ private function updatePaperStatus($type)
296284 if ($ member ->level == 1 ) {
297285 Papers::where ('id_paper ' , $ id_paper )->update (['status_selection ' => $ new_status ]);
298286 }
299- // 🔥 Recarrega o paper atualizado
300- $ this ->paper = Papers::where ('id_paper ' , $ id_paper )->first ()->toArray ();
301- $ this ->paper ['database_name ' ] = DB ::table ('data_base ' )
302- ->where ('id_database ' , $ this ->paper ['data_base ' ])
303- ->value ('name ' ) ?? '' ;
304-
305287 session ()->forget ('successMessage ' );
306288 session ()->flash ('successMessage ' , "Status updated successfully. " );
307289 }
0 commit comments