Special orders as a launch feature tile; institution sign-ups go to the sheet
- Special orders is now a coming-at-launch tile; form and its sheet code removed - B2B section gets a sign-up form (institution, type, contact, phone, email, usual orders) - Apps Script writes institution sign-ups to an "Institutions" tab and emails NOTIFY; pre-filled email fallback until ENDPOINT is set Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
53a9de007e
commit
d67fdb33af
|
|
@ -12,10 +12,6 @@ Deploy it to any static host (Vercel, Netlify, nginx) with the repo root as the
|
|||
|
||||
The form takes a phone number (SMS, the default) or an email, then asks for a name. Signups go to a Google Sheet through `tools/waitlist-apps-script.gs`, which also emails a notification for each one. Until `ENDPOINT` in `index.html` is set, signups are only saved in the visitor's browser.
|
||||
|
||||
## Special orders
|
||||
|
||||
The special order form (item, quantity, name, phone, notes) posts to the same Apps Script endpoint with `type: 'special'`, which writes to a "Special orders" tab and emails `NOTIFY`. Until `ENDPOINT` is set, the request opens as a pre-filled WhatsApp message to `+251 930 099 850`. Redeploy the Apps Script after pulling this change.
|
||||
|
||||
## B2B onboarding
|
||||
|
||||
Institutions reach Gishen by calling `+251 930 099 850` or emailing `b2b@gishenpharmacy.org`. The email link comes with a pre-filled template. Setting up the inbox is tracked in [TASKS.md](TASKS.md).
|
||||
Institutions sign up through the form in the B2B section (institution, type, contact person, phone, optional email and usual orders). It posts to the same Apps Script endpoint with `type: 'b2b'`, which adds a row to an "Institutions" tab and emails `NOTIFY`. Until `ENDPOINT` is set, the form opens a pre-filled email to `b2b@gishenpharmacy.org` instead. Institutions can also call `+251 930 099 850`. Setting up the inbox is tracked in [TASKS.md](TASKS.md).
|
||||
|
|
|
|||
144
index.html
144
index.html
|
|
@ -174,25 +174,6 @@
|
|||
@keyframes slide { to { transform: translateX(-50%); } }
|
||||
@media (max-width: 600px) { .catalog .count span { display: none; } }
|
||||
|
||||
/* ---------- special orders ---------- */
|
||||
.special { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 5vw, 72px); align-items: start; }
|
||||
.steps3 { list-style: none; counter-reset: s; margin: 32px 0 0; padding: 0; display: grid; gap: 18px; }
|
||||
.steps3 li { counter-increment: s; display: flex; gap: 14px; align-items: flex-start; color: var(--ink-2); }
|
||||
.steps3 li::before { content: counter(s); flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: rgba(168, 199, 58, .14); color: var(--lime); font-weight: 700; font-size: 14px; }
|
||||
.steps3 b { display: block; color: var(--ink); }
|
||||
.sform { padding: clamp(20px, 3vw, 32px); border-radius: 28px; background: var(--raise); border: 1px solid var(--line); display: grid; gap: 14px; }
|
||||
.sform label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
|
||||
.sform label small { font-weight: 500; color: var(--ink-3); }
|
||||
.sform input, .sform textarea { width: 100%; min-height: 50px; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--field); font: inherit; font-size: 16px; color: var(--ink); outline: none; resize: vertical; }
|
||||
.sform input:focus, .sform textarea:focus { border-color: var(--line-2); box-shadow: 0 0 0 4px rgba(168, 199, 58, .1); }
|
||||
.sform .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
|
||||
.sform .btn { width: 100%; }
|
||||
.sform .fine, .sform .err { margin: 0; }
|
||||
.sform .alt { text-align: center; font-size: 14px; color: var(--ink-3); margin: 0; }
|
||||
.sform .alt a { color: var(--ink-2); font-weight: 600; text-underline-offset: 3px; }
|
||||
@media (max-width: 860px) { .special { grid-template-columns: 1fr; } }
|
||||
@media (max-width: 460px) { .sform .two { grid-template-columns: 1fr; } }
|
||||
|
||||
/* ---------- stats ---------- */
|
||||
.stats { border-block: 1px solid var(--line); background: var(--raise); }
|
||||
.stats .wrap { display: grid; grid-template-columns: repeat(4, 1fr); }
|
||||
|
|
@ -220,6 +201,11 @@
|
|||
.t-lead h3 { font-size: clamp(26px, 3vw, 36px); max-width: 16ch; }
|
||||
.t-a { grid-column: span 2; } .t-b { grid-column: span 2; }
|
||||
.t-c { grid-column: span 2; } .t-d { grid-column: span 2; } .t-e { grid-column: span 2; }
|
||||
.t-wide { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 24px; }
|
||||
.t-wide h3 { margin: 14px 0 0; }
|
||||
.t-wide p { max-width: 52ch; }
|
||||
.t-wide .chip-row { justify-content: flex-end; max-width: 420px; }
|
||||
@media (max-width: 760px) { .t-wide { grid-template-columns: 1fr; } .t-wide .chip-row { justify-content: flex-start; } }
|
||||
.shelf { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 28px; }
|
||||
.shelf div { aspect-ratio: 1; border-radius: 16px; background: #fff; padding: 12%; transition: transform 400ms var(--ease-out); }
|
||||
.shelf div:nth-child(even) { transform: translateY(18px); }
|
||||
|
|
@ -232,7 +218,7 @@
|
|||
.chip img { height: 18px; width: auto; }
|
||||
.t-lime .chip { border-color: rgba(16, 20, 16, .25); color: var(--lime-ink); }
|
||||
.icon-lg { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: rgba(168, 199, 58, .14); color: var(--lime); }
|
||||
@media (max-width: 960px) { .bento { grid-template-columns: 1fr 1fr; } .t-lead { grid-column: span 2; grid-row: auto; } .t-a, .t-b, .t-c, .t-d, .t-e { grid-column: span 1; } }
|
||||
@media (max-width: 960px) { .bento { grid-template-columns: 1fr 1fr; } .t-lead { grid-column: span 2; grid-row: auto; } .t-a, .t-b, .t-c, .t-d, .t-e { grid-column: span 1; } .t-wide { grid-column: 1 / -1; } }
|
||||
@media (max-width: 600px) { .bento { grid-template-columns: 1fr; } .t-lead, .t-a, .t-b, .t-c, .t-d, .t-e { grid-column: auto; } .shelf { grid-template-columns: repeat(4, 1fr); gap: 8px; } }
|
||||
|
||||
/* ---------- B2B ---------- */
|
||||
|
|
@ -244,12 +230,23 @@
|
|||
.b2b ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
|
||||
.b2b li { display: flex; gap: 12px; align-items: flex-start; font-size: 16px; font-weight: 500; }
|
||||
.b2b li svg { flex: none; margin-top: 2px; }
|
||||
.reach { position: relative; z-index: 1; align-self: center; display: grid; gap: 12px; }
|
||||
.reach a { display: flex; align-items: center; gap: 16px; padding: 20px 22px; border-radius: 22px; background: var(--lime-ink); color: var(--ink); text-decoration: none; transition: transform 200ms var(--ease-out), background 200ms; }
|
||||
.reach { position: relative; z-index: 1; display: grid; gap: 10px; }
|
||||
.bform { padding: clamp(20px, 3vw, 28px); border-radius: 24px; background: var(--lime-ink); color: var(--ink); display: grid; gap: 12px; }
|
||||
.bform h3 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.01em; }
|
||||
.bform label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
|
||||
.bform label small { display: inline; font-size: inherit; font-weight: 500; color: var(--ink-3); }
|
||||
.bform input, .bform select, .bform textarea { width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--field); font: inherit; font-size: 16px; color: var(--ink); outline: none; resize: vertical; }
|
||||
.bform input:focus, .bform select:focus, .bform textarea:focus { border-color: var(--line-2); box-shadow: 0 0 0 4px rgba(168, 199, 58, .12); }
|
||||
.bform .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
|
||||
.bform .btn { width: 100%; margin-top: 4px; }
|
||||
.bform .err { margin: 0; }
|
||||
@media (max-width: 460px) { .bform .two { grid-template-columns: 1fr; } }
|
||||
.reach .alt { display: grid; gap: 10px; }
|
||||
.reach a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 18px; background: var(--lime-ink); color: var(--ink); text-decoration: none; transition: transform 200ms var(--ease-out), background 200ms; }
|
||||
.reach a:hover { transform: translateY(-2px); background: #1A2218; }
|
||||
.reach .ic { flex: none; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--lime); color: var(--lime-ink); }
|
||||
.reach .ic { flex: none; width: 38px; height: 38px; border-radius: 14px; display: grid; place-items: center; background: var(--lime); color: var(--lime-ink); }
|
||||
.reach small { display: block; color: var(--ink-3); font-size: 13px; font-weight: 500; }
|
||||
.reach strong { display: block; font-size: clamp(17px, 1.8vw, 21px); letter-spacing: -.01em; word-break: break-word; }
|
||||
.reach strong { display: block; font-size: 15px; overflow-wrap: anywhere; letter-spacing: -.01em; word-break: break-word; }
|
||||
.reach .arrow { margin-left: auto; color: var(--lime); flex: none; }
|
||||
.reach p { margin: 4px 4px 0; font-size: 14px; color: #2B3520; }
|
||||
@media (max-width: 860px) { .b2b { grid-template-columns: 1fr; } }
|
||||
|
|
@ -297,7 +294,6 @@
|
|||
<a class="brand" href="#" aria-label="Gishen Pharmacy home"><img src="/brand/gishen-logo.png" alt="Gishen Pharmacy — ግሸን መድሃኒት ቤት" width="500" height="117" /></a>
|
||||
<nav class="links" aria-label="Sections">
|
||||
<a href="#coming">What's coming</a>
|
||||
<a href="#special">Special orders</a>
|
||||
<a href="#b2b">For institutions</a>
|
||||
<a href="#branches">Branches</a>
|
||||
<a href="#faq">FAQ</a>
|
||||
|
|
@ -360,7 +356,7 @@
|
|||
<p class="err" id="err" role="alert"></p>
|
||||
</form>
|
||||
</div>
|
||||
<p class="b2b-nudge">Can't find a medicine? <a href="#special">Request a special order</a> · Hospital or clinic? <a href="#b2b">Onboard as B2B</a></p>
|
||||
<p class="b2b-nudge">Hospital, clinic or company? <a href="#b2b">Get onboarded as a B2B partner</a></p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
|
@ -420,45 +416,25 @@
|
|||
<h3>Loyalty that adds up</h3>
|
||||
<p>Earn points and vouchers on every order, online or in a branch.</p>
|
||||
</article>
|
||||
<article class="tile t-wide reveal">
|
||||
<div>
|
||||
<div class="icon-lg"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.3-4.3"/><path d="M11 8v6M8 11h6"/></svg></div>
|
||||
<h3>Special orders: can't find it? We'll source it.</h3>
|
||||
<p>Request a medicine or strength that's hard to find. A pharmacist sources it through our suppliers and calls you with the price and timing.</p>
|
||||
</div>
|
||||
<div class="chip-row"><span class="chip">Hard-to-find medicines</span><span class="chip">Specific strengths</span><span class="chip">Bulk quantities</span><span class="chip">Pharmacist call-back</span></div>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="block" id="special" style="scroll-margin-top: 24px">
|
||||
<div class="wrap special">
|
||||
<div>
|
||||
<span class="kicker reveal">Special orders</span>
|
||||
<h2 class="reveal">Can't find it? <em>We'll source it.</em></h2>
|
||||
<p class="intro reveal">Looking for a medicine, strength or supply that's hard to find in Addis? Tell us what you need. Our pharmacists will track it down through our suppliers.</p>
|
||||
<ol class="steps3 reveal">
|
||||
<li><span><b>Tell us what you need</b>Product name, strength and how many.</span></li>
|
||||
<li><span><b>A pharmacist confirms</b>We call you back with availability, price and timing.</span></li>
|
||||
<li><span><b>Pick up or get it delivered</b>From your nearest branch, or to your door.</span></li>
|
||||
</ol>
|
||||
</div>
|
||||
<form class="sform reveal" id="sform" novalidate>
|
||||
<label>Medicine or product<input id="sItem" name="item" maxlength="200" placeholder="e.g. Insulin glargine 100 IU/ml" required /></label>
|
||||
<div class="two">
|
||||
<label><span>Strength or quantity <small>(optional)</small></span><input id="sQty" name="qty" maxlength="100" placeholder="e.g. 3 pens" /></label>
|
||||
<label>Your name<input id="sName" name="name" autocomplete="name" maxlength="120" placeholder="Full name" required /></label>
|
||||
</div>
|
||||
<label>Phone number<input id="sPhone" name="phone" type="tel" inputmode="tel" autocomplete="tel" placeholder="0911 234 567" required /></label>
|
||||
<label><span>Notes <small>(optional)</small></span><textarea id="sNotes" name="notes" rows="3" maxlength="500" placeholder="Brand preference, prescription details, when you need it"></textarea></label>
|
||||
<label class="hp" aria-hidden="true">Company <input id="sCompany" tabindex="-1" autocomplete="off" /></label>
|
||||
<button class="btn" id="sSubmit" type="submit">Send request</button>
|
||||
<p class="err" id="sErr" role="alert"></p>
|
||||
<p class="alt">Prescription item? <a href="https://wa.me/251930099850" rel="noopener" target="_blank">Send a photo on WhatsApp</a></p>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="block" id="b2b" style="scroll-margin-top: 24px">
|
||||
<div class="wrap">
|
||||
<div class="b2b reveal">
|
||||
<div>
|
||||
<span class="kicker">For institutions</span>
|
||||
<h2>Supplying a hospital, clinic or company? <em>Let's onboard you.</em></h2>
|
||||
<p class="intro">146+ institutions already buy from Gishen. Our B2B portal opens alongside the store. Call or email us now and your account will be ready on day one.</p>
|
||||
<p class="intro">146+ institutions already buy from Gishen. Our B2B portal opens alongside the store. Sign up now and your account will be ready on day one.</p>
|
||||
<ul>
|
||||
<li><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>Bulk orders and quick reorders for medicines and medical supplies</li>
|
||||
<li><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>Team accounts with purchase approvals</li>
|
||||
|
|
@ -467,17 +443,33 @@
|
|||
</ul>
|
||||
</div>
|
||||
<div class="reach">
|
||||
<form class="bform" id="bform" novalidate>
|
||||
<h3>Sign up your institution</h3>
|
||||
<label>Institution name<input id="bOrg" maxlength="160" autocomplete="organization" placeholder="e.g. Bethel Clinic" required /></label>
|
||||
<div class="two">
|
||||
<label>Type<select id="bType"><option>Hospital</option><option>Clinic</option><option>Company</option><option>NGO</option><option>Pharmacy</option><option>Other</option></select></label>
|
||||
<label>Contact person<input id="bName" maxlength="120" autocomplete="name" placeholder="Full name" required /></label>
|
||||
</div>
|
||||
<div class="two">
|
||||
<label>Phone<input id="bPhone" type="tel" inputmode="tel" autocomplete="tel" placeholder="0911 234 567" required /></label>
|
||||
<label><span>Email <small>(optional)</small></span><input id="bEmail" type="email" autocomplete="email" maxlength="200" placeholder="you@institution.org" /></label>
|
||||
</div>
|
||||
<label><span>What you usually order <small>(optional)</small></span><textarea id="bOrders" rows="2" maxlength="500" placeholder="e.g. gloves, IV fluids, antibiotics, monthly"></textarea></label>
|
||||
<label class="hp" aria-hidden="true">Company <input id="bCompany" tabindex="-1" autocomplete="off" /></label>
|
||||
<button class="btn" id="bSubmit" type="submit">Request onboarding</button>
|
||||
<p class="err" id="bErr" role="alert"></p>
|
||||
</form>
|
||||
<div class="alt">
|
||||
<a href="tel:+251930099850">
|
||||
<span class="ic"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M22 16.9v3a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2.1 4.2 2 2 0 0 1 4.1 2h3a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.7a2 2 0 0 1-.5 2.1L8 9.8a16 16 0 0 0 6 6l1.3-1.3a2 2 0 0 1 2.1-.4c.9.3 1.8.6 2.7.7a2 2 0 0 1 1.7 2z"/></svg></span>
|
||||
<span><small>Call us</small><strong>+251 930 099 850</strong></span>
|
||||
<svg class="arrow" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14M13 6l6 6-6 6"/></svg>
|
||||
<span><small>Or call</small><strong>+251 930 099 850</strong></span>
|
||||
</a>
|
||||
<a id="b2bMail" href="mailto:b2b@gishenpharmacy.org?subject=B2B%20onboarding%20%E2%80%94%20%5BInstitution%20name%5D&body=Hello%20Gishen%20team%2C%0A%0AWe%20would%20like%20to%20be%20onboarded%20as%20a%20B2B%20customer.%0A%0AInstitution%20name%3A%0AType%20(hospital%2C%20clinic%2C%20company%2C%20NGO)%3A%0AContact%20person%3A%0APhone%3A%0AWhat%20we%20usually%20order%3A%0A%0AThank%20you.">
|
||||
<span class="ic"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="2" y="4" width="20" height="16" rx="2"/><path d="M22 7l-10 6L2 7"/></svg></span>
|
||||
<span><small>Email to get onboarded</small><strong>b2b@gishenpharmacy.org</strong></span>
|
||||
<svg class="arrow" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14M13 6l6 6-6 6"/></svg>
|
||||
<span><small>Or email</small><strong>b2b@gishenpharmacy.org</strong></span>
|
||||
</a>
|
||||
<p>Tell us your institution's name, a contact person and what you usually order. We'll reply within one working day.</p>
|
||||
</div>
|
||||
<p>We'll reply within one working day.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -509,7 +501,7 @@
|
|||
<details open><summary>When does the online store open?</summary><p>We're in the final stretch. Everyone on the waitlist hears first, by SMS or email, the day orders open.</p></details>
|
||||
<details><summary>Can I order prescription medicines?</summary><p>Yes. Upload a photo of your prescription and a licensed Gishen pharmacist reviews it before your order is prepared.</p></details>
|
||||
<details><summary>Where do you deliver?</summary><p>We start across Addis Ababa, delivering from our seven branches. You can also pick up from your nearest branch.</p></details>
|
||||
<details><summary>What if you don't stock what I need?</summary><p>Use the <a href="#special">special order form</a>. A pharmacist will source it through our suppliers and call you with the price and timing before anything is ordered.</p></details>
|
||||
<details><summary>What if you don't stock what I need?</summary><p>When we launch, you can place a special order in the app. A pharmacist sources it through our suppliers and calls you with the price and timing before anything is ordered.</p></details>
|
||||
<details><summary>How do institutions get onboarded?</summary><p>Call +251 930 099 850 or email <a href="mailto:b2b@gishenpharmacy.org">b2b@gishenpharmacy.org</a> with your institution's details. We'll set up your B2B account before launch.</p></details>
|
||||
<details><summary>What do you do with my details?</summary><p>We use them only to tell you when we open. We never sell or share them, and we'll delete them whenever you ask.</p></details>
|
||||
</div>
|
||||
|
|
@ -676,31 +668,31 @@
|
|||
}
|
||||
});
|
||||
|
||||
// Special orders: rows go to the "Special orders" sheet. Without an ENDPOINT the request opens in WhatsApp instead, so nothing is lost.
|
||||
const sform = $('sform'), sErr = $('sErr'), sBtn = $('sSubmit');
|
||||
sform.addEventListener('submit', async (e) => {
|
||||
e.preventDefault(); sErr.textContent = '';
|
||||
// Institution sign-ups go to the "Institutions" tab. Without an ENDPOINT the details open as a pre-filled email instead.
|
||||
const bform = $('bform'), bErr = $('bErr'), bBtn = $('bSubmit');
|
||||
bform.addEventListener('submit', async (e) => {
|
||||
e.preventDefault(); bErr.textContent = '';
|
||||
const v = (id) => $(id).value.trim();
|
||||
const phone = normPhone(v('sPhone'), 'ET');
|
||||
const bad = [['sItem', v('sItem').length < 2, 'Tell us which medicine or product you need.'], ['sName', v('sName').length < 2, 'Please enter your name.'], ['sPhone', !phone, 'Please enter a phone number, e.g. 0911 234 567, or +country code.']];
|
||||
bad.forEach(([id, b]) => $(id).setAttribute('aria-invalid', String(b)));
|
||||
const phone = normPhone(v('bPhone'), 'ET'), email = v('bEmail').toLowerCase();
|
||||
const bad = [['bOrg', v('bOrg').length < 2, "Please enter your institution's name."], ['bName', v('bName').length < 2, 'Please enter a contact person.'], ['bPhone', !phone, 'Please enter a phone number, e.g. 0911 234 567, or +country code.'], ['bEmail', email && !emailOk(email), 'Please check the email, or leave it empty.']];
|
||||
bad.forEach(([id, b]) => $(id).setAttribute('aria-invalid', String(!!b)));
|
||||
const first = bad.find(([, b]) => b);
|
||||
if (first) { sErr.textContent = first[2]; $(first[0]).focus(); return; }
|
||||
const data = { type: 'special', item: v('sItem'), qty: v('sQty'), name: v('sName'), phone, notes: v('sNotes'), company: $('sCompany').value, page: location.href, createdAt: new Date().toISOString() };
|
||||
if (first) { bErr.textContent = first[2]; $(first[0]).focus(); return; }
|
||||
const data = { type: 'b2b', institution: v('bOrg'), kind: $('bType').value, name: v('bName'), phone, email, orders: v('bOrders'), company: $('bCompany').value, page: location.href };
|
||||
if (!ENDPOINT) {
|
||||
const msg = `Special order request\nItem: ${data.item}${data.qty ? `\nQuantity: ${data.qty}` : ''}\nName: ${data.name}\nPhone: ${phone}${data.notes ? `\nNotes: ${data.notes}` : ''}`;
|
||||
open('https://wa.me/251930099850?text=' + encodeURIComponent(msg), '_blank', 'noopener');
|
||||
const body = `Hello Gishen team,\n\nWe would like to be onboarded as a B2B customer.\n\nInstitution: ${data.institution}\nType: ${data.kind}\nContact person: ${data.name}\nPhone: ${phone}${email ? `\nEmail: ${email}` : ''}${data.orders ? `\nWhat we usually order: ${data.orders}` : ''}\n\nThank you.`;
|
||||
location.href = `mailto:b2b@gishenpharmacy.org?subject=${encodeURIComponent('B2B onboarding: ' + data.institution)}&body=${encodeURIComponent(body)}`;
|
||||
return;
|
||||
}
|
||||
sBtn.disabled = true;
|
||||
bBtn.disabled = true;
|
||||
try {
|
||||
const res = await fetch(ENDPOINT, { method: 'POST', headers: { 'Content-Type': 'text/plain;charset=utf-8' }, body: JSON.stringify(data) });
|
||||
const out = await res.json().catch(() => ({}));
|
||||
if (!res.ok || !out.ok) throw new Error(out.error || res.status);
|
||||
sform.innerHTML = `<div class="done" role="status"><div class="tick"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg></div><div><h3>Request received.</h3><p>A Gishen pharmacist will call you within one working day.</p></div></div>`;
|
||||
bform.innerHTML = `<div class="done" role="status"><div class="tick"><svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg></div><div><h3>Thanks, ${data.institution.replace(/[<>&"]/g, '')} is signed up.</h3><p>Our B2B team will call you within one working day.</p></div></div>`;
|
||||
} catch {
|
||||
sErr.textContent = 'Something went wrong. Please try again, or call us on +251 930 099 850.';
|
||||
sBtn.disabled = false;
|
||||
bErr.textContent = 'Something went wrong. Please try again, or call us on +251 930 099 850.';
|
||||
bBtn.disabled = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -18,20 +18,23 @@ function doGet() {
|
|||
return json_({ count: Math.max(sheet_().getLastRow() - 1, 0) });
|
||||
}
|
||||
|
||||
const SPECIAL_HEADERS = ['createdAt', 'item', 'qty', 'name', 'phone', 'notes', 'page', 'status'];
|
||||
const B2B_HEADERS = ['createdAt', 'institution', 'type', 'contact', 'phone', 'email', 'orders', 'page', 'status'];
|
||||
const B2B_TYPES = ['Hospital', 'Clinic', 'Company', 'NGO', 'Pharmacy', 'Other'];
|
||||
|
||||
// Special order requests live on their own tab, so the waitlist count (first tab) stays right.
|
||||
function special_(d) {
|
||||
const item = String(d.item || '').trim().slice(0, 200);
|
||||
// Institution sign-ups live on their own tab, so the waitlist count (first tab) stays right.
|
||||
function b2b_(d) {
|
||||
const org = String(d.institution || '').trim().slice(0, 160);
|
||||
const name = String(d.name || '').trim().slice(0, 120);
|
||||
const phone = /^\+\d{8,15}$/.test(d.phone || '') ? d.phone : '';
|
||||
if (item.length < 2 || name.length < 2 || !phone) return json_({ ok: false, error: 'invalid' });
|
||||
const email = /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(d.email || '') ? String(d.email).toLowerCase().slice(0, 200) : '';
|
||||
if (org.length < 2 || name.length < 2 || !phone) return json_({ ok: false, error: 'invalid' });
|
||||
const kind = B2B_TYPES.includes(d.kind) ? d.kind : 'Other';
|
||||
const orders = String(d.orders || '').slice(0, 500);
|
||||
const ss = SpreadsheetApp.getActiveSpreadsheet();
|
||||
const sh = ss.getSheetByName('Special orders') || ss.insertSheet('Special orders');
|
||||
if (sh.getLastRow() === 0) sh.appendRow(SPECIAL_HEADERS);
|
||||
const qty = String(d.qty || '').slice(0, 100), notes = String(d.notes || '').slice(0, 500);
|
||||
sh.appendRow([new Date(), item, qty, name, "'" + phone, notes, String(d.page || '').slice(0, 200), 'new']);
|
||||
if (NOTIFY) MailApp.sendEmail(NOTIFY, 'Special order request: ' + item, [item, qty, name, phone, notes].filter(String).join('\n'));
|
||||
const sh = ss.getSheetByName('Institutions') || ss.insertSheet('Institutions');
|
||||
if (sh.getLastRow() === 0) sh.appendRow(B2B_HEADERS);
|
||||
sh.appendRow([new Date(), org, kind, name, "'" + phone, email, orders, String(d.page || '').slice(0, 200), 'new']);
|
||||
if (NOTIFY) MailApp.sendEmail(NOTIFY, 'New institution sign-up: ' + org, [org + ' (' + kind + ')', name, phone, email, orders].filter(String).join('\n'));
|
||||
return json_({ ok: true });
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +42,7 @@ function doPost(e) {
|
|||
try {
|
||||
const d = JSON.parse(e.postData.contents || '{}');
|
||||
if (d.company) return json_({ ok: true }); // honeypot: bots fill the hidden field
|
||||
if (d.type === 'special') return special_(d);
|
||||
if (d.type === 'b2b') return b2b_(d);
|
||||
const name = String(d.name || '').trim().slice(0, 120);
|
||||
const phone = /^\+\d{8,15}$/.test(d.phone || '') ? d.phone : '';
|
||||
const email = /^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(d.email || '') ? String(d.email).toLowerCase().slice(0, 200) : '';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user