-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
1022 lines (854 loc) · 36.2 KB
/
Copy pathadmin.html
File metadata and controls
1022 lines (854 loc) · 36.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin Dashboard</title>
<style>
:root {
--font-sans: "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
--font-mono: "JetBrains Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
--bg: #eef2ff;
--bg-gradient: radial-gradient(900px 700px at 90% -10%, rgba(99, 102, 241, 0.18), transparent 55%), radial-gradient(1100px 800px at -10% 5%, rgba(14, 165, 233, 0.15), transparent 55%), linear-gradient(180deg, #f1f5ff 0%, #e5ecff 40%, #f7f9ff 100%);
--text: #0f172a;
--text-soft: #1e2550;
--text-muted: #4b556d;
--surface: rgba(255, 255, 255, 0.92);
--surface-alt: rgba(244, 247, 255, 0.92);
--divider: rgba(148, 163, 184, 0.2);
--primary: #4f46e5;
--primary-light: rgba(79, 70, 229, 0.16);
--accent: #10b981;
--accent-soft: rgba(16, 185, 129, 0.14);
--info: #0284c7;
--warning: #f59e0b;
--danger: #dc2626;
--radius-lg: 18px;
--radius-md: 12px;
--radius-sm: 8px;
--shadow-soft: 0 20px 45px -30px rgba(15, 23, 42, 0.45), 0 18px 35px -22px rgba(79, 70, 229, 0.25);
--shadow-focus: 0 12px 24px -16px rgba(79, 70, 229, 0.55), 0 0 0 1px rgba(79, 70, 229, 0.18) inset;
--transition-fast: 140ms cubic-bezier(0.27, 0.11, 0.19, 1);
--transition-medium: 260ms cubic-bezier(0.19, 1, 0.22, 1);
}
/* ===== GLOBAL & RESET ===== */
*,
*::before,
*::after {
box-sizing: border-box;
}
html,
body {
min-height: 100%;
margin: 0;
font-family: var(--font-sans);
background: var(--bg-gradient);
color: var(--text);
line-height: 1.6;
letter-spacing: 0.01em;
}
body {
animation: fadeInBody 0.8s ease forwards;
opacity: 0;
}
/* ===== ANIMATIONS ===== */
@keyframes fadeInBody {
from {
opacity: 0;
transform: translateY(12px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes fadeSlideIn {
from {
opacity: 0;
transform: translateY(12px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
/* ===== LAYOUT & STRUCTURE ===== */
header[role="banner"] {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
gap: 12px;
padding: 28px 32px 8px;
}
#navContainer {
position: sticky;
top: 0;
z-index: 30;
display: flex;
gap: 14px;
padding: 14px 32px 18px;
background: linear-gradient(180deg, rgba(248, 250, 255, 0.88), rgba(248, 250, 255, 0.82));
backdrop-filter: blur(12px);
border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}
.view {
display: none;
padding: 32px;
animation: fadeSlideIn 0.45s var(--transition-medium);
}
#productsView {
display: block;
}
/* ===== CARDS & CONTAINERS ===== */
.card,
#formContainer,
#brandForm,
.image-uploader-container,
#textsForm,
.post-template,
#videoCreatorView > div {
position: relative;
background: var(--surface);
border: 1px solid rgba(148, 163, 184, 0.22);
border-radius: var(--radius-lg);
padding: 24px;
box-shadow: var(--shadow-soft);
backdrop-filter: blur(14px);
overflow: hidden;
}
.card::before,
#brandForm::before,
#textsForm::before,
#formContainer::before,
.image-uploader-container::before {
content: "";
position: absolute;
inset: 0;
background: linear-gradient(135deg, rgba(79, 70, 229, 0.16), transparent 60%);
opacity: 0;
transition: opacity var(--transition-medium);
pointer-events: none;
}
.card:hover::before,
#brandForm:hover::before,
#textsForm:hover::before,
#formContainer:hover::before,
.image-uploader-container:hover::before {
opacity: 1;
}
/* ===== TYPOGRAPHY ===== */
h1 {
margin: 0;
font-size: clamp(30px, 2.4vw, 36px);
font-weight: 600;
letter-spacing: -0.03em;
color: var(--text-soft);
text-shadow: 0 14px 30px rgba(79, 70, 229, 0.18);
}
header p {
margin: 0;
font-size: 14px;
color: var(--text-muted);
}
h2,
h3 {
margin: 0 0 16px;
color: var(--text-soft);
font-weight: 600;
letter-spacing: -0.015em;
}
h3 {
font-size: 15px;
text-transform: uppercase;
letter-spacing: 0.18em;
color: rgba(79, 70, 229, 0.85);
}
/* ===== FORMS & INPUTS ===== */
label {
display: block;
margin: 18px 0 8px;
font-size: 13px;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.16em;
color: rgba(15, 23, 42, 0.65);
}
input,
select,
textarea {
width: 100%;
padding: 12px 14px;
border-radius: var(--radius-md);
border: 1px solid rgba(148, 163, 184, 0.35);
background: rgba(255, 255, 255, 0.9);
color: var(--text);
font-size: 14px;
transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
textarea {
min-height: 120px;
resize: vertical;
}
input::placeholder,
textarea::placeholder {
color: rgba(100, 116, 139, 0.55);
}
input:focus,
select:focus,
textarea:focus {
border-color: rgba(79, 70, 229, 0.6);
box-shadow: var(--shadow-focus);
transform: translateY(-1px);
background: rgba(255, 255, 255, 0.98);
}
select {
appearance: none;
background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10.6667 1.33334L6.00008 6.00001L1.33341 1.33334' stroke='%2322334d' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
background-repeat: no-repeat;
background-position: right 14px center;
}
.form-message {
margin-top: 14px;
font-size: 13px;
font-weight: 600;
letter-spacing: 0.08em;
text-transform: uppercase;
}
.form-message.success {
color: var(--accent);
}
.form-message.error {
color: var(--danger);
}
.form-message::before {
content: "";
display: inline-block;
width: 8px;
height: 8px;
margin-right: 8px;
border-radius: 50%;
background: currentColor;
box-shadow: 0 0 12px currentColor;
}
/* ===== BUTTONS ===== */
button {
font-family: inherit;
font-weight: 600;
font-size: 14px;
letter-spacing: 0.015em;
border-radius: var(--radius-md);
padding: 11px 20px;
border: 1px solid rgba(148, 163, 184, 0.34);
background: linear-gradient(120deg, rgba(255, 255, 255, 0.96), rgba(241, 245, 255, 0.94));
color: var(--text-muted);
transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
button:hover {
transform: translateY(-1px);
border-color: rgba(79, 70, 229, 0.34);
color: var(--primary);
box-shadow: 0 14px 20px -16px rgba(79, 70, 229, 0.4);
}
button:active {
transform: translateY(0);
}
#navContainer button {
border: 1px solid rgba(148, 163, 184, 0.26);
background: linear-gradient(120deg, rgba(255, 255, 255, 0.92), rgba(240, 243, 255, 0.92));
color: var(--text-muted);
padding: 10px 20px;
border-radius: 999px;
font-weight: 600;
letter-spacing: 0.015em;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset;
transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
#navContainer button:hover {
transform: translateY(-1px);
color: var(--primary);
border-color: rgba(79, 70, 229, 0.4);
box-shadow: 0 12px 18px -14px rgba(79, 70, 229, 0.35);
}
#navContainer button.active {
background: linear-gradient(120deg, var(--primary), rgba(79, 70, 229, 0.85));
color: #fff;
border: none;
box-shadow: 0 16px 28px -16px rgba(79, 70, 229, 0.55);
}
.btn-primary,
#addProductBtn,
#saveImagePathsBtn {
border: none;
color: #fff;
background: linear-gradient(120deg, var(--primary), #6366f1);
box-shadow: 0 16px 30px -16px rgba(79, 70, 229, 0.55);
}
.btn-primary:hover,
#addProductBtn:hover,
#saveImagePathsBtn:hover {
transform: translateY(-2px);
box-shadow: 0 18px 34px -16px rgba(79, 70, 229, 0.6);
}
/* ===== COMPONENT-SPECIFIC STYLES ===== */
#productSelect {
margin-bottom: 18px;
max-width: 420px;
}
#imageList {
display: flex;
flex-wrap: wrap;
gap: 14px;
margin-top: 12px;
}
#imageList img {
width: 112px;
height: 90px;
object-fit: cover;
border-radius: var(--radius-md);
border: 1px solid rgba(148, 163, 184, 0.26);
background: rgba(255, 255, 255, 0.9);
transition: transform var(--transition-medium), box-shadow var(--transition-medium), filter var(--transition-medium);
}
#imageList img:hover {
transform: translateY(-3px) scale(1.01);
box-shadow: 0 14px 24px -16px rgba(79, 70, 229, 0.35);
filter: saturate(1.1);
}
#imagePreview {
width: 100%;
max-width: 480px;
height: 320px;
margin-top: 18px;
border-radius: var(--radius-lg);
border: 1px solid rgba(148, 163, 184, 0.3);
background: linear-gradient(140deg, rgba(79, 70, 229, 0.16), rgba(255, 255, 255, 0.7));
object-fit: contain;
}
.product-options-container {
display: grid;
gap: 12px;
margin-top: 10px;
}
.product-option-group {
background: var(--surface-alt);
border: 1px solid rgba(148, 163, 184, 0.24);
border-radius: var(--radius-md);
padding: 14px;
}
.tags-container {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin: 8px 0 6px;
}
.choice-tag {
padding: 6px 12px;
border-radius: 999px;
background: rgba(79, 70, 229, 0.12);
color: var(--primary);
border: 1px solid rgba(79, 70, 229, 0.24);
font-weight: 600;
letter-spacing: 0.02em;
}
.image-uploader-box {
position: relative;
border: 1px solid rgba(148, 163, 184, 0.26);
border-radius: var(--radius-md);
background: linear-gradient(140deg, rgba(255, 255, 255, 0.96), rgba(236, 243, 255, 0.92));
transition: transform var(--transition-fast), box-shadow var(--transition-medium), border-color var(--transition-fast);
}
.image-uploader-box:hover {
transform: translateY(-2px);
border-color: rgba(79, 70, 229, 0.35);
box-shadow: 0 16px 28px -18px rgba(79, 70, 229, 0.4);
}
.image-uploader-box .path-display {
margin-top: 10px;
font-family: var(--font-mono);
font-size: 13px;
color: rgba(30, 41, 59, 0.7);
background: rgba(241, 245, 255, 0.9);
border: 1px dashed rgba(79, 70, 229, 0.2);
border-radius: var(--radius-sm);
padding: 9px 12px;
word-break: break-word;
}
.post-template {
border: 1px solid rgba(148, 163, 184, 0.24);
border-radius: var(--radius-lg);
background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(236, 241, 255, 0.92));
}
.post-template textarea {
min-height: 140px;
background: rgba(255, 255, 255, 0.9);
border: 1px solid rgba(148, 163, 184, 0.28);
}
#videoCreatorView label {
margin-top: 20px;
}
#videoCreatorView select,
#videoCreatorView textarea,
#videoCreatorView input[type="range"] {
border-radius: var(--radius-md);
}
#video-result-area {
margin-top: 22px;
padding: 18px;
border-radius: var(--radius-md);
background: rgba(236, 245, 255, 0.9);
border: 1px dashed rgba(148, 163, 184, 0.28);
color: var(--text-muted);
font-size: 15px;
}
#video-result-area a {
color: var(--primary);
font-weight: 600;
text-decoration: none;
}
#video-result-area a:hover {
text-decoration: underline;
}
/* ===== MEDIA QUERIES ===== */
@media (max-width: 1024px) {
header[role="banner"] {
padding: 24px 24px 8px;
}
#navContainer {
padding: 12px 24px 16px;
overflow-x: auto;
}
.view {
padding: 26px 24px;
}
}
@media (max-width: 640px) {
h1 {
font-size: 26px;
}
#navContainer {
gap: 10px;
}
#navContainer button {
padding: 10px 16px;
font-size: 13px;
}
.view {
padding: 22px 18px;
}
}
</style>
<script src="user.js"></script>
<script>
(async () => {
if (typeof window.checkSession === 'function') {
await window.checkSession();
}
const current = typeof window.getCurrentUser === 'function'
? window.getCurrentUser()
: null;
if (!current || current.role !== 'super_admin') {
showToast('Access denied. Please sign in as a super admin.', { type: 'error' });
window.location.href = 'signin.html';
}
})();
</script>
</head>
<body>
<h1>Admin Dashboard</h1>
<p>Customer: <strong id="customerDisplay"></strong></p>
<div id="navContainer">
<button id="showProductsBtn" class="active" type="button">Manage Products</button>
<button id="showBrandBtn" type="button">Manage Brand Info</button>
<button id="showImagesBtn" type="button">Manage Site Images</button>
<button id="showTextsBtn" type="button">Manage Page Texts</button>
<button id="showWinningProductsBtn" type="button">Find Winning Product</button>
<button id="showContentHubBtn" type="button">Content Hub</button>
<button id="showVideoCreatorBtn" type="button">Content Video</button>
</div>
<hr>
<div id="productsView" class="view">
<h2>Product Administration</h2>
<label for="productSelect">Select Product:</label>
<select id="productSelect"></select>
<button id="addProductBtn" type="button">Add New Product</button>
<div id="formContainer"></div>
</div>
<div id="brandView" class="view">
<h2>Brand Information</h2>
<h3>DSers Integration</h3>
<p>Click the button below to connect your DSers account. This will allow for automated order fulfillment and stock syncing for AliExpress products.</p>
<button type="button" id="connectDsersBtn">Connect to DSers</button>
<div id="dsersStatus"></div>
<script>
document.getElementById('connectDsersBtn').addEventListener('click', () => {
// This assumes 'window.customerId' is available globally on the admin page
window.location.href = `/api/${window.customerId}/dsers/connect`;
});
// Check for a success message in the URL
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('dsers_status') === 'success') {
document.getElementById('dsersStatus').innerHTML = '<p style="color: green; font-weight: bold;">DSers connected successfully!</p>';
}
</script>
<hr>
<form id="brandForm">
<p>Fill out your brand's public information. Click save when you're done.</p>
<label for="brand_name">Brand Name</label>
<input type="text" id="brand_name" name="brand_name" placeholder="Your Company LLC">
<label for="brand_logoPath">Logo Path URL</label>
<input type="text" id="brand_logoPath" name="brand_logoPath" placeholder="/images/logo.png">
<label for="brand_phoneNumber">Phone Number</label>
<input type="tel" id="brand_phoneNumber" name="brand_phoneNumber" placeholder="555-123-4567">
<label for="brand_email">Public Email</label>
<input type="email" id="brand_email" name="brand_email" placeholder="contact@yourcompany.com">
<label for="brand_address">Address</label>
<input type="text" id="brand_address" name="brand_address" placeholder="123 Main St, Anytown, USA">
<label for="brand_facebookAddress">Facebook URL</label>
<input type="url" id="brand_facebookAddress" name="brand_facebookAddress" placeholder="https://facebook.com/yourcompany">
<label for="brand_instagramAddress">Instagram URL</label>
<input type="url" id="brand_instagramAddress" name="brand_instagramAddress" placeholder="https://instagram.com/yourcompany">
<label for="brand_tiktokAddress">TikTok URL</label>
<input type="url" id="brand_tiktokAddress" name="brand_tiktokAddress" placeholder="https://tiktok.com/@yourcompany">
<label for="brand_stripeToken">Stripe Token (Private)</label>
<input type="text" id="brand_stripeToken" name="brand_stripeToken" placeholder="sk_live_...">
<label for="brand_shippo_key">Shippo API Key (Private)</label>
<input type="text" id="brand_shippo_key" name="brand_shippo_key" placeholder="shippo_live_...">
<label for="brand_amazonKey">Amazon API Key</label>
<input type="text" id="brand_amazonKey" name="brand_amazonKey" placeholder="Enter Amazon Key (if applicable)">
<label for="brand_aliexpressKey">AliExpress API Key</label>
<input type="text" id="brand_aliexpressKey" name="brand_aliexpressKey" placeholder="Enter AliExpress Key (if applicable)">
<label for="brand_theme">Store Theme</label>
<select id="brand_theme" name="brand_theme">
<option value="css/app.css">Default (Original)</option>
<option value="css/app.color2.css">Color 2</option>
<option value="css/app.color3.css">Color 3</option>
<option value="css/app.color4.css">Color 4</option>
<option value="css/app.color5.css">Color 5</option>
<option value="css/app.color6.css">Color 6</option>
<option value="css/app.color7.css">Color 7</option>
<option value="css/app.color8.css">Color 8</option>
<option value="css/app.color9.css">Color 9</option>
<option value="css/app.color10.css">Color 10</option>
<option value="css/app.color11.css">Color 11</option>
<option value="css/app.color12.css">Color 12</option>
<option value="css/designs/app_original.css">Original (Designs)</option>
<option value="css/designs/app_dark_3d.css">Dark 3D</option>
<option value="css/designs/app_dark_elegant_theme.css">Dark Elegant</option>
<option value="css/designs/app_dark_lumins_lines_theme.css">Dark Lumins Lines</option>
<option value="css/designs/app_deepseek1_light.css">Deepseek Light</option>
<option value="css/designs/app_deepseek2_dark.css">Deepseek Dark</option>
<option value="css/designs/app_flat_design.css">Flat Design</option>
<option value="css/designs/app_flat_design_button.css">Flat Design Buttons</option>
<option value="css/designs/app_white_3d.css">White 3D</option>
<option value="css/designs/app_woodenTheme.css">Wooden Theme</option>
</select>
<button type="submit">Save Brand Info</button>
<div id="brandFormMsg" class="form-message"></div>
</form>
</div>
<div id="imagesView" class="view">
<h2>Site Image Management</h2>
<p>Upload images for your homepage and other non-product sections. The recommended resolution is a guideline for best appearance.</p>
<div class="image-uploader-container">
<h3>Header & Sliders</h3>
<div class="image-uploader-box" data-image-key="logo">
<label for="uploader-logo">Brand Logo (e.g., 200x50 pixels)</label>
<input type="file" id="uploader-logo" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<div class="image-uploader-box" data-image-key="hero1">
<label for="uploader-hero1">Hero Slider Image 1 (e.g., 1920x600 pixels)</label>
<input type="file" id="uploader-hero1" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<div class="image-uploader-box" data-image-key="hero2">
<label for="uploader-hero2">Hero Slider Image 2 (e.g., 1920x600 pixels)</label>
<input type="file" id="uploader-hero2" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<div class="image-uploader-box" data-image-key="hero3">
<label for="uploader-hero3">Hero Slider Image 3 (e.g., 1920x600 pixels)</label>
<input type="file" id="uploader-hero3" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<div class="image-uploader-box" data-image-key="globalOffers">
<label for="uploader-globalOffers">Global Offers Banner (e.g., 1920x450 pixels)</label>
<input type="file" id="uploader-globalOffers" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<h3>"Shop by Deals" Section</h3>
<div class="image-uploader-box" data-image-key="coll1">
<label for="uploader-coll1">Collection Image 1 (Square, e.g., 500x500 pixels)</label>
<input type="file" id="uploader-coll1" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<div class="image-uploader-box" data-image-key="coll2">
<label for="uploader-coll2">Collection Image 2 (Wide, e.g., 700x490 pixels)</label>
<input type="file" id="uploader-coll2" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<div class="image-uploader-box" data-image-key="coll3">
<label for="uploader-coll3">Collection Image 3 (Wide, e.g., 700x490 pixels)</label>
<input type="file" id="uploader-coll3" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<div class="image-uploader-box" data-image-key="coll4">
<label for="uploader-coll4">Collection Image 4 (Square, e.g., 500x500 pixels)</label>
<input type="file" id="uploader-coll4" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<h3>Promotion Section</h3>
<div class="image-uploader-box" data-image-key="promo1">
<label for="uploader-promo1">Promotion Image 1 (Square, e.g., 400x400 pixels)</label>
<input type="file" id="uploader-promo1" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<div class="image-uploader-box" data-image-key="promo2">
<label for="uploader-promo2">Promotion Image 2 (Square, e.g., 400x400 pixels)</label>
<input type="file" id="uploader-promo2" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<div class="image-uploader-box" data-image-key="promo3">
<label for="uploader-promo3">Promotion Image 3 (Square, e.g., 400x400 pixels)</label>
<input type="file" id="uploader-promo3" class="image-uploader-input" accept="image/png, image/jpeg">
<div class="path-display">No image uploaded.</div>
</div>
<hr>
<button id="saveImagePathsBtn" type="button">Save All Image Paths</button>
<div id="imageFormMsg" class="form-message"></div>
</div>
</div>
<div id="textsView" class="view">
<h2>Index Page Text Management</h2>
<p>Edit the text content for your main homepage. Use multiple lines in the text boxes for line breaks on the site. Click save when you're done.</p>
<form id="textsForm">
<h3>Hero Slider Section</h3>
<label for="text-hero-main">Main Hero Text (e.g., Starting At $209.99)</label>
<textarea id="text-hero-main" name="heroMain" rows="2" placeholder="Starting At $209.99"></textarea>
<label for="text-hero-button">Hero "Shop Now" Button Text</label>
<input type="text" id="text-hero-button" name="heroButton" placeholder="SHOP NOW">
<h3>Deals Section</h3>
<label for="text-deals-title">"Shop by Deals" Title</label>
<input type="text" id="text-deals-title" name="dealsTitle" placeholder="SHOP BY DEALS">
<label for="text-deals-subtitle">"Shop by Deals" Subtitle</label>
<input type="text" id="text-deals-subtitle" name="dealsSubtitle" placeholder="BROWSE FAVOURITE DEALS">
<h3>Global Offers Banner</h3>
<label for="text-global-offers">Global Offers Text Block</label>
<textarea id="text-global-offers" name="globalOffers" rows="4" placeholder="Global Offers Official Launch Don't Miss! Enjoy Free Shipping..."></textarea>
<label for="text-global-offers-button">Global Offers "Shop Now" Button Text</label>
<input type="text" id="text-global-offers-button" name="globalOffersButton" placeholder="Shop Now">
<h3>Featured Products Section</h3>
<label for="text-featured-title">"Featured Products" Title</label>
<input type="text" id="text-featured-title" name="featuredTitle" placeholder="FEATURED PRODUCTS">
<label for="text-featured-subtitle">"Featured Products" Subtitle</label>
<input type="text" id="text-featured-subtitle" name="featuredSubtitle" placeholder="FIND NEW FEATURED PRODUCTS">
<h3>Services Section (Icons)</h3>
<label for="text-service1-title">Service 1 Title (Free Shipping)</label>
<input type="text" id="text-service1-title" name="service1Title" placeholder="Free Shipping">
<label for="text-service1-desc">Service 1 Description</label>
<textarea id="text-service1-desc" name="service1Desc" rows="2" placeholder="Free shipping on all US order or order above $200"></textarea>
<label for="text-service2-title">Service 2 Title (Shop with Confidence)</label>
<input type="text" id="text-service2-title" name="service2Title" placeholder="Shop with Confidence">
<label for="text-service2-desc">Service 2 Description</label>
<textarea id="text-service2-desc" name="service2Desc" rows="2" placeholder="Our Protection covers your purchase from click to delivery"></textarea>
<label for="text-service3-title">Service 3 Title (24/7 Help Center)</label>
<input type="text" id="text-service3-title" name="service3Title" placeholder="24/7 Help Center">
<label for="text-service3-desc">Service 3 Description</label>
<textarea id="text-service3-desc" name="service3Desc" rows="2" placeholder="Round-the-clock assistance for a smooth shopping experience"></textarea>
<h3>Promotion Section</h3>
<label for="text-promo1-line1">Promo 1 - Line 1</label>
<input type="text" id="text-promo1-line1" name="promo1Line1" placeholder="WEBSITES FOR YOUR BUSINESS">
<label for="text-promo1-line2a">Promo 1 - Line 2 (Normal Text)</label>
<input type="text" id="text-promo1-line2a" name="promo1Line2a" placeholder="GET IN">
<label for="text-promo1-line2b">Promo 1 - Line 2 (Brand Color Text)</label>
<input type="text" id="text-promo1-line2b" name="promo1Line2b" placeholder="TOUCH">
<label for="text-promo2-line1a">Promo 2 - Line 1 (Normal Text)</label>
<input type="text" id="text-promo2-line1a" name="promo2Line1a" placeholder="E-COMMERCE">
<label for="text-promo2-line1b">Promo 2 - Line 1 (Brand Color Text)</label>
<input type="text" id="text-promo2-line1b" name="promo2Line1b" placeholder="2025">
<label for="text-promo2-line2">Promo 2 - Line 2</label>
<input type="text" id="text-promo2-line2" name="promo2Line2" placeholder="CREATE YOUR STORE">
<label for="text-promo3-line1">Promo 3 - Line 1</label>
<input type="text" id="text-promo3-line1" name="promo3Line1" placeholder="BUY IT NOW">
<label for="text-promo3-line2">Promo 3 - Line 2 (Brand Color Text)</label>
<input type="text" id="text-promo3-line2" name="promo3Line2" placeholder="GET UP TO 30% OFF">
<hr>
<button type="submit">Save All Page Texts</button>
<div id="textsFormMsg" class="form-message"></div>
</form>
</div>
<div id="winningProductsView" class="view">
<h2>Winning Product Research Hub</h2>
<p>Enter a product keyword or niche below to research its popularity across major platforms.</p>
<div style="background-color: #fff; border-radius: 8px; padding: 1.5rem; margin-top: 1rem; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<label>Enter Keywords to Compare:</label>
<div id="keyword-container">
<div class="keyword-input-group">
<input type="text" class="product-keyword-input" placeholder="e.g., portable blender">
<button type="button" class="remove-keyword-btn" style="display: none; background-color: #e74c3c;">-</button>
</div>
</div>
<button type="button" id="add-keyword-btn" style="background-color: #27ae60;">+ Add Keyword</button>
<hr>
<div style="display: flex; gap: 10px; margin-top: 1rem;">
<button type="button" id="search-google-btn">Search Google Trends</button>
<button type="button" id="search-tiktok-btn">Search TikTok</button>
<button type="button" id="search-instagram-btn">Search Instagram</button>
</div>
<p style="font-size: 0.8em; color: #777; margin-top: 1rem;">
<small><strong>Note:</strong> Your browser might block multiple tabs from opening. If it does, click the pop-up icon in your address bar and choose "Always allow" for this site.</small>
</p>
</div>
</div>
<div id="contentHubView" class="view">
<h2>Social Media Content Hub</h2>
<p>Draft and tailor your posts for each platform in one place, then copy and paste to publish.</p>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-top: 1rem;">
<div class="post-template" style="border: 1px solid #ddd; border-radius: 8px; padding: 15px; background: #fff;">
<h4>Facebook Post</h4>
<textarea id="fb-text" placeholder="What's on your mind?" style="width: 100%; min-height: 150px;"></textarea>
<button onclick="copyText('fb-text', null, this)">Copy Text</button>
<button onclick="handleAiEdit('facebook', this)" class="ai-edit-btn">✨ AI Edit</button>
</div>
<div class="post-template" style="border: 1px solid #ddd; border-radius: 8px; padding: 15px; background: #fff;">
<h4>Instagram Post</h4>
<textarea id="ig-text" placeholder="Write a caption..." style="width: 100%; min-height: 100px;"></textarea>
<label>Hashtags:</label>
<input type="text" id="ig-hashtags" placeholder="#gadget #coolfinds">
<button onclick="copyText('ig-text', 'ig-hashtags', this)">Copy Caption & Hashtags</button>
<button onclick="handleAiEdit('instagram', this)" class="ai-edit-btn">✨ AI Edit</button>
</div>
<div class="post-template" style="border: 1px solid #ddd; border-radius: 8px; padding: 15px; background: #fff;">
<h4>TikTok Video Description</h4>
<textarea id="tt-text" placeholder="Describe your video..." style="width: 100%; min-height: 100px;"></textarea>
<label>Hashtags:</label>
<input type="text" id="tt-hashtags" placeholder="#tiktokmademebuyit">
<button onclick="copyText('tt-text', 'tt-hashtags', this)">Copy Description & Hashtags</button>
<button onclick="handleAiEdit('tiktok', this)" class="ai-edit-btn">✨ AI Edit</button>
</div>
</div>
</div>
<div id="videoCreatorView" class="view">
<h2>AI Video Creator (Powered by Runway)</h2>
<p>Create a short video from an image. The process can take a few minutes.</p>
<div style="background-color: #fff; border-radius: 8px; padding: 1.5rem; margin-top: 1rem; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<label for="video-provider">AI Provider (Check Pricing):</label>
<select id="video-provider">
<option value="veo">Google Veo 3 Fast (~$0.15/sec)</option>
<option value="runway">Runway (~$0.25/sec)</option>
</select>
<label for="video-product-select">Select a Product to Create Video For:</label>
<select id="video-product-select" class="select-box">
<option value="">-- Loading Products --</option>
</select>
<div id="video-image-selector" style="display: none; margin-top: 1rem;">
<label>Select an Image from the Product:</label>
<div id="video-image-thumbnails" style="display: flex; gap: 10px; flex-wrap: wrap; border: 1px solid #ddd; padding: 10px; border-radius: 4px;">
</div>
</div>
<label for="video-duration">Video Duration (seconds): <span id="duration-label">10s</span></label>
<input type="range" id="video-duration" min="5" max="20" value="10" style="margin-top: 5px;">
<label for="video-platform">Optimize For:</label>
<select id="video-platform">
<option value="tiktok">TikTok</option>
<option value="instagram">Instagram (Reels/Story)</option>
<option value="facebook">Facebook</option>
</select>
<label for="video-prompt">Your Instructions (e.g., "camera slowly zooms in"):</label>
<textarea id="video-prompt" placeholder="Describe the motion you want to see..."></textarea>
<button type="button" id="generate-video-btn">Generate Video</button>
<div id="video-result-area" style="margin-top: 20px;"></div>
</div>
</div>
<script src="auth.js"></script>
<script>
// Site Images view logic
(() => {
const BRAND_API = `${window.API_ROOT}/brand`;
const BRAND_IMAGE_UPLOAD_URL = `${window.API_ROOT}/upload-brand-image`;
const imageFormMsg = document.getElementById('imageFormMsg');
let siteImagePaths = {};
async function fetchJSON(url, opts = {}) {
const res = await fetch(url, opts);
let data;
try { data = await res.json(); } catch (e) {}
if (!res.ok) {
const errorMsg = data?.error || `${res.status} ${res.statusText}`;
throw new Error(errorMsg);
}
return data;
}
async function loadAndDisplayBrandImages() {
try {
const brandData = await fetchJSON(BRAND_API);
const paths = brandData.brand_nonProductImagePath || {};
siteImagePaths = paths;
document.querySelectorAll('.image-uploader-box').forEach(box => {
const key = box.dataset.imageKey;
const pathDisplay = box.querySelector('.path-display');
if (paths[key]) {
pathDisplay.textContent = paths[key];
} else {
pathDisplay.textContent = 'No image uploaded.';
}
});
} catch (error) {
console.error('Error loading brand images:', error);
}
}
document.querySelectorAll('.image-uploader-input').forEach(input => {
input.addEventListener('change', async (event) => {
const file = event.target.files[0];
if (!file) return;
const box = event.target.closest('.image-uploader-box');
const pathDisplay = box.querySelector('.path-display');
const key = box.dataset.imageKey;
pathDisplay.textContent = 'Uploading...';
const formData = new FormData();
formData.append('file', file);
try {
const result = await fetchJSON(BRAND_IMAGE_UPLOAD_URL, {
method: 'POST',
body: formData
});
pathDisplay.textContent = result.path;
siteImagePaths[key] = result.path;
} catch (error) {
pathDisplay.textContent = `Upload failed: ${error.message}`;
console.error('Upload error:', error);
}
});
});
document.getElementById('saveImagePathsBtn').addEventListener('click', async () => {
imageFormMsg.textContent = 'Saving...';
imageFormMsg.className = 'form-message';
try {
const brandData = await fetchJSON(BRAND_API).catch(() => ({}));
// Safely get the old paths from the data we just fetched
const oldPaths = brandData.brand_nonProductImagePath || {};
// Merge the old paths with any newly uploaded paths
const finalImagePaths = { ...oldPaths, ...siteImagePaths };
const payload = {
...brandData,
brand_logoPath: finalImagePaths.logo || brandData.brand_logoPath,
brand_nonProductImagePath: JSON.stringify(finalImagePaths) // Use the complete, merged object
};
delete payload.rowid;