kromitgmbh / titra

titra - modern open source project time tracking for freelancers and small teams
https://titra.io
GNU Affero General Public License v3.0
406 stars 55 forks source link

tiny-date-picker on en locale #202

Closed thomcuddihy closed 10 months ago

thomcuddihy commented 10 months ago

Clicking on the calendar icon the tracktime page generates the following error:

titra_app  | [ERROR: TypeError: e.tinydatepicker is undefined @ Wed Jan 31 2024 05:11:49 GMT+0000 (Coordinated Universal Time)] {
titra_app  |   "file": "https://titra.fordelab.com/f9c72afee02bda1964480facf57fac56ad834807.js?meteor_js_resource=true line 70 > eval",
titra_app  |   "onLine": 1,
titra_app  |   "browserInfo": {
titra_app  |     "browser": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0",
titra_app  |     "userId": "4Lfnrauq3z4FFoTDT",
titra_app  |     "url": "https://titra.nope.com/tracktime",
titra_app  |     "resolution": "2560x1440"
titra_app  |   }
titra_app  | }

Looks like tinydatepicker is defined when the weekDaysMin and months are not empty: https://github.com/kromitgmbh/titra/blob/3757150a287eb45702d81ced76ebb538f49f4a00/imports/ui/pages/track/tracktime.js#L47

And those are set here based on locale: https://github.com/kromitgmbh/titra/blob/3757150a287eb45702d81ced76ebb538f49f4a00/imports/utils/i18n.js#L51

Problem is, the dayjs en locale doesn't include weekDaysMin for some reason: https://github.com/iamkun/dayjs/blob/bdcc336613c9fa466b385574e88d0b43629475bc/src/locale/en.js#L2

Have tested this by switching user language setting to non-English languages and it works fine.

A suggested fix would be switch the failover locale in the try/catch from en to something like `en-gb' here: https://github.com/kromitgmbh/titra/blob/3757150a287eb45702d81ced76ebb538f49f4a00/imports/utils/i18n.js#L67

Since the more specific en locales in dayjs do have weekDaysMin:

https://github.com/iamkun/dayjs/blob/bdcc336613c9fa466b385574e88d0b43629475bc/src/locale/en-gb.js#L8

Assuming it's tripping here: https://github.com/kromitgmbh/titra/blob/3757150a287eb45702d81ced76ebb538f49f4a00/imports/utils/i18n.js#L52

(I'm down my dev computer, and can't test or make a pull request, sorry)

faburem commented 10 months ago

should be fixed in titra version 0.96.3! Thank you very much for the very detailed bug report and suggested solution - that is greatly appreciated. If you encounter further issue feel free to reopen this issue!