2026-07-06 12:35:42 +02:00
|
|
|
import { computed, inject, provide, type InjectionKey } from 'vue'
|
2026-06-14 10:08:46 +03:30
|
|
|
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>
|
2026-07-06 12:35:42 +02:00
|
|
|
nameProject: ReturnType<typeof computed<string>>
|
|
|
|
|
rulesTitle: ReturnType<typeof computed<string>>
|
|
|
|
|
rulesBlocks: ReturnType<typeof computed<RulesBlock[]>>
|
2026-06-14 10:08:46 +03:30
|
|
|
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 || 'بورس مس',
|
|
|
|
|
)
|
|
|
|
|
|
2026-07-06 12:35:42 +02:00
|
|
|
const rulesTitle = computed(() => getRulesTitle(nameProject.value, true))
|
2026-06-14 10:08:46 +03:30
|
|
|
|
2026-07-06 12:35:42 +02:00
|
|
|
const rulesBlocks = computed(() => getRulesBlocks(nameProject.value, true))
|
2026-06-14 10:08:46 +03:30
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|