PageSourceSearch

https://herpowerapp.com/assets/EbookNotes-BeUJKWin.js

js herpowerapp.com collected 2026-10-09 22:03:46 UTC 13,602 bytes, 1 lines download raw bytes

1import{b as pe,u as je,g as be,r as a,s as f,j as e,a2 as Ne,C as T,y as Z,z as ee,I as se,a as E,B as o,d as ve,e as te,N as _,h as g,D as ye,q as we,t as ke,v as Ce,w as Se,X as Te}from"./index-DO0ZNUzu.js";import{T as Ee}from"./textarea-CcV1k9Cd.js";import{S as W,a as L,b as z,c as V,d}from"./select-Tn3h6yZZ.js";import{u as _e}from"./useDebounce-i_d-TPaQ.js";import{n as Ae}from"./confidence-young-girl-CCu4XpAf.js";import{P as De}from"./pen-line-DxoMXFq6.js";import{H as Pe}from"./house-CUUNLlcb.js";import{L as Fe}from"./lightbulb-DnYnZiXl.js";import{S as Ie}from"./search-DfJrq0Pb.js";import{F as Re}from"./filter-b1rxWdXb.js";import{P as qe}from"./plus-BWXN0Mzt.js";import{P as He}from"./pencil-C1015J_z.js";import{T as Be}from"./trash-2-VtFXnL4x.js";import"./check-Cyw8qn0D.js";const A=["Daily Confidence","Weekly Planning","Boundaries","Self-Care & Wellness","Confidence & Identity","Emotional Reflection","Dreams & Vision","Journal Prompts","Affirmations"],Oe=["Check-In","Goal","Reflection","Boundary","Self-Care","Affirmation","Dream","Wellness","Growth","Power Words","Healing","Vision"],We=["Today I felt proud of myself when…","Something I want to believe about myself is…","A boundary I’m practicing is…","My dream for this year looks like…"],ss=()=>{const D=pe(),{user:r,loading:p}=je(),{toast:i}=be(),[ae,P]=a.useState(!0),[j,re]=a.useState([]),[le,c]=a.useState(!1),[m,M]=a.useState(null),[$,oe]=a.useState(""),b=_e($,300),[N,ne]=a.useState("all"),[u,ie]=a.useState("all"),[x,G]=a.useState([]),[v,y]=a.useState(""),[w,k]=a.useState(""),[F,I]=a.useState(""),[R,q]=a.useState(A[0]),[n,C]=a.useState([]),[S,H]=a.useState("");a.useEffect(()=>{document.title="HERPower Notes - Your E-book Companion"},[]),a.useEffect(()=>{!p&&r?B():!p&&!r&&P(!1)},[r,p,b,N,u,x]);const B=async()=>{if(r){P(!0);try{let s=f.from("ebook_notes").select("*").eq("user_id",r.id).order("updated_at",{ascending:!1});b&&(s=s.or(`title.ilike.%${b}%,content.ilike.%${b}%`)),N!=="all"&&(s=s.eq("ebook_type",N)),u!=="all"&&(u==="intro"?s=s.eq("chapter_number",0):s=s.eq("chapter_number",parseInt(u)));const{data:t,error:l}=await s;if(l)throw l;let h=t||[];x.length>0&&(h=h.filter(fe=>x.some(ge=>{var Q;return(Q=fe.tags)==null?void 0:Q.includes(ge)}))),re(h)}catch(s){console.error("Error fetching notes:",s),i({title:"Error",description:"Failed to load your notes",variant:"destructive"})}finally{P(!1)}}},U=()=>{y(""),k(""),I(""),q(A[0]),C([]),H(""),M(null)},Y=()=>{U(),c(!0)},ce=s=>{y(s.title),k(s.content),I(s.page_reference||""),q(s.ebook_type),C(s.tags||[]),M(s),c(!0)},O=s=>{const t=s.trim();t&&!n.includes(t)&&(C([...n,t]),H(""))},K=s=>{C(n.filter(t=>t!==s))},de=s=>{G(t=>t.includes(s)?t.filter(l=>l!==s):[...t,s])},me=async()=>{if(!r||!v.trim()||!w.trim()){i({title:"Missing Information",description:"Please provide a title and content for your note",variant:"destructive"});return}try{if(m){const{error:s}=await f.from("ebook_notes").update({title:v.trim(),content:w.trim(),page_reference:F.trim()||null,ebook_type:R,tags:n}).eq("id",m.id);if(s)throw s;i({title:"Success",description:"Note updated successfully"})}else{const{error:s}=await f.from("ebook_notes").insert({user_id:r.id,title:v.trim(),content:w.trim(),page_reference:F.trim()||null,ebook_type:R,tags:n});if(s)throw s;i({title:"Success",description:"Note created successfully"})}c(!1),U(),B()}catch(s){console.error("Error saving note:",s),i({title:"Error",description:"Failed to save note",variant:"destructive"})}},ue=async s=>{if(confirm("Are you sure you want to delete this note?"))try{const{error:t}=await f.from("ebook_notes").delete().eq("id",s);if(t)throw t;i({title:"Success",description:"Note deleted successfully"}),B()}catch(t){console.error("Error deleting note:",t),i({title:"Error",description:"Failed to delete note",variant:"destructive"})}},J=j,[xe,he]=a.useState([]);a.useEffect(()=>{(async()=>{if(r)try{const{data:t}=await f.from("ebook_notes").select("tags").eq("user_id",r.id),l=Array.from(new Set((t||[]).flatMap(h=>h.tags||[])));he(l)}catch(t){console.error("Error fetching tags:",t)}})()},[r]);const X=xe;return p||ae?e.jsx(Ne,{}):r?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsxs("section",{className:"relative overflow-hidden",children:[e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("img",{src:Ae,alt:"Young girl smiling with confidence",className:"w-full h-full object-cover",loading:"eager"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-background via-background/90 to-background/30"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-background via-trans
1parent to-transparent"})]}),e.jsx("div",{className:"relative container mx-auto px-4 pt-8 pb-10",children:e.jsxs("div",{className:"max-w-2xl",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-rose-100 text-rose-600 text-xs font-semibold mb-4",children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),"Your reflections matter"]}),e.jsx("h1",{className:"text-3xl sm:text-4xl font-bold text-foreground mb-3",children:"HERPower Notes"}),e.jsx("p",{className:"text-muted-foreground text-lg mb-5 max-w-lg",children:"A private place to capture what you’re learning, feeling, and becoming — one note at a time."}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(o,{onClick:Y,className:"gap-2 rounded-full px-5",children:[e.jsx(De,{className:"h-4 w-4"}),"Write a Note"]}),e.jsxs(o,{variant:"outline",size:"sm",onClick:()=>D("/ebook"),className:"rounded-full gap-2",children:[e.jsx(te,{className:"h-4 w-4"}),"Read the E-book"]}),e.jsx(o,{variant:"ghost",size:"icon",onClick:()=>D("/dashboard"),className:"rounded-full","aria-label":"Back to Dashboard",children:e.jsx(Pe,{className:"h-5 w-5"})})]})]})})]}),e.jsxs("div",{className:"container mx-auto px-4 py-6 space-y-6",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:We.map((s,t)=>{const l=["bg-rose-100 text-rose-600","bg-sky-100 text-sky-600","bg-violet-100 text-violet-600","bg-amber-100 text-amber-600"];return e.jsxs("button",{onClick:()=>{y("Reflection"),k(s+" "),c(!0)},className:"text-left p-4 rounded-2xl bg-card border border-border/50 hover:border-primary/30 hover:bg-muted/40 transition-gentle",children:[e.jsx(Fe,{className:`h-5 w-5 mb-2 p-1 rounded-full ${l[t%l.length]}`}),e.jsx("p",{className:"text-sm font-medium text-foreground leading-snug",children:s})]},t)})}),e.jsx(T,{className:"overflow-hidden border-border/50",children:e.jsx(E,{className:"pt-5 pb-5",children:e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-3",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(Ie,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(_,{placeholder:"Search your notes...",value:$,onChange:s=>oe(s.target.value),className:"pl-10 rounded-full"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Re,{className:"h-4 w-4 text-muted-foreground hidden sm:block"}),e.jsxs(W,{value:u,onValueChange:ie,children:[e.jsx(L,{className:"w-[160px] rounded-full",children:e.jsx(z,{placeholder:"Filter by chapter"})}),e.jsxs(V,{children:[e.jsx(d,{value:"all",children:"All Chapters"}),e.jsx(d,{value:"intro",children:"Introduction"}),Array.from({length:13},(s,t)=>t+1).map(s=>e.jsxs(d,{value:s.toString(),children:["Chapter ",s]},s))]})]}),e.jsxs(W,{value:N,onValueChange:ne,children:[e.jsx(L,{className:"w-[180px] rounded-full",children:e.jsx(z,{placeholder:"Filter by section"})}),e.jsxs(V,{children:[e.jsx(d,{value:"all",children:"All Sections"}),A.map(s=>e.jsx(d,{value:s,children:s},s))]})]})]})]}),X.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Filter by tags:"}),X.map(s=>e.jsx(g,{variant:x.includes(s)?"default":"outline",className:"cursor-pointer rounded-full",onClick:()=>de(s),children:s},s)),x.length>0&&e.jsx(o,{variant:"ghost",size:"sm",onClick:()=>G([]),className:"h-6 px-2 rounded-full",children:"Clear"})]})]})})}),J.length===0?e.jsx(T,{className:"border-border/50",children:e.jsxs(E,{className:"py-14 text-center",children:[e.jsx("div",{className:"mx-auto w-16 h-16 rounded-2xl bg-rose-100 text-rose-600 flex items-center justify-center mb-4",children:e.jsx(te,{className:"h-8 w-8"})}),e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-1",children:j.length===0?"No notes yet, girl":"No notes match your search"}),e.jsx("p",{className:"text-muted-foreground max-w-md mx-auto mb-5",children:j.length===0?"Every thought you capture is a step toward owning your story. Start with a prompt above.":"Try adjusting your filters or search words."}),j.length===0&&e.jsxs(o,{onClick:Y,className:"gap-2 rounded-full",children:[e.jsx(qe,{className:"h-4 w-4"}),"Write My First Note"]})]})}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:J.map(s=>e.jsxs(T,{className:"group border-border/50 hover:shadow-md transition-gentle overflow-hidden",children:[e.jsxs(Z,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(ee,{className:"text-lg leading-tight truncate",children:s.title}),e.jsxs(se,{className:"mt-1.5 flex flex-wrap items-center gap-2",children:[s.chapter_number!==null&&s.chapter_number!==void 0&&e.jsx(g,{variant:"outline",className:"rounded-full",children:s.chapter_number===0?"Introduction":`Chapter ${s.chapter_number}`}),e.jsxs("span",{className:"text-xs",children:[s.ebook_type,s.page_reference&&` • ${s.page_reference}`]})]})]}),e.jsxs("div",{className:"flex gap-1 opacity-80 group-hover:opacity-100 transition-opacity",children:[e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>ce(s),"aria-label":"Edit note",children:e.jsx(He,{className:"h-4 w-4"})}),e.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 rounded-full text-destructive hover:text-destructive",onClick:()=>ue(s.id),"aria-label":"Delete note",children:e.jsx(Be,{className:"h-4 w-4"})})]})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:s.tags.map((t,l)=>e.jsx(g,{variant:"secondary",className:"text-xs rounded-full",children:t},l))})]}),e.jsxs(E,{className:"pt-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-4",children:s.content}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-4",children:["Updated ",new Date(s.updated_at).toLocaleDateString()]})]})]},s.id))}),e.jsx(ye,{open:le,onOpenChange:c,children:e.jsxs(we,{className:"max-w-2xl rounded-2xl",children:[e.jsxs(ke,{children:[e.jsx(Ce,{children:m?"Edit Note":"New Note"}),e.jsx(Se,{children:m?"Update your workbook note":"Create a new note from your HERPower workbook"})]}),e.jsxs("div",{className:"space-y-4 max-h-[70vh] overflow-y-auto pr-1",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Workbook Section"}),e.jsxs(W,{value:R,onValueChange:q,children:[e.jsx(L,{className:"rounded-xl",children:e.jsx(z,{})}),e.jsx(V,{children:A.map(s=>e.jsx(d,{value:s,children:s},s))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Title"}
1),e.jsx(_,{placeholder:"Note title...",value:v,onChange:s=>y(s.target.value),className:"rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Page Reference (optional)"}),e.jsx(_,{placeholder:"e.g., Page 42, Chapter 3",value:F,onChange:s=>I(s.target.value),className:"rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Content"}),e.jsx(Ee,{placeholder:"Write your notes here...",value:w,onChange:s=>k(s.target.value),rows:8,className:"rounded-xl"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Tags"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:Oe.map(s=>e.jsx(g,{variant:n.includes(s)?"default":"outline",className:"cursor-pointer rounded-full",onClick:()=>n.includes(s)?K(s):O(s),children:s},s))}),n.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 border rounded-xl bg-muted/30",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Selected:"}),n.map(s=>e.jsxs(g,{className:"gap-1 rounded-full",children:[s,e.jsx(Te,{className:"h-3 w-3 cursor-pointer",onClick:()=>K(s)})]},s))]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(_,{placeholder:"Add custom tag...",value:S,onChange:s=>H(s.target.value),onKeyDown:s=>{s.key==="Enter"&&(s.preventDefault(),O(S))},className:"rounded-xl"}),e.jsx(o,{type:"button",variant:"secondary",onClick:()=>O(S),disabled:!S.trim(),className:"rounded-xl",children:"Add"})]})]})]}),e.jsxs("div",{className:"flex gap-2 justify-end pt-2",children:[e.jsx(o,{variant:"outline",onClick:()=>c(!1),className:"rounded-full",children:"Cancel"}),e.jsx(o,{onClick:me,className:"rounded-full",children:m?"Update Note":"Create Note"})]})]})]})})]})]}):e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center p-4",children:e.jsxs(T,{className:"max-w-md w-full",children:[e.jsxs(Z,{children:[e.jsx(ee,{children:"Sign In Required"}),e.jsx(se,{children:"Please sign in to access your HERPower Notes"})]}),e.jsx(E,{children:e.jsx(o,{onClick:()=>D("/auth"),className:"w-full",children:"Sign In"})})]})})};export{ss as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.