-
Notifications
You must be signed in to change notification settings - Fork 140
[FEAT] Create Team CTA #539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
3a40346
f1af317
a28b7fc
9b9a1ca
d710000
23d1e5d
274fd68
42a3797
dcf2e30
1fa9fcc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,8 @@ import { | |
RadioButtonChecked, | ||
SearchRounded, | ||
ClearRounded, | ||
Edit | ||
Edit, | ||
Add | ||
} from '@mui/icons-material'; | ||
import { | ||
alpha, | ||
|
@@ -22,6 +23,7 @@ import { | |
useTheme | ||
} from '@mui/material'; | ||
import Link from 'next/link'; | ||
import { useRouter } from 'next/router'; | ||
import pluralize from 'pluralize'; | ||
import { | ||
FC, | ||
|
@@ -84,7 +86,7 @@ export const TeamPopover: FC<{ | |
const { team } = useSingleTeamConfig(); | ||
const { addPage } = useOverlayPage(); | ||
const updatingTeamMemberFilter = useBoolState(); | ||
|
||
const router = useRouter(); | ||
const isRoleEng = false; | ||
const activeRouteEvent = useActiveRouteEvent('APP_TEAM_CHANGE_SINGLE'); | ||
const dispatch = useDispatch(); | ||
|
@@ -115,6 +117,11 @@ export const TeamPopover: FC<{ | |
|
||
const teamReposMap = useSelector((s) => s.app.teamsProdBranchMap); | ||
|
||
const addTeam = () => { | ||
const path = `${ROUTES.TEAMS.PATH}?create=true`; | ||
router.push(path); | ||
}; | ||
|
||
return ( | ||
<Popover | ||
anchorEl={teamElRef.current} | ||
|
@@ -323,6 +330,15 @@ export const TeamPopover: FC<{ | |
'We getting your teams together, but someone seems missing 🤔' | ||
)} | ||
</Scrollbar> | ||
{Boolean(apiTeams.length) && ( | ||
<FlexBox marginTop={'10px'}> | ||
<Button fullWidth variant="outlined" onClick={addTeam}> | ||
<FlexBox> | ||
|
||
<Add fontSize="small" /> Add new team | ||
</FlexBox> | ||
</Button> | ||
</FlexBox> | ||
)} | ||
</MenuListWrapperSecondary> | ||
</Stack> | ||
</FlexBox> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ import { Integration } from '@/constants/integrations'; | |
import { FetchState } from '@/constants/ui-states'; | ||
import { useAuth } from '@/hooks/useAuth'; | ||
import { useBoolState, useEasyState } from '@/hooks/useEasyState'; | ||
import { updateTeamBranchesMap } from '@/slices/app'; | ||
import { appSlice, updateTeamBranchesMap } from '@/slices/app'; | ||
import { fetchCurrentOrg } from '@/slices/auth'; | ||
import { fetchTeams, createTeam, updateTeam } from '@/slices/team'; | ||
import { useDispatch, useSelector } from '@/store'; | ||
|
@@ -95,7 +95,7 @@ export const TeamsCRUDProvider: React.FC<{ | |
const fetchTeamsAndRepos = useCallback(() => { | ||
// refetch session to update the onboarding state of org | ||
dispatch(fetchCurrentOrg()); | ||
dispatch( | ||
return dispatch( | ||
fetchTeams({ | ||
org_id: orgId, | ||
provider: Integration.GITHUB | ||
|
@@ -251,7 +251,7 @@ export const TeamsCRUDProvider: React.FC<{ | |
provider: Integration.GITHUB | ||
}) | ||
) | ||
.then((res) => { | ||
.then((res: any) => { | ||
if (res.meta.requestStatus === 'rejected') { | ||
enqueueSnackbar('Failed to create team', { | ||
variant: 'error', | ||
|
@@ -263,7 +263,18 @@ export const TeamsCRUDProvider: React.FC<{ | |
variant: 'success', | ||
autoHideDuration: 2000 | ||
}); | ||
fetchTeamsAndRepos(); | ||
const createdTeam = res.payload.team; | ||
|
||
fetchTeamsAndRepos().then((res: any) => { | ||
if (res.meta.requestStatus === 'fulfilled') { | ||
const { teams } = res.payload; | ||
const singleTeam = teams.find( | ||
(team: Team) => team.id === createdTeam.id | ||
); | ||
dispatch(appSlice.actions.setSingleTeam([singleTeam])); | ||
|
||
} | ||
}); | ||
|
||
callBack?.(res); | ||
}) | ||
.finally(isSaveLoading.false); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make this
mt={2}
looked better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure