Skip to main content

Due Date: Using Shadcn Vue Date Picker

Premium
6 min read

Now, let's try to add one more field to our form and database: due_date with a date picker.


Prepare Database/Controller

I will just show you the code without any comments. These are Laravel fundamentals, I'm sure you know them.

Migration:

php artisan make:migration add_due_date_to_tasks_table
Schema::table('tasks', function (Blueprint $table) {
$table->date('due_date')->nullable();
});

Then, we run:

php artisan migrate

Adding to...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 09 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

K
Kaspars ✓ Link copied!

in Create.vue:

const submitForm = () => { form.transform((data) => ({ ...data, due_date: data.due_date ? data.due_date.toDate(getLocalTimeZone()) : null, ... toDate is red underlined. Property 'toDate' does not exist on type 'never'.ts-plugin(2339)

M
Modestas ✓ Link copied!

I am not sure on how to best fix this issue at this time. Will play around with more time at hand as this one might require more changes, sorry.

ps. Warnings like this are annoying, but at this point - it doesn't impact the functionality.

K
Kaspars ✓ Link copied!

Yes, doesn't impact on funcionality. Typescript sometimes is too strict, maybe

K
Kaspars ✓ Link copied!

in Edit.vue:

due_date: task.due_date ? fromDate(new Date(task.due_date)) : null,

'due_date' is red underlined Type 'ZonedDateTime | null' is not assignable to type 'FormDataConvertible'. Type 'ZonedDateTime' is not assignable to type 'FormDataConvertible'. Type 'ZonedDateTime' is not assignable to type '{ [key: string]: FormDataConvertible; }'. Index signature for type 'string' is missing in type 'ZonedDateTime'.ts-plugin(2322)

from Date is red underlined
Expected 2 arguments, but got 1.ts-plugin(2554)

types.d.ts(104, 38): An argument for 'timeZone' was not provided. (alias) fromDate(date: Date, timeZone: string): ZonedDateTime import fromDate Takes a Date object and converts it to the provided time zone.

! Functionally all working, except pagination!
M
Modestas ✓ Link copied!

I'm not sure about the type errors you mentioned, but... Can you expand on the except pagination part?

K
Kaspars ✓ Link copied!

https://github.com/kkcdp/vue-todo-project, My repository, maybe it helps. Pagination part is replaced

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.