From f3c494cf58a8b0862490fcc0b38dde5fa01e439d Mon Sep 17 00:00:00 2001 From: unimatrix Date: Tue, 17 Nov 2026 22:19:49 +0000 Subject: [PATCH] Connect Company dashboard application counts and direct review navigation --- .../control-panel/public/cp-v2/cp-v2-organisation-shell.mjs | 3 ++- website/node/company-workspace.mjs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/website/control-panel/public/cp-v2/cp-v2-organisation-shell.mjs b/website/control-panel/public/cp-v2/cp-v2-organisation-shell.mjs index 6a020e31..a8ef2cdb 100644 --- a/website/control-panel/public/cp-v2/cp-v2-organisation-shell.mjs +++ b/website/control-panel/public/cp-v2/cp-v2-organisation-shell.mjs @@ -38,7 +38,7 @@ export function startOrganisationCP(kind){ const navigate={onMembers:()=>go('people'),onRequests:()=>go('applications')}; if(page==='overview'&&(!company&&!route()&&location.hash&& !location.hash.startsWith('#household/'))){const old=location.hash.slice(1).split('/').at(-1);if(old&&!['politics-overview','dashboard'].includes(old)){dispose=mountPoliticsPage(host,old);return;}} if(page==='overview'){ - host.append(createOrganisationDashboard({kind,organisation:{...record,tag:record.tag||record.slug||'REGISTERED',emblem:record.emblem||assets+fallback,homeworldName:record.homeworldName||(company?'Company register':'Political office'),titles:{officeholder:'Office deed holder'}},members:record.members||[],role:record.role==='Founder'||record.role==='CEO'?'owner':record.role,memberSummary:company?(record.memberCount==null?'Verified leadership':record.memberCount+' / '+record.memberLimit+' registered members'):undefined,loadMotd:record.role==='visitor'?undefined:async()=>(await loadSettings()).motd,activityStatus:'unavailable',links:{claims:'#'+prefix+'/claims'},...navigate})); + host.append(createOrganisationDashboard({kind,organisation:{...record,tag:record.tag||record.slug||'REGISTERED',emblem:record.emblem||assets+fallback,homeworldName:record.homeworldName||(company?'Company register':'Political office'),titles:{officeholder:'Office deed holder'}},members:record.members||[],canReview:company&&!!record.canReview,requests:company?record.requests||[]:[],role:record.role==='Founder'||record.role==='CEO'?'owner':record.role,memberSummary:company?(record.memberCount==null?'Verified leadership':record.memberCount+' / '+record.memberLimit+' registered members'):undefined,loadMotd:record.role==='visitor'?undefined:async()=>(await loadSettings()).motd,activityStatus:'unavailable',links:{claims:'#'+prefix+'/claims'},...navigate})); }else if(page==='settings'){ const sections=[['Identity & homeworld','Registered organisation identity.',record.name],['Message of the day','Organisation messages will use the shared service.',null],['Ownership deed & dynasty',company?'Company clan charter · COM keys.':'Protected political clan charter · political-clan keys. Political decision keys are separate.',record.membership?'Active office deed · ends '+new Date(record.membership.expiresAt).toLocaleString('en-GB'):'No new charter entitlement is inferred.'],['Claim charter & capacity','The shared claim model will be connected to this organisation.',null],['Relations & subhouses','The shared parent-deed mechanism will manage subordinate organisations.',null]].map(([title,description,text])=>({title,description,content:text?el('p',text):null,pending:!text}));host.append(createOrganisationSettings(sections));dispose=mountOrganisationEditor(host,{kind,id:record.id,onSaved:data=>Object.assign(record,{name:data.name,description:data.description,motd:data.motd})});if(company){const stopEditor=dispose,stopDeed=mountCompanyDeed(host,{id:record.id,onChanged:()=>location.reload()});dispose=()=>{stopEditor();stopDeed();};}const note=el('p',company?'COM clan keys belong to company charters.':'Political-clan keys belong to protected organisation deeds; POL decision keys remain separate.');host.append(note); Promise.resolve().then(async()=>{const r=await fetch('/api/organisation-keys',{credentials:'same-origin',cache:'no-store'});if(!r.ok)throw Error();const data=await r.json();if(turn!==generation||stopped)return;const rows=(data.keys||[]).filter(k=>company?k.type==='company':k.type==='politics-clan');const box=el('section',undefined,'organisation-settings-card');box.append(el('h3',noun+' clan keys'));for(const key of rows){box.append(el('p',key.status+(key.code?' · '+key.code:'')));}if(!rows.length)box.append(el('p','No organisation-clan keys are present in your private register.'));host.append(box);}).catch(()=>{if(turn===generation)note.append(el('span',' The private key register is unavailable.'));}); @@ -47,6 +47,7 @@ export function startOrganisationCP(kind){ else if(!company&&page==='campaigns')dispose=mountPoliticsPage(host,'house-elections'); else if(page==='commerce'){dispose=mountExchangeDesign(host,{context:'clan',organisationScope:{kind,id:record.id}});} + else if(company&&page==='applications'){dispose=mountExchangeDesign(host,{context:'clan',view:'applications',organisationScope:{kind,id:record.id}});} else if(company&&page==='people'){dispose=mountCompanyRoster(host,{record,onChanged:action=>{if(action==='leave'){const url=new URL(location.href);url.searchParams.delete('company');url.hash='company/overview';location.assign(url.href);}else location.reload();}});} else if(page==='people'||page==='applications'){pending(host,'Members & applications',company?'Company recruitment applications will use the shared J.A.R.V.I.S. flow.':'Only verified current officeholders are automatically linked to this protected House.');for(const m of record.members||[])host.append(el('p',m.name||m.username));} else pending(host,groups.flatMap(([,items])=>items).find(([id])=>id===page)?.[1]||noun+' workspace','The shared component is prepared; organisation-specific authority and data must be connected before actions are enabled.'); diff --git a/website/node/company-workspace.mjs b/website/node/company-workspace.mjs index 4120b551..94ae9538 100644 --- a/website/node/company-workspace.mjs +++ b/website/node/company-workspace.mjs @@ -11,7 +11,7 @@ export function createCompanyWorkspace(db,{authenticate=request=>identity(reques const extra=db.companyDeedsEnabled?' OR EXISTS(SELECT 1 FROM site_company_members m WHERE m.company_id=c.id AND m.user_id=?)':''; const {results=[]}=await db.prepare('SELECT c.id,c.slug,c.name,c.description,c.status,c.founded_by,c.ceo_account_id,a.username ceo_name,f.username founder_name FROM corrino_companies c LEFT JOIN site_accounts a ON a.id=c.ceo_account_id LEFT JOIN site_accounts f ON f.id=c.founded_by WHERE ('+ownerSource+' OR c.ceo_account_id=?'+extra+')'+(db.companyDeedsEnabled?" AND c.status IN ('active','pending')":'')+' ORDER BY c.name LIMIT 100').bind(user.id,user.id,...(db.companyDeedsEnabled?[user.id]:[])).all(); let companies=results.map(({founded_by,ceo_account_id,...company})=>({...company,role:founded_by===user.id?'Founder':'CEO'})); - if(db.companyDeedsEnabled)companies=await Promise.all(companies.map(async c=>({...c,...companyDeedView(await readCompanyDeed(db,c.id),user.id)}))); + if(db.companyDeedsEnabled)companies=await Promise.all(companies.map(async c=>{const view=companyDeedView(await readCompanyDeed(db,c.id),user.id),requests=view.canManage?(await db.prepare("SELECT a.username FROM site_company_requests r JOIN site_jarvis_company_applications j ON j.company_id=r.company_id AND j.user_id=r.user_id JOIN site_accounts a ON a.id=r.user_id WHERE r.company_id=? AND r.status='pending' ORDER BY r.created_at LIMIT 101").bind(c.id).all()).results:[];return{...c,...view,canReview:view.canManage,requests};})); if(id&&!companies.some(c=>c.id===id))return reply({message:'This company is not available to your account.'},404); return reply({companies,selected:id||companies[0]?.id||null}); };}