show upgrade badge and hide /team/null when team unpublished (#7059)

* untested but i think this works

* fix upgrade badge

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
This commit is contained in:
Peer Richelsen
2023-02-17 10:48:13 -07:00
committed by GitHub
co-authored by CarinaWolli
parent 5da76c698e
commit 48e5d18ea1
2 changed files with 30 additions and 5 deletions
+29 -4
View File
@@ -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>
)}
@@ -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
@@ -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>
);
};
@@ -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,