Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,11 @@
"lookup": {
"open": "تعبئة علاماتي باستخدام رقم الاكتتاب",
"title": "استيراد علامات الامتحان",
"description": "للشهادات السورية العلمية والأدبية لعام 2026. اختر محافظة الامتحان والشهادة والمنهاج كما تظهر في تطبيق الوزارة.",
"description": "للشهادة الثانوية السورية لعام 2026، الفرعين العلمي والأدبي.",
"directorate": "محافظة الامتحان",
"certificate": "الشهادة والمنهاج",
"number": "رقم الاكتتاب",
"choose": "اختر من القائمة",
"privacy": "استخدم رقمك أو رقماً لديك إذن بالاستعلام عنه. يتصل متصفحك بخدمة نتائج الوزارة، وتعالج سوريا المفتوحة الرد المشفّر لتعبئة علاماتك دون الاحتفاظ برقمك أو بيانات هويتك. تتحقق Cloudflare من الطلب لمنع إساءة الاستخدام.",
"hint": "يمكنك دائماً إدخال العلامات يدوياً. محافظة الامتحان مستقلة عن مكان الدراسة الذي تفضّله.",
"submit": "جلب العلامات وتعبئتها",
"cancel": "العودة إلى النموذج",
"retry": "إعادة المحاولة",
Expand Down
4 changes: 1 addition & 3 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -515,13 +515,11 @@
"lookup": {
"open": "Fill marks using my student number",
"title": "Import your exam marks",
"description": "Syrian 2026 scientific and literary certificates. Choose the exam governorate and the exact certificate and curriculum shown in the Ministry app.",
"description": "For Syrian 2026 scientific and literary certificates.",
"directorate": "Exam governorate",
"certificate": "Certificate and curriculum",
"number": "Student number",
"choose": "Choose an option",
"privacy": "Use your own number or one you have permission to check. Your browser contacts the Ministry results service. OpenSyria processes the encrypted response to fill your marks; it does not retain your number or identity details. Cloudflare checks this request for abuse.",
"hint": "Manual entry is always available. Your exam governorate is separate from your preferred study location.",
"submit": "Fetch and fill marks",
"cancel": "Return to the form",
"retry": "Try again",
Expand Down
64 changes: 37 additions & 27 deletions src/app/[locale]/admissions/_components/results-lookup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ import {
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog"
import {
Field,
FieldDescription,
FieldGroup,
FieldLabel,
} from "@/components/ui/field"
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field"
import { Input } from "@/components/ui/input"
import {
type CertificateOption,
Expand All @@ -46,7 +41,8 @@ type Turnstile = {
sitekey: string
action: string
cData: string
size: "compact"
size: "compact" | "flexible"
appearance: "interaction-only"
language: string
callback: (token: string) => void
"expired-callback": () => void
Expand Down Expand Up @@ -183,21 +179,37 @@ export function ResultsLookup({
!window.turnstile
)
return
widget.current = window.turnstile.render(challengeRef.current, {
sitekey: session.siteKey,
action: "admissions_lookup",
cData: session.challenge,
size: "compact",
language: locale,
callback: setToken,
"expired-callback": () => setToken(""),
"error-callback": () => {
setToken("")
setError("challenge")
},
})
const container = challengeRef.current
const turnstile = window.turnstile
const { siteKey, challenge } = session
let size: "compact" | "flexible" | undefined
function render() {
const nextSize = container.clientWidth < 300 ? "compact" : "flexible"
if (size === nextSize) return
size = nextSize
if (widget.current) turnstile.remove(widget.current)
setToken("")
widget.current = turnstile.render(container, {
sitekey: siteKey,
action: "admissions_lookup",
cData: challenge,
size,
appearance: "interaction-only",
language: locale,
callback: setToken,
"expired-callback": () => setToken(""),
"error-callback": () => {
setToken("")
setError("challenge")
},
})
}
render()
const observer = new ResizeObserver(render)
observer.observe(container)
return () => {
if (widget.current) window.turnstile?.remove(widget.current)
observer.disconnect()
if (widget.current) turnstile.remove(widget.current)
widget.current = undefined
}
}, [open, session, ready, locale])
Expand Down Expand Up @@ -373,12 +385,8 @@ export function ResultsLookup({
autoComplete="off"
maxLength={12}
aria-invalid={error === "invalid"}
aria-describedby="exam-privacy"
/>
</Field>
<FieldDescription id="exam-privacy">
{t("privacy")}
</FieldDescription>
{session ? (
<>
<Script
Expand All @@ -387,7 +395,10 @@ export function ResultsLookup({
onReady={() => setReady(true)}
onError={() => setError("challenge")}
/>
<div ref={challengeRef} className="flex justify-center" />
<div
ref={challengeRef}
className="flex w-full min-w-0 justify-center"
/>
</>
) : null}
{error ? (
Expand Down Expand Up @@ -426,7 +437,6 @@ export function ResultsLookup({
</DialogFooter>
</DialogContent>
</Dialog>
<FieldDescription>{t("hint")}</FieldDescription>
{imported ? (
<p role="status" className="text-sm">
{t("success")}
Expand Down