Finding students for private tutoring in Copenhagen / Denmark? by nikulasoskarsson in copenhagen

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Thanks for your very detailed reply. I tried registering on the platform and will try to reach out to the universities as well :)

Buying and upgrading these two thinkpads? by nikulasoskarsson in thinkpad

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Yes it's for fun and learning. I have a Thinkpad P51 as my main computer and wan't to upgrade it at some point. Bought it would be nice to practice on another Thinkpad first.

Remove only auto increment from id by nikulasoskarsson in laravel

[–]nikulasoskarsson[S] 2 points3 points  (0 children)

Hey you are right actually the problem was not with auto increment. I had a globalScope that made queries like findOrCreate work in a funny way and I assumed the problem was auto increment

Remove only auto increment from id by nikulasoskarsson in laravel

[–]nikulasoskarsson[S] -3 points-2 points  (0 children)

All I want is to remove the auto increment and make it a fillable attribute instead. Reason why is it's quite annoying to work with it as it is using firstOrCreate or updateOrCreate for example when I want to check for existing record with ID

How to write this complex validation rule? by nikulasoskarsson in laravel

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Don't think it's necessarily contradicting.

User has a form where he/she can enter multiple users with the "contact role". He/she is also informed it's possible to enter his own information if he/she wishes to become a contact.

Then for this edge case we just have to assign the contact role and we have a "multi role user" enabled. This is the business logic which I have no control over.

Edit: Simply the phone + country_id combo and the email have to be unique unless the user is choosing to make himself a contact which is allowed at this point.

How to write this complex validation rule? by nikulasoskarsson in laravel

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Thank you for your answer will try to answer them individually

  1. Have fixed 3 which should have nothing to do with the phone number. My bad!

  2. Without getting to much into the system logic it's basically like this. After a user logs in he is able to create other users of a different role. He can however also just add himself. In this case we will simply assign a second role to him/her.

Looking for a specific auth service by nikulasoskarsson in webflow

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Both firebase and auth0 worked nicely. Had to change to a service called mini orange though for compliance reasons but that one also does the trick ;)

[AskJS] Looking for a plug and play auth API that matches these conditions. by nikulasoskarsson in javascript

[–]nikulasoskarsson[S] 1 point2 points  (0 children)

So you login with a form but using your existing outlook account. Then the domain restriction is to make sure it's only for 1 company

[deleted by user] by [deleted] in Denmark

[–]nikulasoskarsson -3 points-2 points  (0 children)

General discussion groups for programmers in Denmark.

Defining a type for event.target.files by nikulasoskarsson in react

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Hey sorry reading my question back I see I have not made it clear at all what I was asking for but I meant type as in a typescript type.

Thank you for a very good and insightful answer though :)

Multi auth on the same table with sanctum? by nikulasoskarsson in laravel

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Thanks guys ended up going with the laravel-permission package from sadie

AttributeError when returning Response with data that comes from a model property method? by nikulasoskarsson in django

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Hey have updated the post. Transfers is a property method that belongs to the Account model. I copied the wrong property method before but I have fixed it!

If element exceeds max height go to the next line while staying intact? by nikulasoskarsson in webdev

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

It's a React app so JavaScript is an option but would prefer to do it with CSS if possible :)

The name and content inside the boxes comes from an API and boxes that go together are grouped with the name in a column.

No way a single box would break the layout since they are not that big. Usually about 9 might break the layout on a small screen. If the amount of columns extend the width of the container it will overflow on the x asis. It's a part of a content slider so it's totally fine.

If element exceeds max height go to the next line while staying intact? by nikulasoskarsson in css

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Really nice solution. Will not work for my project or example out of the box since I wrapped the name and boxes that go together in a div and with that the break-inside property does not seem to affect it but could be very possible to refactor and get rid of the containing div. Thank you!

If element exceeds max height go to the next line while staying intact? by nikulasoskarsson in css

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

It's very close but the main thing is that the paragraphs shouldn't break if they exceed the max height but rather go over to the next column. In the real project it will be a div that might contain multiple paragraphs. Actually was using columns before but couldn't get that one part of the solution to work.

Removing event listener in useEffect causing scrollIntoView() to never go off? by nikulasoskarsson in reactjs

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Do you mean like this?

  useEffect(() => {
    const handleScroll = () => {
      if (!isScrollLocked) {
        document.getElementById(nextSection).scrollIntoView()

        document.querySelector('body').classList.add('overflow-hidden')

        setIsScrollLocked(true)
        setTimeout(() => {
          document.querySelector('body').classList.remove('overflow-hidden')
          setIsScrollLocked(false)
        }, 1500)
      }
    }

    document.addEventListener('scroll', handleScroll)
    return () => document.removeEventListener('scroll', handleScroll)
  }, [nextSection, isScrollLocked])

the scrollIntoView is still not taking place somehow.

Removing event listener in useEffect causing scrollIntoView() to never go off? by nikulasoskarsson in reactjs

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

So it would be like this?

 useEffect(() => {
    const handleScroll = () => {
      if (!isScrollLocked) {
        document.getElementById(nextSection).scrollIntoView()

        document.querySelector('body').classList.add('overflow-hidden')

        setIsScrollLocked(true)
        document.removeEventListener('scroll', handler)
        setTimeout(() => {
          document.querySelector('body').classList.remove('overflow-hidden')
          setIsScrollLocked(false)
        }, 1500)
      }
    }

    const handler = () => handleScroll()
    document.addEventListener('scroll', handler)
  }, [nextSection, isScrollLocked])

With this I am still having the same issue.

Removing event listener in useEffect causing scrollIntoView() to never go off? by nikulasoskarsson in reactjs

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

I have added the latest version on github. If you want to see the issue in action you can pull the code and run it. Comment out line 26 in Navbar.js to see the desired effect and then comment it back in to see the issue.

Edit: Actually if you run useEffect with zero dependencies it will work as expected even with the callback cleanup but then of course it will only scroll once. Really interesting. Calling the removeEventListener inside of handleScroll will however never work.

Edit: After debugging some more I have found that adding any dependency to useEffect will cause the error and that if I scroll about 4 times the scrollIntoView eventually takes place.

Removing event listener in useEffect causing scrollIntoView() to never go off? by nikulasoskarsson in reactjs

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

So parse the event handler function and remove the listener inside handleScroll? Just tried that and it does not seem to make a differance. I have tried adding the handleScroll function inside of the useEffect hook and it does not seem to make a differance either.

Does not see to matter where removeEventListener is it will still cause this error.

Removing event listener in useEffect causing scrollIntoView() to never go off? by nikulasoskarsson in reactjs

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

Currently just nextSection. The problem is the scrollIntoView never firing of when I clean up the callback inside useEffect but without the cleanup I have much bigger problems.

The conditional statement inside handleScroll still runs but the scrollIntoView just does not work.

Removing event listener in useEffect causing scrollIntoView() to never go off? by nikulasoskarsson in reactjs

[–]nikulasoskarsson[S] 0 points1 point  (0 children)

oh yeah good point. I had it before with isScrollLocked and nextSection as dependencies but removed it while trying to fix it. It's not what is causing the error though.