Compare commits
46
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
810de0cb24 | ||
|
|
e68f7407f3 | ||
|
|
ad436f786c | ||
|
|
a2649fddeb | ||
|
|
f69f76a05a | ||
|
|
1a75dec59a | ||
|
|
663ceaca16 | ||
|
|
22d2484cab | ||
|
|
1af7415add | ||
|
|
71177f749c | ||
|
|
bbfa5b28c3 | ||
|
|
ba11eda64c | ||
|
|
174ec31351 | ||
|
|
27ecdf386e | ||
|
|
5e633b959d | ||
|
|
a4df094191 | ||
|
|
15c88fc6be | ||
|
|
ddca7acbd4 | ||
|
|
fd655952b6 | ||
|
|
b672b1cefa | ||
|
|
f2953dd18f | ||
|
|
0c4274d87b | ||
|
|
4a2a84b36f | ||
|
|
3944c6a4b0 | ||
|
|
a352e359c4 | ||
|
|
d9ca806d50 | ||
|
|
f037522052 | ||
|
|
e476117c77 | ||
|
|
d758f5bf12 | ||
|
|
8b2c4310ba | ||
|
|
1c24b9a23f | ||
|
|
86758cf848 | ||
|
|
39d75eddbd | ||
|
|
f4ee40f45d | ||
|
|
422078545e | ||
|
|
2a7cb467cf | ||
|
|
c20ab45c9d | ||
|
|
cf625abff2 | ||
|
|
85977cb7af | ||
|
|
2032837aad | ||
|
|
a097cf4311 | ||
|
|
bf7fb937d2 | ||
|
|
a8ce5490c8 | ||
|
|
b0b0347b04 | ||
|
|
a75712a60a | ||
|
|
e08b6121a2 |
@@ -1104,13 +1104,3 @@ span.tarot-fan-card { cursor: default; }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.tarot-flip-inner, .tarot-fan-card, .tarot-demo-text { transition: none; animation: none; }
|
||||
}
|
||||
|
||||
/* Birth date and time: our own Hungarian fields (not the browser's date and time inputs) */
|
||||
.birth-fields { border: 0; margin: 0; padding: 0; min-width: 0; }
|
||||
.birth-fields legend { padding: 0; margin-bottom: 8px; }
|
||||
.birth-row { display: flex; align-items: center; gap: 8px; }
|
||||
.birth-year { width: 5.5em; flex: none; }
|
||||
.birth-month { flex: 1 1 auto; min-width: 0; }
|
||||
.birth-day { width: 5.2em; flex: none; }
|
||||
.birth-time { width: 4.4em; flex: none; text-align: center; }
|
||||
.birth-colon { color: var(--muted); font-weight: 600; }
|
||||
|
||||
@@ -16,41 +16,6 @@ const ERRORS: Record<string, string> = {
|
||||
invalid_date: "Érvénytelen dátum.",
|
||||
};
|
||||
|
||||
const MONTHS = [
|
||||
"január",
|
||||
"február",
|
||||
"március",
|
||||
"április",
|
||||
"május",
|
||||
"június",
|
||||
"július",
|
||||
"augusztus",
|
||||
"szeptember",
|
||||
"október",
|
||||
"november",
|
||||
"december",
|
||||
];
|
||||
|
||||
const pad = (n: number) => String(n).padStart(2, "0");
|
||||
const daysIn = (year: number, month: number) => new Date(Date.UTC(year || 2000, month, 0)).getUTCDate();
|
||||
|
||||
/** "YYYY-MM-DD" from the three fields, or null while it is not a real date. */
|
||||
function composeDate(year: string, month: string, day: string): string | null {
|
||||
const y = Number(year);
|
||||
const m = Number(month);
|
||||
const d = Number(day);
|
||||
if (!/^\d{4}$/.test(year) || y < 1000 || !m || !d || d > daysIn(y, m)) return null;
|
||||
return `${year}-${pad(m)}-${pad(d)}`;
|
||||
}
|
||||
|
||||
/** "HH:MM" from the two fields, or null while it is not a real time. */
|
||||
function composeTime(hour: string, minute: string): string | null {
|
||||
if (!/^\d{1,2}$/.test(hour) || !/^\d{1,2}$/.test(minute)) return null;
|
||||
const h = Number(hour);
|
||||
const m = Number(minute);
|
||||
return h <= 23 && m <= 59 ? `${pad(h)}:${pad(m)}` : null;
|
||||
}
|
||||
|
||||
/** Someone else's chart: added with a name, or (with `chartId`) corrected. */
|
||||
export type PersonTarget = { chartId?: string; name?: string };
|
||||
|
||||
@@ -67,16 +32,8 @@ export function BirthForm({
|
||||
onSaved: (chartId: string) => void;
|
||||
}) {
|
||||
const [name, setName] = useState(person?.name ?? "");
|
||||
// Our own fields, not the browser's date and time inputs: those follow the
|
||||
// operating system's or the browser's region (US order, AM/PM in Safari).
|
||||
const [year, setYear] = useState(initial?.date?.slice(0, 4) ?? "");
|
||||
const [month, setMonth] = useState(initial?.date ? String(Number(initial.date.slice(5, 7))) : "");
|
||||
const [day, setDay] = useState(initial?.date ? String(Number(initial.date.slice(8, 10))) : "");
|
||||
const [hour, setHour] = useState(initial?.time?.slice(0, 2) ?? "");
|
||||
const [minute, setMinute] = useState(initial?.time?.slice(3, 5) ?? "");
|
||||
const minuteRef = useRef<HTMLInputElement>(null);
|
||||
const date = composeDate(year, month, day) ?? "";
|
||||
const time = composeTime(hour, minute) ?? "";
|
||||
const [date, setDate] = useState(initial?.date ?? "");
|
||||
const [time, setTime] = useState(initial?.time?.slice(0, 5) ?? "");
|
||||
const [timeUnknown, setTimeUnknown] = useState(initial ? !initial.time : false);
|
||||
const [country, setCountry] = useState(initial?.country ?? "HU");
|
||||
const [place, setPlace] = useState<Place | null>(
|
||||
@@ -100,11 +57,8 @@ export function BirthForm({
|
||||
e.preventDefault();
|
||||
setError(null);
|
||||
if (person && !name.trim()) return setError("Add meg a nevét.");
|
||||
if (!year && !month && !day) return setError("Add meg a születési dátumot.");
|
||||
if (!date) return setError("Ellenőrizd a dátumot: az év négy számjegy, és a nap legyen az adott hónapban.");
|
||||
if (date > today) return setError("A születési dátum nem lehet a jövőben.");
|
||||
if (!timeUnknown && !hour && !minute) return setError("Add meg a születési időt, vagy jelöld, hogy nem tudod.");
|
||||
if (!timeUnknown && !time) return setError("Ellenőrizd az időt: óra 0–23, perc 0–59.");
|
||||
if (!date) return setError("Add meg a születési dátumot.");
|
||||
if (!timeUnknown && !time) return setError("Add meg a születési időt, vagy jelöld, hogy nem tudod.");
|
||||
if (!place) return setError("Válaszd ki a születési helyet a listából.");
|
||||
setBusy(true);
|
||||
try {
|
||||
@@ -166,106 +120,37 @@ export function BirthForm({
|
||||
</div>
|
||||
)}
|
||||
<div className="grid-2">
|
||||
<fieldset className="field birth-fields">
|
||||
<legend className="label">Születési dátum</legend>
|
||||
<div className="birth-row">
|
||||
<label className="sr-only" htmlFor="birth-year">
|
||||
Év
|
||||
</label>
|
||||
<input
|
||||
id="birth-year"
|
||||
className="inp birth-year"
|
||||
inputMode="numeric"
|
||||
autoComplete="bday-year"
|
||||
placeholder="év"
|
||||
maxLength={4}
|
||||
value={year}
|
||||
onChange={(e) => setYear(e.target.value.replace(/\D/g, ""))}
|
||||
/>
|
||||
<label className="sr-only" htmlFor="birth-month">
|
||||
Hónap
|
||||
</label>
|
||||
<select
|
||||
id="birth-month"
|
||||
className="inp birth-month"
|
||||
autoComplete="bday-month"
|
||||
value={month}
|
||||
onChange={(e) => setMonth(e.target.value)}
|
||||
>
|
||||
<option value="">hónap</option>
|
||||
{MONTHS.map((m, i) => (
|
||||
<option key={m} value={i + 1}>
|
||||
{m}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<label className="sr-only" htmlFor="birth-day">
|
||||
Nap
|
||||
</label>
|
||||
<select
|
||||
id="birth-day"
|
||||
className="inp birth-day"
|
||||
autoComplete="bday-day"
|
||||
value={day}
|
||||
onChange={(e) => setDay(e.target.value)}
|
||||
>
|
||||
<option value="">nap</option>
|
||||
{Array.from({ length: month ? daysIn(Number(year), Number(month)) : 31 }, (_, i) => (
|
||||
<option key={i + 1} value={i + 1}>
|
||||
{i + 1}.
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset className="field birth-fields">
|
||||
<legend className="label">Születési idő (helyi idő)</legend>
|
||||
<div className="birth-row">
|
||||
<label className="sr-only" htmlFor="birth-hour">
|
||||
Óra
|
||||
</label>
|
||||
<input
|
||||
id="birth-hour"
|
||||
className="inp birth-time"
|
||||
inputMode="numeric"
|
||||
placeholder="óra"
|
||||
maxLength={2}
|
||||
value={timeUnknown ? "" : hour}
|
||||
disabled={timeUnknown}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value.replace(/\D/g, "");
|
||||
setHour(v);
|
||||
setAmbiguous(false);
|
||||
// Two digits (or one that cannot start a valid hour): on to the minutes.
|
||||
if (v.length === 2 || (v.length === 1 && Number(v) > 2)) minuteRef.current?.focus();
|
||||
}}
|
||||
/>
|
||||
<span className="birth-colon" aria-hidden="true">
|
||||
:
|
||||
</span>
|
||||
<label className="sr-only" htmlFor="birth-minute">
|
||||
Perc
|
||||
</label>
|
||||
<input
|
||||
id="birth-minute"
|
||||
ref={minuteRef}
|
||||
className="inp birth-time"
|
||||
inputMode="numeric"
|
||||
placeholder="perc"
|
||||
maxLength={2}
|
||||
value={timeUnknown ? "" : minute}
|
||||
disabled={timeUnknown}
|
||||
onChange={(e) => {
|
||||
setMinute(e.target.value.replace(/\D/g, ""));
|
||||
setAmbiguous(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label htmlFor="birth-date">Születési dátum</label>
|
||||
<input
|
||||
id="birth-date"
|
||||
type="date"
|
||||
className="inp"
|
||||
min="1000-01-01"
|
||||
max={today}
|
||||
value={date}
|
||||
onChange={(e) => setDate(e.target.value)}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="field">
|
||||
<label htmlFor="birth-time">Születési idő (helyi idő)</label>
|
||||
<input
|
||||
id="birth-time"
|
||||
type="time"
|
||||
className="inp"
|
||||
value={timeUnknown ? "" : time}
|
||||
disabled={timeUnknown}
|
||||
onChange={(e) => {
|
||||
setTime(e.target.value);
|
||||
setAmbiguous(false);
|
||||
}}
|
||||
/>
|
||||
<label className="check">
|
||||
<input type="checkbox" checked={timeUnknown} onChange={(e) => setTimeUnknown(e.target.checked)} />
|
||||
Nem tudom a születési időt
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid-2">
|
||||
|
||||
Reference in New Issue
Block a user