Skip to content

Conversation

VipinDevelops
Copy link
Contributor

@VipinDevelops VipinDevelops commented Sep 7, 2024

Linked Issue(s)

#529
#537

Acceptance Criteria fulfillment

  • Add a button that redirects to the team page with create query
  • Consume the query in the team Page and show create team component

Proposed changes (including videos or screenshots)

Screencast.from.2024-09-09.13-24-32.webm

@VipinDevelops
Copy link
Contributor Author

VipinDevelops commented Sep 7, 2024

Hey @e-for-eshaan

Can you Please take a look ?
Thanks :)

@e-for-eshaan
Copy link
Contributor

e-for-eshaan commented Sep 8, 2024

Pasted Graphic 3

asymmetric design, looks a bit off
suggestions:

  • make the button to be full width of the selector-popover
  • make padding, margins and spacings to be uniform (above the button)
  • use <Button variant="outlined"/>. My hopes are that it might look better than the current design

showCreate.true();
router.replace(router.pathname, '');
}
}, [router, router.query.create, showCreate]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see, you only need to showCreate.true in your dependency array, but my guess is linter asked you to add the entire showCreate object.

  • instead of calling showCreate.true(), use depFn(showCreate, true),
  • update the dependency array to include showCreate.true, instead of showCreate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood

'We getting your teams together, but someone seems missing 🤔'
)}
</Scrollbar>
{apiTeams.length && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if teams don't exists (length==0), then we DEFINITELY need to ask them to create teams

although, we already have reroutes in place that redirect to teams page, but still, your check is redundant

Copy link
Contributor Author

@VipinDevelops VipinDevelops Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
We already have this button that asks to create a team if there are no teams that's why I added this check to show this button only if we have some team already

I will update it to check for {apiTeams.length > 0 && ( BUTTON) }

Copy link
Contributor

@e-for-eshaan e-for-eshaan Sep 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, well i missed that. great, keep the current condition,

don't add direct numbers as conditional checks
apiTeams.length would render a 0 on false

can convert to Boolean(apiTeams.length)
what you said {apiTeams.length > 0 && ( BUTTON) }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood

@VipinDevelops
Copy link
Contributor Author

asymmetric design, looks a bit off suggestions:

  • make the button to be full width of the selector-popover
  • make padding, margins and spacings to be uniform (above the button)
  • use <Button variant="outlined"/>. My hopes are that it might look better than the current design

Hey, @e-for-eshaan Looks Good now?
image

@VipinDevelops
Copy link
Contributor Author

Hey @e-for-eshaan I have also solved #537 in this PR
In this PR as well There Is some type assertion Because payload.team was unknow

Screenshot from 2024-09-08 12-57-46

@e-for-eshaan
Copy link
Contributor

yes this happens when consuming the response from dispatch pomise.
use this as the .then callback

(res: any) => {
if(res.meta.requestStatus !== 'rejected')
/*...your code...*/
}

@VipinDevelops
Copy link
Contributor Author

Hey @e-for-eshaan You mean to handle this call inside .then right?
I am already doing it inside that even here the res.payload type exist but .team in unknown
image

@e-for-eshaan
Copy link
Contributor

we typecast it to any

(res: any) => {}

that's what i was referring to in previous comment

@VipinDevelops
Copy link
Contributor Author

VipinDevelops commented Sep 8, 2024

okay so we are not sure about the response type here understood

@VipinDevelops
Copy link
Contributor Author

@e-for-eshaan I have made the changes and here I didn't use the requestStatus check because we already had a check and where we returned early

@e-for-eshaan
Copy link
Contributor

e-for-eshaan commented Sep 8, 2024

cool, i want you to check for data now

console.log a singleTeam when selecting from the teams selector

and console.log the response that you get after creating a team

are they the same type of object? does it need any more/fewer keys?

@VipinDevelops
Copy link
Contributor Author

Sure Let me check last time I check it was same but lets see how it's different from other case

@VipinDevelops
Copy link
Contributor Author

VipinDevelops commented Sep 8, 2024

@e-for-eshaan This is what we get when we use the selector to update team
Screenshot from 2024-09-08 14-19-01

this is what we get from the response team
Screenshot from 2024-09-08 14-20-09
only difference is manager_id and is_deleted here

I don't think mangaer_id is a problem because manager_id is optional
image

@VipinDevelops
Copy link
Contributor Author

also you can checkout complete working in the updated video above

@VipinDevelops
Copy link
Contributor Author

VipinDevelops commented Sep 8, 2024

I added the is_deleted in our response as well and obviously its just created so its not false

Response

Screenshot from 2024-09-08 14-35-56

Selector

Screenshot from 2024-09-08 14-36-37

@VipinDevelops
Copy link
Contributor Author

@e-for-eshaan Please take a look let me know if anything else left to do

@e-for-eshaan
Copy link
Contributor

e-for-eshaan commented Sep 8, 2024

it's not okay to assign selectedTeam in such an unsafe manner, might get troublesome later since it violates some basic assumptions.

How to approach this?

  • we have to find the team from the team-map we have in the redux state.
    const teamMap = useSelector((state) => state.team.teams)

  • so now, the events that transpire will be:

    • create team
    • wait for the creation call to finish (and be successful). get this response's teamId (c-id)
    • wait for the call that refreshes the teams maps
    • find the c-id w.r.t this fresh team-map

@e-for-eshaan
Copy link
Contributor

feel free to ask more questions!

@e-for-eshaan
Copy link
Contributor

e-for-eshaan commented Sep 9, 2024

  • fetchTeamsAndRepos: this seems to be the function refreshing the teams-map
  • edit this function to return a promise-response (async await)
  • use a .then on this function
  • consume the teams payload for this function
  • definitely add checks on the requestStatus every time, whenever consuming directly from dispatch promises

@VipinDevelops
Copy link
Contributor Author

VipinDevelops commented Sep 9, 2024

Awesome I was doing the same thing last night I basically tried different ways thanks for suggestion @e-for-eshaan I will make suggested changes.

@VipinDevelops
Copy link
Contributor Author

Have a look @e-for-eshaan

@e-for-eshaan
Copy link
Contributor

image

jagged alignment, use <FlexBox centered>...</Flexbox>

)}
</Scrollbar>
{Boolean(apiTeams.length) && (
<FlexBox marginTop={'10px'}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make this mt={2}

image

looked better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

{Boolean(apiTeams.length) && (
<FlexBox marginTop={'10px'}>
<Button fullWidth variant="outlined" onClick={addTeam}>
<FlexBox>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

centered

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it

const singleTeam = teams.find(
(team: Team) => team.id === createdTeam.id
);
dispatch(appSlice.actions.setSingleTeam([singleTeam]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check will never fail, but still,
if(singleTeam)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it

@VipinDevelops
Copy link
Contributor Author

VipinDevelops commented Sep 9, 2024

Have a Look @e-for-eshaan
Thanks for Quick Responses

@VipinDevelops
Copy link
Contributor Author

image
This is how it looks with more than 4 teams

@e-for-eshaan
Copy link
Contributor

Can you update the final video?

@VipinDevelops
Copy link
Contributor Author

Can you update the final video?

Updated

@e-for-eshaan
Copy link
Contributor

Good stuff, approving! 🎉

@VipinDevelops
Copy link
Contributor Author

Good stuff, approving! 🎉

Thanks man 😊 🔥

@VipinDevelops
Copy link
Contributor Author

Can we get this merged?

@e-for-eshaan e-for-eshaan merged commit aa0c53d into middlewarehq:main Sep 9, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants