diff --git a/api/next.php b/api/next.php new file mode 100644 index 0000000..bb159db --- /dev/null +++ b/api/next.php @@ -0,0 +1,43 @@ + 'no_list']); + exit; +} + +$words = sortDueWords($data['words']); + +$today = date('Y-m-d'); + +$due = array_filter($words, function ($w) use ($today) { + return !isset($w['nextReview']) || $w['nextReview'] <= $today; +}); + +if (count($due) === 0) { + $due = $words; +} + +$word = array_values($due)[0]; + +echo json_encode([ + 'word' => $word +]); \ No newline at end of file