N
Nuxtβ€’2y ago
Romi

How can I do this after initialization?

<script setup>

const client = useSupabaseClient()

const { data, error } = await client.from('weeks').select('*').eq('reports', reportId)
if (error) {
console.log('error', error)
}

const reportId = data.reports

</script>
<script setup>

const client = useSupabaseClient()

const { data, error } = await client.from('weeks').select('*').eq('reports', reportId)
if (error) {
console.log('error', error)
}

const reportId = data.reports

</script>
No description
160 Replies
Romi
RomiOPβ€’2y ago
for context: I have a report which has many weeks. So I want to now only show the weeks that belong to the report that is open. /report/id
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
is this a supabase thing? is this a official package from suapabase for nuxt? or what and what is reportId ? because you mayke first that request and then set the reportId?
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
ah yea i trought it was an existing bug which he reported some weeks ago omg xD
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
@πŸ‡¨πŸ‡­ Marko Bolliger <cannap> @Sr. Full Stack Dev yes so I am using supabase nuxt package. no reportId is what I created thinking it would do something xD. I think the code you send should work so I will try that. Thank you πŸ™‚ what should the file be called, is it [[id]].vue as currently I just have the code in index which I need to move as the code I mentioned above is a component
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
yes got it thanks πŸ™‚ Makes a lot more sense now. 1 other question not sure you know, supabase created date comes back with a really long date is their anyway to format that?
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
thanks thats perfect
Romi
RomiOPβ€’2y ago
also the index.vue inside the [id], this slug should be /reports/[id] right? as currently getting error when I turned the [id] into a folder from [id].vue so not sure if I've done it right
No description
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
hmm ok weird im getting
No description
Romi
RomiOPβ€’2y ago
since i updated it

<script setup>

const client = useSupabaseClient()

// get all reports with name of driver
const { data } = useAsyncData('reports', async () => {
const { data, error } = await client
.from('reports')
.select('id, driver (name, contract_hours ), created_at')

if (error) {
console.log(error)
}
return data
})

console.log(data);

</script>

<script setup>

const client = useSupabaseClient()

// get all reports with name of driver
const { data } = useAsyncData('reports', async () => {
const { data, error } = await client
.from('reports')
.select('id, driver (name, contract_hours ), created_at')

if (error) {
console.log(error)
}
return data
})

console.log(data);

</script>
thats my index which is inside of [id]
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
when you on window there is a problem with nuxt server restart edge version of nuxt has included a fix for it
Romi
RomiOPβ€’2y ago
windows ?
Romi
RomiOPβ€’2y ago
you put widow so was not sure xD
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
i am not 10% sure its only on windows
Romi
RomiOPβ€’2y ago
i'm on mac though
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
can you show the payload you send
Romi
RomiOPβ€’2y ago
this?
No description
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
.select('id, driver (name, contract_hours ), created_at') what is name
Romi
RomiOPβ€’2y ago
name is driver.name that fetches from driver table
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
.select('id, driver (name, contract_hours ), created_at') i cannot see where you a name as parameter there is nothing script setup> const client = useSupabaseClient() // get all reports with name of driver const { data } = useAsyncData('reports', async () => { const { data, error } = await client .from('reports') .select('id, driver (name, contract_hours ), created_at') if (error) { console.log(error) } return data }) console.log(data); </script> look where is name variable i cannot see oor contract_hourse did you post the whole code this stuff is missing nvm sry i see '' its a string but still dont understand it supabase is right but they still miss types like trcp as example are you sure the db is in sync
Romi
RomiOPβ€’2y ago
so where I have
.select('id, driver (name, contract_hours ), created_at')
.select('id, driver (name, contract_hours ), created_at')
does driver (name, contract_hours) not get the name and contract_hours from the db? as it was previously\ I think so, how do i check
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
i dont know maybe you can add a debug log from the db so you see each query add i mean enable
Romi
RomiOPβ€’2y ago
so when I remove name & contract hours it works but without that data ofc which is strange as this is how I had it before
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
maybe db is not sync can you make a fullreset on the db? i know this is not the way to go do you use migrations?
Romi
RomiOPβ€’2y ago
nope Restarted still same :9
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
which db are you using mysql postgres mongo? what are you using to call the db i forgot
Romi
RomiOPβ€’2y ago
I'm using supabase, but its postgres
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
i also use supabase with prisma
Romi
RomiOPβ€’2y ago
I'm just using nuxt package with supabase
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
maybe an relation faild i had this today
Romi
RomiOPβ€’2y ago
what does that mean sorry
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
do you have an relation where you try to add something i had this problem today
Romi
RomiOPβ€’2y ago
oh no thats not it
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
an now you made select
Romi
RomiOPβ€’2y ago
well I don't think as
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
are you german?
Romi
RomiOPβ€’2y ago
when I console.log it I see all the data
Romi
RomiOPβ€’2y ago
No description
Romi
RomiOPβ€’2y ago
nope
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
did you restart nuxt? xD
Romi
RomiOPβ€’2y ago
yep tried that lol
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
also macbook or pc? πŸ˜„ no jk
Romi
RomiOPβ€’2y ago
πŸ˜…
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
hmm wtf do you have a repo
Romi
RomiOPβ€’2y ago
its strange as name is there so driver.name should work not but I can upload it
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
do it i will have look but i cannot promise do you use ts? go with trpc when its a single one and you dont have to share the server
Romi
RomiOPβ€’2y ago
not yet as trying to learn vue first xD
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
you get autocompletion in the use case vue is easy πŸ˜„ i mean there are also complex stuff or performance thing you have to aware of but simpler as in other frameworks @Sr. Full Stack Dev made whole windows in vue xD
Romi
RomiOPβ€’2y ago
I'm currently a wordpress dev so all this is quite new for me. I am currently building a site with Storyblok + nuxt and trying to create this application to learn more about apis and creating a web app wow
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
no its not like the real windows he just made the ui
Romi
RomiOPβ€’2y ago
lol
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
but he will not opensource it for now πŸ˜„ i forgot the demo link
Romi
RomiOPβ€’2y ago
GitHub
GitHub - RomiSinghio/Savari-Payroll
Contribute to RomiSinghio/Savari-Payroll development by creating an account on GitHub.
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
where is t erros coming i will not setup a db right now
Romi
RomiOPβ€’2y ago
its on /reports/4
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
i have no idea i also dont know what client is+ the sql query should only happen on sever
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
@Romi i think you make sql queries on the client xD
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
you have very much todo xD
No description
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
the colors are not correct
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
dark i never installed any other things custom themes or what ever xD
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
OS: Windows 10 10.0.22621 CPU: (6) x64 Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
GitHub
devtools document is not defined Β· Issue #70 Β· danielroe/nuxt-vite...
no idea why this happens normal tests are running :D thanks for this module ξ‚Ά recipes ξ‚° npx envinfo --system --binaries --browser --npmPackages System: OS: Windows 10 10.0.22621 CPU: (6) x64 Intel(...
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
maybe i changed i am not sure can you not get the current one xD i forgot mine looks better as the dark one i have no idea
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
Wow that looks so cool Oh, have I misunderstood how setup works I thought that runs it on the server ?
πŸ‡¨πŸ‡­ Marko Bolliger <cannap>
wait i am not sure
Romi
RomiOPβ€’2y ago
πŸ˜‚
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
Yeah that’s what I thought But why am I getting this error xD
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
This 😭
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
Sure , I’m not home atm but will try that. I did test by removing .name
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
And it outputted an array of the data For that driver
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
Ok not problem that would be great
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
This what happens when I console.log
No description
Romi
RomiOPβ€’2y ago
But will message you once I’m back πŸ™‚
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
hey @Sr. Full Stack Dev I am back πŸ™‚ so doing this
Driver: <span class=" uppercase"> {{ report?.driver?.name }}</span></h2>

Driver: <span class=" uppercase"> {{ report?.driver?.name }}</span></h2>

has fixed it and shows the data why is that lol as I thought
?
?
just checks if its available
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
but whats underfined as its still outputting correctly
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
im am using that
No description
Romi
RomiOPβ€’2y ago
but now its working when I removed wtf
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
but I did not change data and now removed the ? check lol
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
oh thats a thing lol , prob was that Thanks πŸ™‚ now I can carry on building my app xD
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
is this the correct way to add tailwind plugins using the nuxt tailwind package? I created my own config file.
No description
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
do I need the import statement?
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
I have installed tailwind forms but still not working nvm needed a restart of terminal ty again
Romi
RomiOPβ€’2y ago
Hi Again, I am trying to total up all the weeks hours to calculate the total hours for the report. What is it called to cross add between rows as trying to search from some docs but not sure what the terminology is called
No description
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
correct
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
but how to I pass my data to each row into the array? for example you have 1,2,3 I need to pass
report1.hours, report2.hours, report3.hours
report1.hours, report2.hours, report3.hours
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
so this is my report
const { data } = useAsyncData('reports', async () => {
const { data, error } = await client
.from('reports')
.select('id, driver ( * ), created_at, base_rate, total_hours, gross_pay, pay_slip, net_pay')
.eq('id', route.params.id)

if (error) {
console.log(error)
}
return data
})

const { data } = useAsyncData('reports', async () => {
const { data, error } = await client
.from('reports')
.select('id, driver ( * ), created_at, base_rate, total_hours, gross_pay, pay_slip, net_pay')
.eq('id', route.params.id)

if (error) {
console.log(error)
}
return data
})

and then my weeks are in a component
const route = useRoute()
const client = useSupabaseClient()

const { data, error } = await client.from('weeks').select('*').eq('reports', route.params.id)
if (error) {
console.log('error', error)
}
const route = useRoute()
const client = useSupabaseClient()

const { data, error } = await client.from('weeks').select('*').eq('reports', route.params.id)
if (error) {
console.log('error', error)
}
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
this right
[
{
"id": 1,
"created_at": "2023-01-31T16:06:51.385299+00:00",
"base_rate": 400,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "Week 1",
"total_hours": 12.5,
"total_amount": 45.6
},
{
"id": 2,
"created_at": "2023-02-22T20:08:25.263205+00:00",
"base_rate": null,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "test report",
"total_hours": 40,
"total_amount": null
},
{
"id": 3,
"created_at": "2023-02-22T20:10:15.2842+00:00",
"base_rate": null,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "real test report",
"total_hours": 30,
"total_amount": null
}
]
[
{
"id": 1,
"created_at": "2023-01-31T16:06:51.385299+00:00",
"base_rate": 400,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "Week 1",
"total_hours": 12.5,
"total_amount": 45.6
},
{
"id": 2,
"created_at": "2023-02-22T20:08:25.263205+00:00",
"base_rate": null,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "test report",
"total_hours": 40,
"total_amount": null
},
{
"id": 3,
"created_at": "2023-02-22T20:10:15.2842+00:00",
"base_rate": null,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "real test report",
"total_hours": 30,
"total_amount": null
}
]
thats my weeks ^ this is my report
{
"id": 4,
"created_at": "2023-02-22T18:55:19.510042+00:00",
"base_rate": 120,
"total_hours": 500,
"gross_pay": 0,
"pay_slip": "payslips",
"net_pay": 120,
"driver": {
"id": 1,
"created_at": "2023-01-31T16:01:18.475061+00:00",
"name": "romi",
"email": "[email protected]",
"contract_hours": 30,
"active": true,
"employed": false
}
}
{
"id": 4,
"created_at": "2023-02-22T18:55:19.510042+00:00",
"base_rate": 120,
"total_hours": 500,
"gross_pay": 0,
"pay_slip": "payslips",
"net_pay": 120,
"driver": {
"id": 1,
"created_at": "2023-01-31T16:01:18.475061+00:00",
"name": "romi",
"email": "[email protected]",
"contract_hours": 30,
"active": true,
"employed": false
}
}
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
No description
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
correct
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
{
"id": 1,
"created_at": "2023-01-31T16:06:51.385299+00:00",
"base_rate": 400,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "Week 1",
"total_hours": 12.5,
"total_amount": 45.6
},
{
"id": 2,
"created_at": "2023-02-22T20:08:25.263205+00:00",
"base_rate": null,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "test report",
"total_hours": 40,
"total_amount": null
},
{
"id": 3,
"created_at": "2023-02-22T20:10:15.2842+00:00",
"base_rate": null,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "real test report",
"total_hours": 30,
"total_amount": null
}
]
{
"id": 1,
"created_at": "2023-01-31T16:06:51.385299+00:00",
"base_rate": 400,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "Week 1",
"total_hours": 12.5,
"total_amount": 45.6
},
{
"id": 2,
"created_at": "2023-02-22T20:08:25.263205+00:00",
"base_rate": null,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "test report",
"total_hours": 40,
"total_amount": null
},
{
"id": 3,
"created_at": "2023-02-22T20:10:15.2842+00:00",
"base_rate": null,
"monday_hours": null,
"monday_fixed": null,
"reports": 4,
"name": "real test report",
"total_hours": 30,
"total_amount": null
}
]
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
that worked now, cache maybe when I tired first version
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
const total = data.map(obj => obj.total_hours).reduce((partialSum, a) => partialSum + a, 0);
console.log(total); // your total
const total = data.map(obj => obj.total_hours).reduce((partialSum, a) => partialSum + a, 0);
console.log(total); // your total
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
so in my report component right I can then use {{ total }} and then store that against my db?
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
well its not actually a report component its my index.vue
Romi
RomiOPβ€’2y ago
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
i noticed lol
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
so how can I declare it from another file
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
Yeah I have been following some tutorials on the side for certain parts but then get stuck on complex things where I cant really find as much information on yeah have heard of Pinia its state management right
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
Thanks, for now I might just put everything into one file kind of learn the basics while finishing the project then come back to refactor it back to components. This project was more of a replacement I built in Laravel + vue last year but with upgrades so thought it would be good practice. I actually have a full web app built on core php that I want to upgrade the frond end using Nuxt but need to learn first πŸ™‚ Thanks for the help really appreciate it
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
Thanks want to stop doing Wordpress πŸ˜†
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
lol I Want to build with javascript not php lol
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
have used bit.ly yes
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
no way
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
dam nice I work for a Digital agency and just completed my apprenticeship thanks
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
yeah I spend all day wordpress get home then start working on my own projects
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
dam I wish What do you recommend for learning vue/nuxt?
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
yeah I might give that a go with downloading projects, as I watch tutorials but I always change it so i'm not just following it line by line
Unknown User
Unknown Userβ€’2y ago
Message Not Public
Sign In & Join Server To View
Romi
RomiOPβ€’2y ago
ah thats cool I will defo check that out ty
Want results from more Discord servers?
Add your server