fix: mobile event types and avatars (#11184)

This commit is contained in:
Leo Giovanetti 2023-09-06 18:41:03 -03:00 committed by GitHub
parent fce98ebb13
commit b7ae8c9594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 9 deletions

View File

@ -108,8 +108,10 @@ const MobileTeamsTab: FC<MobileTeamsTabProps> = (props) => {
const orgBranding = useOrgBranding(); const orgBranding = useOrgBranding();
const tabs = eventTypeGroups.map((item) => ({ const tabs = eventTypeGroups.map((item) => ({
name: item.profile.name ?? "", name: item.profile.name ?? "",
href: item.teamId ? `/event-types?teamId=${item.teamId}` : "/event-types", href: item.teamId ? `/event-types?teamId=${item.teamId}` : "/event-types?noTeam",
avatar: item.profile.image ?? `${orgBranding?.fullDomain ?? WEBAPP_URL}/${item.profile.slug}/avatar.png`, avatar: orgBranding
? `${orgBranding.fullDomain}${item.teamId ? "/team" : ""}/${item.profile.slug}/avatar.png`
: item.profile.image ?? `${WEBAPP_URL + (item.teamId && "/team")}/${item.profile.slug}/avatar.png`,
})); }));
const { data } = useTypedQuery(querySchema); const { data } = useTypedQuery(querySchema);
const events = eventTypeGroups.filter((item) => item.teamId === data.teamId); const events = eventTypeGroups.filter((item) => item.teamId === data.teamId);
@ -117,13 +119,15 @@ const MobileTeamsTab: FC<MobileTeamsTabProps> = (props) => {
return ( return (
<div> <div>
<HorizontalTabs tabs={tabs} /> <HorizontalTabs tabs={tabs} />
{events.length && ( {events.length > 0 ? (
<EventTypeList <EventTypeList
types={events[0].eventTypes} types={events[0].eventTypes}
group={events[0]} group={events[0]}
groupIndex={0} groupIndex={0}
readOnly={events[0].metadata.readOnly} readOnly={events[0].metadata.readOnly}
/> />
) : (
<CreateFirstEventTypeView />
)} )}
</div> </div>
); );
@ -358,6 +362,10 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL
} }
}, []); }, []);
if (!types.length) {
return group.teamId ? <EmptyEventTypeList group={group} /> : <CreateFirstEventTypeView />;
}
const firstItem = types[0]; const firstItem = types[0];
const lastItem = types[types.length - 1]; const lastItem = types[types.length - 1];
const isManagedEventPrefix = () => { const isManagedEventPrefix = () => {
@ -712,7 +720,10 @@ const EventTypeListHeading = ({
<Avatar <Avatar
alt={profile?.name || ""} alt={profile?.name || ""}
href={teamId ? `/settings/teams/${teamId}/profile` : "/settings/my-account/profile"} href={teamId ? `/settings/teams/${teamId}/profile` : "/settings/my-account/profile"}
imageSrc={`${orgBranding?.fullDomain ?? WEBAPP_URL}/${profile.slug}/avatar.png` || undefined} imageSrc={
`${orgBranding?.fullDomain ?? WEBAPP_URL}${teamId ? "/team" : ""}/${profile.slug}/avatar.png` ||
undefined
}
size="md" size="md"
className="mt-1 inline-flex justify-center" className="mt-1 inline-flex justify-center"
/> />
@ -759,6 +770,12 @@ const CreateFirstEventTypeView = () => {
Icon={LinkIcon} Icon={LinkIcon}
headline={t("new_event_type_heading")} headline={t("new_event_type_heading")}
description={t("new_event_type_description")} description={t("new_event_type_description")}
className="mb-16"
buttonRaw={
<Button href="?dialog=new" variant="button">
{t("create")}
</Button>
}
/> />
); );
}; };
@ -893,8 +910,10 @@ const Main = ({
groupIndex={index} groupIndex={index}
readOnly={group.metadata.readOnly} readOnly={group.metadata.readOnly}
/> />
) : ( ) : group.teamId ? (
<EmptyEventTypeList group={group} /> <EmptyEventTypeList group={group} />
) : (
<CreateFirstEventTypeView />
)} )}
</div> </div>
)) ))

View File

@ -142,7 +142,7 @@ export default function Signup({ prepopulateFormValues, token, orgSlug }: Signup
<TextField <TextField
addOnLeading={ addOnLeading={
orgSlug orgSlug
? getOrgFullDomain(orgSlug, { protocol: true }) ? `${getOrgFullDomain(orgSlug, { protocol: true })}/`
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/` : `${process.env.NEXT_PUBLIC_WEBSITE_URL}/`
} }
{...register("username")} {...register("username")}

View File

@ -275,8 +275,7 @@ export const getByViewerHandler = async ({ ctx, input }: GetByViewerOptions) =>
const bookerUrl = await getBookerUrl(user); const bookerUrl = await getBookerUrl(user);
return { return {
// don't display event teams without event types, eventTypeGroups,
eventTypeGroups: eventTypeGroups.filter((groupBy) => groupBy.parentId || !!groupBy.eventTypes?.length),
// so we can show a dropdown when the user has teams // so we can show a dropdown when the user has teams
profiles: eventTypeGroups.map((group) => ({ profiles: eventTypeGroups.map((group) => ({
...group.profile, ...group.profile,

View File

@ -48,7 +48,13 @@ export function EmptyScreen({
</div> </div>
)} )}
<div className="flex max-w-[420px] flex-col items-center"> <div className="flex max-w-[420px] flex-col items-center">
<h2 className="text-semibold font-cal text-emphasis mt-6 text-center text-xl">{headline}</h2> <h2
className={classNames(
"text-semibold font-cal text-emphasis text-center text-xl",
Icon && "mt-6"
)}>
{headline}
</h2>
{description && ( {description && (
<div className="text-default mb-8 mt-3 text-center text-sm font-normal leading-6"> <div className="text-default mb-8 mt-3 text-center text-sm font-normal leading-6">
{description} {description}