Reuse SPost and Corrino Group attribution on code office

This commit is contained in:
unimatrixgit 2026-11-16 20:39:20 +01:00
commit c4226e6249
3 changed files with 8 additions and 2 deletions

View file

@ -28,3 +28,7 @@ export function createCodeRedemption(){
inspect.onclick=()=>{if(locked)return;try{reviewed=describeRedemption(input.value);check.checked=false;badge.className='reward-kind reward-kind-'+reviewed.kind;badge.textContent=reviewed.available?'Ready to submit':'Dedicated route';title.textContent=reviewed.title;effect.textContent=reviewed.description;submit.textContent=reviewed.action;submit.hidden=!reviewed.available;consent.hidden=!reviewed.available;destination.hidden=!reviewed.href;if(reviewed.href){destination.href=reviewed.href;destination.textContent=reviewed.action;}verification.textContent=reviewed.available?'Format recognised. Ownership and eligibility are checked when you submit.':reviewed.href?'Continue in the dedicated workshop to choose your kit.':'This route is being connected. Your code has not been used.';preview.hidden=false;result.textContent='';sync();}catch(error){invalidate();result.textContent=error.message;input.focus();}};
return {root,form,input,check,submit,result,setLocked(value){locked=!!value;sync();},reset(){form.reset();invalidate();},reviewedCode(){if(!reviewed?.available||describeRedemption(input.value).code!==reviewed.code||!check.checked)throw Error('Review your code and confirm the action first.');return reviewed.code;}};
}
export function createCodeOfficeBranding(){
const footer=el('footer',undefined,'code-office-provider'),brands=el('div',undefined,'code-office-provider-brands'),logo=el('img');logo.src='https://www.dunerealms.com/assets/spost-logo-v1.svg';logo.alt='SPost';logo.width=130;logo.height=43;const group=el('a');group.href='https://www.dunerealms.com/corrino-group.html';const art=el('img');art.src='https://www.dunerealms.com/assets/corrino-group-v4.png';art.alt='Corrino Group';art.width=116;art.height=42;group.append(el('span','part of'),art);brands.append(logo,group);footer.append(el('span','Code services provided by'),brands);return footer;
}

View file

@ -1,5 +1,5 @@
import {createCPV2Page,element as el} from './cp-v2-page-template.mjs';
import {createCodeRedemption} from './cp-v2-code-redemption.mjs';
import {createCodeRedemption,createCodeOfficeBranding} from './cp-v2-code-redemption.mjs';
import {createUserAPI} from './cp-v2-user-api.mjs';
import {kitReceiptStatus,groupKitReceipts} from '../kit-receipt-status.mjs';
@ -21,7 +21,7 @@ export function mountRewards(host,{fetcher=fetch,initialTab}={}){
function setCodes(kind,title,rows){groups.set(kind,{title,rows:rows.length?rows:[[title+' register','—','No records','—']]});paintCodes();}
for(const [kind,title] of [['clan','Clan founding'],['company','Company founding']]){const action=el('button','Use founding code — coming soon');action.type='button';action.disabled=true;setCodes(kind,title,[[title+' code · '+(kind==='clan'?'CLAN-…':'COM-…'),'Once per account','Not issued — preview',action]]);}for(const [kind,title] of [['kit','Kit'],['token','Upgrade Token'],['community','Community reward']])setCodes(kind,title,[[title+' register','—','Loading…','—']]);filter.oninput=typeFilter.onchange=paintCodes;const tailor=el('a','Apply Upgrade Tokens in Imperial Tailor →');tailor.href='#realm/kits-exchange';directory.append(tailor);directory.append(el('p','Founding codes are coming soon. New formats: KIT-…, UP-…, CLAN-… and COM-…. Existing DRK/DRU codes remain valid.','reward-code-note'));
const desk=createCodeRedemption(),{form,input,check,result}=desk,redemption=desk.root;
const {root,activate}=createCPV2Page({shellHost:host,title:'Codes & founding rights',description:'Your private rewards, founding rights and political appointments.',artwork:'imperial-seal-128.png',tabs:[{id:'unclaimed-codes',label:'Your codes',content:codes},{id:'redeem',label:'Redeem a code',content:redemption}]});host.replaceChildren(root);redemption.addEventListener('show-code-register',()=>activate('unclaimed-codes'));if(initialTab==='redeem')activate(initialTab);
const {root,activate}=createCPV2Page({shellHost:host,title:'Codes & founding rights',description:'Your private rewards, founding rights and political appointments.',artwork:'imperial-seal-128.png',tabs:[{id:'unclaimed-codes',label:'Your codes',content:codes},{id:'redeem',label:'Redeem a code',content:redemption}]});root.append(createCodeOfficeBranding());host.replaceChildren(root);redemption.addEventListener('show-code-register',()=>activate('unclaimed-codes'));if(initialTab==='redeem')activate(initialTab);
function codeCell(code,command=false){const details=el('details');details.append(el('summary',command?'Show private command':'Show private code'),el('code',code));const copy=el('button','Copy');copy.type='button';copy.onclick=async()=>{try{await navigator.clipboard.writeText(code);if(active)copy.textContent='Copied';}catch{if(active)copy.textContent='Select and copy the code above';}};details.append(copy);return details;}
function render(){setCodes('kit','Kit',privateKitCodes(orders).map(row=>[row.name,row.orderId,kitReceiptStatus(row).label,codeCell(row.code)]));}
async function load(){if(busy)return;busy=true;refresh.disabled=true;desk.setLocked(true);status.textContent='Loading current private entitlements…';

View file

@ -253,3 +253,5 @@
.code-redemption{display:grid;gap:24px;min-width:0}.code-redemption-layout{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(240px,1fr);gap:24px;align-items:start}.code-redemption-card{min-width:0;padding:26px;border:1px solid #9e8b53;border-radius:16px;background:linear-gradient(135deg,#193c31f5,#102820f5)}.code-redemption fieldset{min-width:0;margin:0;padding:0;border:0}.code-redemption legend{font-size:20px;font-weight:700;color:#efd28b;margin-bottom:20px}.code-redemption label{display:grid;gap:10px}.code-redemption input[type=text]{box-sizing:border-box;width:100%;min-width:0;padding:16px;font-family:monospace;font-size:16px;letter-spacing:.04em;border:1px solid #b59a58;border-radius:8px;background:#0c241e;color:#f5e5bb}.code-redemption input:focus-visible,.code-redemption button:focus-visible,.code-redemption a:focus-visible{outline:2px solid #f0cc74;outline-offset:4px}.code-redemption p{line-height:1.65;overflow-wrap:anywhere}.code-redemption h5{font-size:23px;line-height:1.3;color:#efd28b;margin:16px 0}.code-redemption-muted{color:#bdcfc2;font-size:14px}.code-redemption .code-redemption-preview{margin-top:28px;padding-top:24px;border-top:1px solid #776b42}.code-redemption .code-redemption-consent{display:flex;align-items:flex-start;gap:12px;margin:24px 0}.code-redemption-consent input{flex:0 0 auto;margin-top:5px}.code-redemption button{min-height:44px;padding:12px 20px;border:1px solid #d8ba6d;border-radius:8px;background:linear-gradient(#c5a653,#9d813e);color:#10271f;font-weight:700;cursor:pointer}.code-redemption button:disabled{opacity:.5;cursor:not-allowed}.code-redemption-guide>small{letter-spacing:.12em;color:#d7bb76}.code-redemption-guide-item{padding:18px 0;border-bottom:1px solid #6a684249}.code-redemption-guide-item:last-of-type{margin-bottom:20px}.code-redemption-guide-item p{margin-bottom:0;font-size:14px}.code-redemption-result:empty{display:none}.code-redemption-result{padding:14px;border-left:3px solid #d7bb76;background:#0c241e}.reward-kind-politics{color:#dcb9e7}.code-redemption [hidden]{display:none!important}@media(max-width:850px){.code-redemption-layout{grid-template-columns:minmax(0,1fr)}.code-redemption-card{padding:20px}}@media(max-width:450px){.code-redemption-card{padding:16px}.code-redemption .reward-code-banner{align-items:flex-start}.code-redemption input[type=text]{font-size:16px;padding:12px}.code-redemption button{width:100%}}
.code-redemption a{color:#efd28b;text-underline-offset:3px}
.code-office-provider{display:flex;justify-content:center;align-items:center;gap:28px;flex-wrap:wrap;padding:26px 18px;margin:24px 0 0;border-top:1px solid #a28b4d;background:#0b2118;color:#bdc9bd}.code-office-provider-brands{display:flex;align-items:center;gap:22px;flex-wrap:wrap}.code-office-provider img{object-fit:contain;max-width:100%}.code-office-provider a{display:flex;align-items:center;gap:12px;border-left:1px solid #6f704252;padding-left:22px;text-decoration:none;color:#efd28b}.code-office-provider a span{font-size:11px}@media(max-width:450px){.code-office-provider{gap:16px}.code-office-provider-brands{justify-content:center;gap:14px}.code-office-provider a{padding-left:14px}}