From 3396e290f2309b128ac07a2b316cf7506c8002e2 Mon Sep 17 00:00:00 2001 From: Thomas de Roo <2+thomas@noreply.localhost> Date: Mon, 15 Jun 2026 12:15:06 +0200 Subject: [PATCH] Add api/next.php --- api/next.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 api/next.php 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