add schedule button for master

This commit is contained in:
vchikalkin 2025-01-29 20:50:31 +03:00
parent f3c96e9ea8
commit 4e1b0da035
6 changed files with 55 additions and 1 deletions

View File

@ -1,5 +1,5 @@
import { getProfile } from '@/actions/profile';
import { PersonCard, ProfileDataCard } from '@/components/profile';
import { LinksCard, PersonCard, ProfileDataCard } from '@/components/profile';
import { dehydrate, HydrationBoundary, QueryClient } from '@tanstack/react-query';
export default async function ProfilePage() {
@ -15,6 +15,7 @@ export default async function ProfilePage() {
<div className="space-y-4">
<PersonCard />
<ProfileDataCard />
<LinksCard />
</div>
</HydrationBoundary>
);

View File

@ -0,0 +1,3 @@
export default function SchedulePage() {
return 'Schedule';
}

View File

@ -1,3 +1,4 @@
export * from './card-header';
export * from './checkbox-field';
export * from './link-button';
export * from './text-field';

View File

@ -0,0 +1,21 @@
import Link from 'next/link';
type Props = {
readonly description?: string;
readonly href: string;
readonly text: string;
readonly visible?: boolean;
};
export function LinkButton({ description, href, text, visible }: Props) {
if (!visible) return null;
return (
<Link href={href} rel="noopener noreferrer">
<div className="flex w-full flex-col rounded-2xl bg-background p-4 px-6 shadow-lg backdrop-blur-2xl dark:bg-primary/5">
<h2 className="text-lg font-bold text-foreground">{text}</h2>
<span className="mt-1 text-sm text-muted-foreground">{description}</span>
</div>
</Link>
);
}

View File

@ -1,2 +1,3 @@
export * from './data-card';
export * from './links-card';
export * from './person-card';

View File

@ -0,0 +1,27 @@
/* eslint-disable canonical/id-match */
'use client';
import { type ProfileProps } from '../types';
import { LinkButton } from './components';
import { getProfile } from '@/actions/profile';
import { Enum_Customer_Role } from '@repo/graphql/types';
import { useQuery } from '@tanstack/react-query';
export function LinksCard({ telegramId }: Readonly<ProfileProps>) {
const { data: customer } = useQuery({
queryFn: () => getProfile({ telegramId }),
queryKey: telegramId ? ['profile', 'telegramId', telegramId] : ['profile'],
});
const isMaster = customer?.role === Enum_Customer_Role.Master;
return (
<div className="flex flex-col gap-4 p-4 py-0">
<LinkButton
description="Указать доступные дни и время для записи клиентов"
href="/profile/schedule"
text="График работы"
visible={isMaster}
/>
</div>
);
}