PublicLayout.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import React from 'react'
  2. import type { ReactNode } from 'react'
  3. import { Link, useLocation } from 'react-router-dom'
  4. import { useLegacyThemePage, usePageContext } from '../shared/pageContext'
  5. import { AppLogo } from '../components/common/AppLogo'
  6. import { LocaleSwitcher } from '../components/common/LocaleSwitcher'
  7. type PublicLayoutProps = {
  8. children: ReactNode
  9. footer?: boolean
  10. variant?: 'demo' | 'live'
  11. profilePath?: string
  12. simulationPath?: string
  13. bookingUrl?: string
  14. }
  15. function PublicHeader({
  16. variant = 'demo',
  17. profilePath: profilePathOverride,
  18. simulationPath,
  19. bookingUrl,
  20. }: Omit<PublicLayoutProps, 'children' | 'footer'>) {
  21. const { path, copy } = usePageContext()
  22. const location = useLocation()
  23. const profilePath = profilePathOverride || path('/profile')
  24. const customerSimulationPath = simulationPath || path('/customer-simulation')
  25. const isCustomerSimulation = location.pathname.startsWith(path('/customer-simulation'))
  26. const pageCopy = copy.publicLayout
  27. const navCopy = pageCopy.nav
  28. return (
  29. <header>
  30. <nav className="navbar navbar-expand-lg header-light bg-white box-shadow-small">
  31. <div className="container-fluid">
  32. <div className="col-auto me-auto">
  33. <Link className="navbar-brand" to={path('')}>
  34. <AppLogo />
  35. </Link>
  36. </div>
  37. <div className="col-auto menu-order position-static">
  38. <button
  39. className="navbar-toggler float-start"
  40. type="button"
  41. data-bs-toggle="collapse"
  42. data-bs-target="#publicNavbarNav"
  43. aria-controls="publicNavbarNav"
  44. aria-label="Toggle navigation"
  45. >
  46. <span className="navbar-toggler-line"></span>
  47. <span className="navbar-toggler-line"></span>
  48. <span className="navbar-toggler-line"></span>
  49. <span className="navbar-toggler-line"></span>
  50. </button>
  51. <div className="collapse navbar-collapse" id="publicNavbarNav">
  52. <ul className="navbar-nav">
  53. <li className="nav-item"><a href={`${profilePath}#profile`} className="nav-link">{navCopy.profile}</a></li>
  54. <li className="nav-item"><a href={`${profilePath}#templates`} className="nav-link">{navCopy.templates}</a></li>
  55. <li className="nav-item"><Link to={customerSimulationPath} className={`nav-link${isCustomerSimulation ? ' active' : ''}`}>{navCopy.simulation}</Link></li>
  56. {variant === 'live' ? (
  57. bookingUrl ? <li className="nav-item"><a href={bookingUrl} className="nav-link" target="_blank" rel="noreferrer">{navCopy.booking}</a></li> : null
  58. ) : (
  59. <li className="nav-item"><a href={`${profilePath}#reviews`} className="nav-link">{navCopy.reviews}</a></li>
  60. )}
  61. </ul>
  62. </div>
  63. </div>
  64. <div className="col-auto d-flex stylist-dashboard-actions gap-2">
  65. <LocaleSwitcher locale={locale} />
  66. </div>
  67. </div>
  68. </nav>
  69. </header>
  70. )
  71. }
  72. export function PublicLayout({
  73. children,
  74. footer = true,
  75. variant = 'demo',
  76. profilePath,
  77. simulationPath,
  78. bookingUrl,
  79. }: PublicLayoutProps) {
  80. useLegacyThemePage({ bodyClassName: '', mobileNavStyle: 'classic' })
  81. const { copy } = usePageContext()
  82. return (
  83. <>
  84. <PublicHeader variant={variant} profilePath={profilePath} simulationPath={simulationPath} bookingUrl={bookingUrl} />
  85. {children}
  86. {footer ? (
  87. <footer className="p-0 footer-light position-relative">
  88. <div className="container">
  89. <div className="row justify-content-center pt-5 pb-5 sm-pt-40px sm-pb-40px">
  90. <div className="col-12 text-center">
  91. <img src="/images/logo_color.svg" alt="Aitori Stylist" className="footer-logo mb-20px" style={{ maxWidth: '160px' }} />
  92. <div className="fs-16 text-medium-gray">{copy.publicLayout.footer}</div>
  93. </div>
  94. </div>
  95. </div>
  96. </footer>
  97. ) : null}
  98. </>
  99. )
  100. }