Skip to content

Commit

Permalink
show upgrade badge and hide /team/null when team unpublished (#7059)
Browse files Browse the repository at this point in the history
* untested but i think this works

* fix upgrade badge

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
  • Loading branch information
PeerRich and CarinaWolli committed Feb 17, 2023
1 parent 5da76c6 commit 48e5d18
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
33 changes: 29 additions & 4 deletions apps/web/pages/event-types/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,17 @@ const Item = ({ type, group, readOnly }: { type: EventType; group: EventTypeGrou
data-testid={"event-type-title-" + type.id}>
{type.title}
</span>
<small
className="hidden font-normal leading-4 text-gray-600 sm:inline"
data-testid={"event-type-slug-" + type.id}>{`/${group.profile.slug}/${type.slug}`}</small>
{group.profile.slug ? (
<small
className="hidden font-normal leading-4 text-gray-600 sm:inline"
data-testid={"event-type-slug-" + type.id}>
{`/${group.profile.slug}/${type.slug}`}
</small>
) : (
<></>
)}
{readOnly && (
<span className="rtl:ml-2inline items-center rounded-sm bg-gray-100 px-1.5 py-0.5 text-xs font-medium text-gray-800 ltr:ml-2 ltr:mr-2">
<span className="inline items-center rounded-sm bg-gray-100 px-1.5 py-0.5 text-xs font-medium text-gray-800 ltr:ml-2 ltr:mr-2 rtl:ml-2">
{t("readonly")}
</span>
)}
Expand Down Expand Up @@ -557,6 +563,18 @@ const EventTypeListHeading = ({
membershipCount,
teamId,
}: EventTypeListHeadingProps): JSX.Element => {
const { t } = useLocale();
const router = useRouter();

const publishTeamMutation = trpc.viewer.teams.publish.useMutation({
onSuccess(data) {
router.push(data.url);
},
onError: (error) => {
showToast(error.message, "error");
},
});

return (
<div className="mb-4 flex items-center space-x-2">
<Avatar
Expand Down Expand Up @@ -588,6 +606,13 @@ const EventTypeListHeading = ({
</Link>
)}
</div>
{!profile?.slug && !!teamId && (
<button onClick={() => publishTeamMutation.mutate({ teamId })}>
<Badge variant="gray" className="mb-1 -ml-2">
{t("upgrade")}
</Badge>
</button>
)}
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion packages/trpc/server/routers/viewer/eventTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export const eventTypesRouter = router({
profile: {
name: membership.team.name,
image: `${CAL_URL}/team/${membership.team.slug}/avatar.png`,
slug: "team/" + membership.team.slug,
slug: membership.team.slug ? "team/" + membership.team.slug : null,
},
metadata: {
membershipCount: membership.team.members.length,
Expand Down

0 comments on commit 48e5d18

Please sign in to comment.