refactor: update membership agreement and conflict resolution framework templates to utilize centralized cooperative information, enhance decision framework handling, and improve overall layout for better user experience
This commit is contained in:
parent
f1889b3a70
commit
7b4fb6c2fd
5 changed files with 510 additions and 703 deletions
81
composables/useCoopInfo.ts
Normal file
81
composables/useCoopInfo.ts
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
import { ref, watch, readonly } from 'vue'
|
||||
|
||||
export interface CoopInfo {
|
||||
cooperativeName: string
|
||||
dateEstablished: string
|
||||
purpose: string
|
||||
coreValues: string
|
||||
legalStructure: string
|
||||
registeredLocation: string
|
||||
isLegallyRegistered: boolean
|
||||
}
|
||||
|
||||
const STORAGE_KEY = 'coop-info'
|
||||
|
||||
// Global reactive state
|
||||
const coopInfo = ref<CoopInfo>({
|
||||
cooperativeName: '',
|
||||
dateEstablished: '',
|
||||
purpose: '',
|
||||
coreValues: '',
|
||||
legalStructure: '',
|
||||
registeredLocation: '',
|
||||
isLegallyRegistered: false
|
||||
})
|
||||
|
||||
// Flag to prevent loading during initial save
|
||||
let isInitialized = false
|
||||
|
||||
export const useCoopInfo = () => {
|
||||
|
||||
// Load data from localStorage on first use
|
||||
if (!isInitialized && process.client) {
|
||||
const saved = localStorage.getItem(STORAGE_KEY)
|
||||
if (saved) {
|
||||
try {
|
||||
const parsedData = JSON.parse(saved)
|
||||
coopInfo.value = { ...coopInfo.value, ...parsedData }
|
||||
} catch (error) {
|
||||
console.error('Error loading coop info:', error)
|
||||
}
|
||||
}
|
||||
isInitialized = true
|
||||
|
||||
// Set up watcher to save changes
|
||||
watch(
|
||||
coopInfo,
|
||||
(newData) => {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(newData))
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
}
|
||||
|
||||
// Helper function to update specific fields
|
||||
const updateCoopInfo = (updates: Partial<CoopInfo>) => {
|
||||
coopInfo.value = { ...coopInfo.value, ...updates }
|
||||
}
|
||||
|
||||
// Helper function to get display name (with fallback)
|
||||
const getDisplayName = () => {
|
||||
return coopInfo.value.cooperativeName || 'Worker Cooperative'
|
||||
}
|
||||
|
||||
// Helper function to get organization name for different contexts
|
||||
const getOrgName = () => {
|
||||
return coopInfo.value.cooperativeName || 'Organization'
|
||||
}
|
||||
|
||||
// Helper function to check if basic info is complete
|
||||
const isBasicInfoComplete = () => {
|
||||
return !!(coopInfo.value.cooperativeName && coopInfo.value.cooperativeName.trim())
|
||||
}
|
||||
|
||||
return {
|
||||
coopInfo: readonly(coopInfo),
|
||||
updateCoopInfo,
|
||||
getDisplayName,
|
||||
getOrgName,
|
||||
isBasicInfoComplete
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue