Hi. It’s been some time since my last post. I read book about Phoenix and I am in the middle of LiveView book (cause I stuck in middle, now everything is more clarified for me). I still have some questions about creating SPA with LiveView, how to combine it with plan Phoenix. I was shocked in the beginning that LV doesnt have controllers and because of that I am confused a little.
To the point.
I try to create pretty simple app - Budget Tracker, but a little more complex than simple adding transactions and list them on screen. I have created authentication using phx.gen.auth, created simple site, controllers, navbar etc. App dashboard is restricted only for authenticated users. This is place where problems started to appear. I have this main page with its navbar (budgets, transactions, goals, charts etc.) and under nav I put dashboard where everything should change. Its static page, not live. All CRUD actions are possible only for auth user, every transactions will have their owner and all created things are visible only for creator.
When I click on “Budgets” on navbar I want only to put list (name and icon, edit/delete buttons i want to have hidden in modal) of my created Budgets on dashboard (red place on screen) - not redirecting it to budget.html.heex where I need to write from beginning whole Dashboard’s html. It looks like <%= @inner_content %> comes to play, but Its hard to find some solutions about that and how it can work with liveview.
What comes to my mind is actually rewrite this dashboard for redirecting - but in place where i want to place my transaction/budget list using liveview. Clicking budgets redirects to same looking budget.html.heex with dashboard with implemented logic for list whole budgets (then after clicking some from list open list of specific transactions written under this budget).
I’ve read also that without some “cheats” liveview won’t know that user is logged in and app will behave like for not logged user. But for this I found some solutions which I will try when I accomplished problem above.