PageSourceSearch

https://www.instagem.ai/assets/EditScheduledPost-Cdjmfs8o.js

js instagem.ai collected 2026-10-05 12:04:57 UTC 11,162 bytes, 1 lines download raw bytes

1import{b as se,a as te,aG as ae,E as re,G as ie,u as ne,al as le,r as l,j as e,o as M,a6 as B,c as g,C as b,g as v,h as N,l as S,a2 as w,af as oe,z as R,aW as ce,aa as V,ab as q,ac as G,ad as F,ae as W}from"./main-DX7XzkoU.js";import{C as de,s as me,a as ue}from"./calendar-CB1VlRw0.js";import{P as pe,a as he,b as xe}from"./popover-C2ojZSpS.js";import{B as ge}from"./badge-BOGaWzi1.js";import{A as y}from"./AppHeader-CzkMBh75.js";import{I as X}from"./instagramPublishingService-BVQSHM0o.js";import{p as fe,e as je}from"./pt-BR-g-tPW2Ip.js";import{A as $}from"./arrow-left-Cf41rOjY.js";import{f as be}from"./format-kQpqiptj.js";import{C as ve}from"./clock-DZY59rpR.js";import{S as Ne}from"./save-eqVbSOS7.js";import"./addDays-CTmn1H6a.js";import"./endOfMonth-DpURBOFe.js";import"./isSameDay-BKzx1q_S.js";import"./chevron-left-B_lb0x5L.js";import"./chevron-right-D27HfhtL.js";import"./sheet-D4yLKOxB.js";import"./AppInstallBanner-CAnCi_kO.js";import"./CreateContentModal-eREkTihJ.js";import"./referral-code-CAIXjQN4.js";import"./megaphone-B0K-HV7w.js";import"./lightbulb-UJa6zn96.js";import"./image-BBUOngQh.js";import"./smartphone-WGY3uvd5.js";import"./video-BvJDFQSG.js";import"./image-play-FzvV3P2U.js";import"./palette-OTKsHiwO.js";import"./wand-sparkles-CwRAYUwy.js";import"./clapperboard-BoJYuZop.js";import"./layers-UGj9VXD5.js";import"./ThemeToggle-C5kzRcph.js";import"./dropdown-menu-D6liHcXh.js";import"./index-D6Z5KIMn.js";import"./circle-BXmX70XD.js";import"./monitor-MvsPdGOU.js";import"./routes-Dh-CjbFu.js";import"./history-BQ1iBcZd.js";import"./user-check-BR60HPjZ.js";import"./chart-no-axes-column-CL-SWzid.js";import"./link-D6mXMmG7.js";import"./settings-N25lzdMz.js";import"./circle-help-CV3y08qY.js";import"./user-x-BOA8xi05.js";import"./globe-BBWCCznd.js";import"./download-DFu9GkQ8.js";import"./useInstagramProfiles-D_KQvT_K.js";import"./instagram-uOX4SJX4.js";import"./plus-C6FQ2-b-.js";import"./gem-DGeoeC5P.js";import"./menu-B6sRxHFL.js";const Se=Array.from({length:24},(a,c)=>({value:c.toString().padStart(2,"0"),label:c.toString().padStart(2,"0")})),we=Array.from({length:12},(a,c)=>({value:(c*5).toString().padStart(2,"0"),label:(c*5).toString().padStart(2,"0")}));function Cs(){const{t:a,i18n:c}=se(),f=te(),{postId:p}=ae(),{toast:C}=re(),{selectedProfile:m}=ie(),{user:ye,signOut:Ce}=ne(),{subscription:_e,imagesLeft:Ae,openCustomerPortal:Pe}=le(),_=c.language==="pt"?fe:je,[t,J]=l.useState(null),[K,h]=l.useState(!0),[A,x]=l.useState(null),[n,P]=l.useState(""),u=2200,[d,T]=l.useState(void 0),[E,I]=l.useState("12"),[k,z]=l.useState("00"),[Q,D]=l.useState(!1),[H,L]=l.useState(!1),Y={post:a("postSuggestions.post","Post"),story:a("postSuggestions.story","Story"),story_sequence:a("postSuggestions.storySequence","Sequência de Stories"),carousel:a("postSuggestions.carousel","Carrossel"),reel:a("publishing.reel","Reel")};l.useEffect(()=>{async function s(){if(!p){x("Post ID não fornecido"),h(!1);return}try{const i=(await X.listScheduledPosts({instagramProfileId:m==null?void 0:m.id,limit:1e3})).find(r=>r.id===p);if(!i){x("Post não encontrado"),h(!1);return}if(!["pending","scheduled","failed"].includes(i.status)){x("Este post não pode ser editado"),h(!1);return}if(J(i),P(i.caption||""),i.scheduledAt){const r=new Date(i.scheduledAt);T(r),I(r.getHours().toString().padStart(2,"0")),z(r.getMinutes().toString().padStart(2,"0"))}}catch(o){console.error("Error loading post:",o),x("Erro ao carregar post")}finally{h(!1)}}s()},[p,m==null?void 0:m.id]);const j=()=>
1{if(d)return me(ue(d,parseInt(E)),parseInt(k))},O=()=>{const s=j();return s?s<=new Date:!1},Z=()=>{if(!t||d&&O()||n.length>u)return!1;const s=t.caption||"",o=n.trim()!==s.trim(),i=t.scheduledAt?new Date(t.scheduledAt):void 0,r=j(),U=(i==null?void 0:i.getTime())!==(r==null?void 0:r.getTime());return o||U},ee=async()=>{if(!(!t||!p)){L(!0);try{const s={},o=t.caption||"";n.trim()!==o.trim()&&(s.caption=n.trim());const i=t.scheduledAt?new Date(t.scheduledAt):void 0,r=j();if((i==null?void 0:i.getTime())!==(r==null?void 0:r.getTime())&&r&&(s.scheduledAt=r),await X.updateScheduledPost(p,s))C({title:a("publishing.updated","Atualizado!"),description:a("publishing.updated_desc","Seu agendamento foi atualizado com sucesso.")}),f("/dashboard/scheduled");else throw new Error("Erro ao atualizar")}catch(s){console.error("Save error:",s),C({title:a("common.error","Erro"),description:a("publishing.update_error","Erro ao atualizar agendamento"),variant:"destructive"})}finally{L(!1)}}};return K?e.jsxs("div",{className:"min-h-screen bg-gradient-background",children:[e.jsx("div",{className:"fixed top-0 left-0 right-0 z-50",children:e.jsx(y,{})}),e.jsx("div",{className:"flex items-center justify-center pt-32",children:e.jsx(M,{className:"w-8 h-8 animate-spin text-primary"})})]}):A||!t?e.jsxs("div",{className:"min-h-screen bg-gradient-background",children:[e.jsx("div",{className:"fixed top-0 left-0 right-0 z-50",children:e.jsx(y,{})}),e.jsx("div",{className:"container max-w-2xl mx-auto py-6 px-4 pt-[calc(64px_+_var(--app-banner-h,0px)_+_var(--sai-top))]",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-destructive/10 flex items-center justify-center mb-4",children:e.jsx(B,{className:"w-8 h-8 text-destructive"})}),e.jsx("h3",{className:"font-medium text-lg mb-1",children:A||"Post não encontrado"}),e.jsxs(g,{variant:"outline",className:"mt-4",onClick:()=>f("/dashboard/scheduled"),children:[e.jsx($,{className:"w-4 h-4 mr-2"}),a("common.back","Voltar")]})]})})]}):e.jsxs("div",{className:"min-h-screen bg-gradient-background",children:[e.jsx("div",{className:"fixed top-0 left-0 right-0 z-50",children:e.jsx(y,{})}),e.jsxs("div",{className:"container max-w-2xl mx-auto py-6 px-4 pt-[calc(64px_+_var(--app-banner-h,0px)_+_var(--sai-top))] pb-24",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx(g,{variant:"ghost",size:"icon",onClick:()=>f("/dashboard/scheduled"),children:e.jsx($,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold",children:a("publishing.edit.title","Editar Agendamento")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("publishing.edit.subtitle","Altere a legenda ou data de publicação.")})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(b,{children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(N,{className:"text-base",children:a("publishing.preview","Prévia")}),e.jsx(ge,{variant:"outline",children:Y[t.contentType]})]})}),e.jsx(S,{children:e.jsxs("div",{className:"flex gap-4",children:[e.jsxs("div",{className:"relative w-24 h-24 sm:w-32 sm:h-32 rounded-lg overflow-hidden bg-muted shrink-0",children:[t.contentType==="reel"||t.videoUrl?e.jsx("video",{src:t.videoUrl||t.imageUrl,className:"w-full h-full object-cover",muted:!0,playsInline:!0}):e.jsx("img",{src:t.imageUrl,alt:"Preview",className:"w-full h-full object-cover"}),t.carouselSlides&&t.carouselSlides.length>0&&e.jsxs("div",{className:"absolute bottom-1 right-1 bg-black/60 text-white text-xs px-1.5 py-0.5 rounded",children:["+",t.carouselSlides.length]}),(t.contentType==="reel"||t.videoUrl)&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/20",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-white/80 flex items-center justify-center",children:e.jsx("div",{className:"w-0 h-0 border-t-[6px] border-t-transparent border-l-[10px] border-l-black border-b-[6px] border-b-transparent ml-0.5"})})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:a("publishing.edit.media_readonly","A mídia não pode ser alterada.")}),t.carouselSlides&&t.carouselSlides.length>0&&e.jsxs("div",{className:"flex gap-1 mt-2 overflow-x-auto pb-1",children:[t.carouselSlides.slice(0,4).map((s,o)=>e.jsx("div",{className:"w-12 h-12 rounded overflow-hidden bg-muted shrink-0",children:e.jsx("img",{src:s.image_url,alt:"",className:"w-full h-full object-cover"})},o)),t.carouselSlides.length>4&&e.jsxs("div",{className:"w-12 h-12 rounded bg-muted shrink-0 flex items-center justify-center text-xs text-muted-foreground",children:["+",t.carouselSlides.length-4]})]})]})]})})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(N,{className:"text-base",children:a("publishing.caption","
1Legenda")}),e.jsxs("span",{className:w("text-xs tabular-nums",n.length>u?"text-red-500 font-medium":n.length>2e3?"text-orange-500":"text-muted-foreground"),children:[n.length,"/",u]})]})}),e.jsxs(S,{children:[e.jsx(oe,{value:n,onChange:s=>P(s.target.value),placeholder:t.contentType==="story"?a("publishing.caption_not_supported","Stories não suportam legenda"):a("publishing.caption_placeholder","Escreva uma legenda..."),disabled:t.contentType==="story",rows:5,className:w("resize-none",n.length>u&&"border-red-500 focus-visible:ring-red-500")}),n.length>u&&e.jsx("p",{className:"text-xs text-red-500 mt-1",children:a("publishing.caption_too_long","A legenda excede o limite do Instagram. Reduza {{count}} caracteres.",{count:n.length-u})})]})]}),e.jsxs(b,{children:[e.jsx(v,{className:"pb-3",children:e.jsx(N,{className:"text-base",children:a("publishing.schedule","Agendamento")})}),e.jsxs(S,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(R,{className:"text-sm",children:a("publishing.date","Data")}),e.jsxs(pe,{open:Q,onOpenChange:D,modal:!0,children:[e.jsx(he,{asChild:!0,children:e.jsxs(g,{type:"button",variant:"outline",className:w("w-full justify-start text-left font-normal mt-1.5",!d&&"text-muted-foreground"),children:[e.jsx(ce,{className:"mr-2 h-4 w-4"}),d?be(d,"PPP",{locale:_}):a("publishing.select_date","Selecione uma data")]})}),e.jsx(xe,{className:"w-auto p-0",align:"start",children:e.jsx(de,{mode:"single",selected:d,onSelect:s=>{T(s),D(!1)},disabled:s=>s<new Date(new Date().setHours(0,0,0,0)),initialFocus:!0,locale:_})})]})]}),e.jsxs("div",{children:[e.jsx(R,{className:"text-sm",children:a("publishing.time","Horário")}),e.jsxs("div",{className:"flex gap-2 mt-1.5",children:[e.jsxs(V,{value:E,onValueChange:I,children:[e.jsxs(q,{className:"flex-1",children:[e.jsx(ve,{className:"w-4 h-4 mr-2"}),e.jsx(G,{})]}),e.jsx(F,{children:Se.map(s=>e.jsxs(W,{value:s.value,children:[s.label,"h"]},s.value))})]}),e.jsx("span",{className:"flex items-center text-muted-foreground",children:":"}),e.jsxs(V,{value:k,onValueChange:z,children:[e.jsx(q,{className:"flex-1",children:e.jsx(G,{})}),e.jsx(F,{children:we.map(s=>e.jsx(W,{value:s.value,children:s.label},s.value))})]})]})]}),O()&&e.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1.5",children:[e.jsx(B,{className:"w-4 h-4"}),a("publishing.time_in_past","O horário selecionado já passou")]})]})]}),e.jsxs(g,{onClick:ee,disabled:!Z()||H,className:"w-full gap-2",size:"lg",children:[H?e.jsx(M,{className:"w-5 h-5 animate-spin"}):e.jsx(Ne,{className:"w-5 h-5"}),a("common.save","Salvar")]})]})]})]})}export{Cs 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.