| 1 |
/** |
| 2 |
* Page Header Component |
| 3 |
* Reusable header for all pages with title, description, and actions |
| 4 |
* Supports role-based action visibility |
| 5 |
*/ |
| 6 |
|
| 7 |
import React from "react"; |
| 8 |
import { __ } from "../../lib/i18n"; |
| 9 |
import { ConditionalRender } from "../ui/conditional-render"; |
| 10 |
|
| 11 |
interface PageHeaderProps { |
| 12 |
title?: string; // Optional - title is now shown in top bar |
| 13 |
description?: string; |
| 14 |
actions?: React.ReactNode; |
| 15 |
actionCapability?: string; |
| 16 |
actionRequirePro?: boolean; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Page Header Component |
| 21 |
* |
| 22 |
* @example |
| 23 |
* <PageHeader |
| 24 |
* title={__('Trips', 'yatra')} |
| 25 |
* description={__('Manage your travel packages', 'yatra')} |
| 26 |
* actionCapability="yatra_edit_trips" |
| 27 |
* actions={<Button>Add New</Button>} |
| 28 |
* /> |
| 29 |
*/ |
| 30 |
export const PageHeader: React.FC<PageHeaderProps> = ({ |
| 31 |
description, |
| 32 |
actions, |
| 33 |
actionCapability, |
| 34 |
actionRequirePro = false, |
| 35 |
}) => { |
| 36 |
return ( |
| 37 |
<div className="flex items-center justify-between mb-8"> |
| 38 |
<div> |
| 39 |
{description && ( |
| 40 |
<p className="text-sm text-gray-500 dark:text-gray-400"> |
| 41 |
{description} |
| 42 |
</p> |
| 43 |
)} |
| 44 |
</div> |
| 45 |
|
| 46 |
{actions && ( |
| 47 |
<ConditionalRender |
| 48 |
capability={actionCapability} |
| 49 |
requirePro={actionRequirePro} |
| 50 |
> |
| 51 |
<div className="flex items-center gap-3">{actions}</div> |
| 52 |
</ConditionalRender> |
| 53 |
)} |
| 54 |
</div> |
| 55 |
); |
| 56 |
}; |
| 57 |
|
| 58 |
export default PageHeader; |
| 59 |
|