add schedule button for master
This commit is contained in:
parent
f3c96e9ea8
commit
4e1b0da035
@ -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>
|
||||
);
|
||||
|
||||
3
apps/web/app/(main)/profile/schedule/page.tsx
Normal file
3
apps/web/app/(main)/profile/schedule/page.tsx
Normal file
@ -0,0 +1,3 @@
|
||||
export default function SchedulePage() {
|
||||
return 'Schedule';
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
export * from './card-header';
|
||||
export * from './checkbox-field';
|
||||
export * from './link-button';
|
||||
export * from './text-field';
|
||||
|
||||
21
apps/web/components/profile/cards/components/link-button.tsx
Normal file
21
apps/web/components/profile/cards/components/link-button.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
@ -1,2 +1,3 @@
|
||||
export * from './data-card';
|
||||
export * from './links-card';
|
||||
export * from './person-card';
|
||||
|
||||
27
apps/web/components/profile/cards/links-card.tsx
Normal file
27
apps/web/components/profile/cards/links-card.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user