Files
boursecu_user/src/views/base/rules/composables/useRulesPage.ts
T
safavimohadeseh78andCursor 59cceaf581 Make boursecu branch boursecu-only and simplify app loading.
Remove multi-tenant branches and default views, show logo-only boot and splash screens, and polish boursecu transactions tab styling.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 12:35:42 +02:00

51 lines
1.5 KiB
TypeScript

import { computed, inject, provide, type InjectionKey } from 'vue'
import { useConfigStore } from '@/store/configStore'
import {
getProjectBaleLink,
getProjectSupportPhoneLink,
} from '@/utils/config'
import { getRulesBlocks, getRulesTitle, type RulesBlock } from '../rulesContent'
export interface RulesPageContext {
config: ReturnType<typeof useConfigStore>
nameProject: ReturnType<typeof computed<string>>
rulesTitle: ReturnType<typeof computed<string>>
rulesBlocks: ReturnType<typeof computed<RulesBlock[]>>
getProjectSupportPhoneLink: typeof getProjectSupportPhoneLink
getProjectBaleLink: typeof getProjectBaleLink
}
export const RULES_PAGE_CONTEXT_KEY: InjectionKey<RulesPageContext> = Symbol('rulesPageContext')
export function useRulesPage() {
const config = useConfigStore()
const nameProject = computed(
() => config.config?.name_fa || config.config?.name || 'بورس مس',
)
const rulesTitle = computed(() => getRulesTitle(nameProject.value, true))
const rulesBlocks = computed(() => getRulesBlocks(nameProject.value, true))
const context: RulesPageContext = {
config,
nameProject,
rulesTitle,
rulesBlocks,
getProjectSupportPhoneLink,
getProjectBaleLink,
}
provide(RULES_PAGE_CONTEXT_KEY, context)
return context
}
export function useRulesPageContext() {
const context = inject(RULES_PAGE_CONTEXT_KEY)
if (!context) {
throw new Error('useRulesPageContext must be used within a page that calls useRulesPage()')
}
return context
}