Fix Block
This commit is contained in:
1 parent
0ee4eee880
commit
78f2cb62aa
6 files changed
+53
-12
No files matched your search
@@ -6,6 +6,7 @@ interface BannerFormProps {
|
|||||||
editingLang: string;
|
editingLang: string;
|
||||||
getLocalizedValue: (payload: any, field: string) => string;
|
getLocalizedValue: (payload: any, field: string) => string;
|
||||||
updateLocalizedValue: (field: string, value: string) => void;
|
updateLocalizedValue: (field: string, value: string) => void;
|
||||||
|
updatePayloadValue: (field: string, value: string | number) => void;
|
||||||
setUploadTarget: (target: { type: 'main' | 'slide'; index?: number } | null) => void;
|
setUploadTarget: (target: { type: 'main' | 'slide'; index?: number } | null) => void;
|
||||||
setIsMediaModalOpen: (open: boolean) => void;
|
setIsMediaModalOpen: (open: boolean) => void;
|
||||||
}
|
}
|
||||||
@@ -14,6 +15,7 @@ export default function BannerForm({
|
|||||||
editingSection,
|
editingSection,
|
||||||
getLocalizedValue,
|
getLocalizedValue,
|
||||||
updateLocalizedValue,
|
updateLocalizedValue,
|
||||||
|
updatePayloadValue,
|
||||||
setUploadTarget,
|
setUploadTarget,
|
||||||
setIsMediaModalOpen,
|
setIsMediaModalOpen,
|
||||||
}: BannerFormProps) {
|
}: BannerFormProps) {
|
||||||
@@ -69,8 +71,8 @@ export default function BannerForm({
|
|||||||
<label className="text-[10px] uppercase font-bold tracking-widest text-slate-400">Link URL</label>
|
<label className="text-[10px] uppercase font-bold tracking-widest text-slate-400">Link URL</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={getLocalizedValue(editingSection.payload, 'linkUrl')}
|
value={editingSection.payload?.linkUrl || ''}
|
||||||
onChange={(e) => updateLocalizedValue('linkUrl', e.target.value)}
|
onChange={(e) => updatePayloadValue('linkUrl', e.target.value)}
|
||||||
className="admin-input w-full"
|
className="admin-input w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ interface EditorialCarouselFormProps {
|
|||||||
updateLocalizedValue: (field: string, value: string) => void;
|
updateLocalizedValue: (field: string, value: string) => void;
|
||||||
getLocalizedSlideValue: (slide: any, field: string) => string;
|
getLocalizedSlideValue: (slide: any, field: string) => string;
|
||||||
updateLocalizedSlideValue: (idx: number, field: string, value: string) => void;
|
updateLocalizedSlideValue: (idx: number, field: string, value: string) => void;
|
||||||
|
updateSlidePayloadValue: (idx: number, field: string, value: string | number) => void;
|
||||||
setUploadTarget: (target: { type: 'main' | 'slide'; index?: number } | null) => void;
|
setUploadTarget: (target: { type: 'main' | 'slide'; index?: number } | null) => void;
|
||||||
setIsMediaModalOpen: (open: boolean) => void;
|
setIsMediaModalOpen: (open: boolean) => void;
|
||||||
}
|
}
|
||||||
@@ -21,6 +22,7 @@ export default function EditorialCarouselForm({
|
|||||||
updateLocalizedValue,
|
updateLocalizedValue,
|
||||||
getLocalizedSlideValue,
|
getLocalizedSlideValue,
|
||||||
updateLocalizedSlideValue,
|
updateLocalizedSlideValue,
|
||||||
|
updateSlidePayloadValue,
|
||||||
setUploadTarget,
|
setUploadTarget,
|
||||||
setIsMediaModalOpen,
|
setIsMediaModalOpen,
|
||||||
}: EditorialCarouselFormProps) {
|
}: EditorialCarouselFormProps) {
|
||||||
@@ -155,8 +157,8 @@ export default function EditorialCarouselForm({
|
|||||||
<label className="text-[10px] uppercase font-bold tracking-widest text-slate-500">Button Link</label>
|
<label className="text-[10px] uppercase font-bold tracking-widest text-slate-500">Button Link</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={getLocalizedSlideValue(slide, 'buttonLink')}
|
value={slide.buttonLink || ''}
|
||||||
onChange={(e) => updateLocalizedSlideValue(idx, 'buttonLink', e.target.value)}
|
onChange={(e) => updateSlidePayloadValue(idx, 'buttonLink', e.target.value)}
|
||||||
className="admin-input w-full text-xs"
|
className="admin-input w-full text-xs"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ interface EditorialTileFormProps {
|
|||||||
editingLang: string;
|
editingLang: string;
|
||||||
getLocalizedValue: (payload: any, field: string) => string;
|
getLocalizedValue: (payload: any, field: string) => string;
|
||||||
updateLocalizedValue: (field: string, value: string) => void;
|
updateLocalizedValue: (field: string, value: string) => void;
|
||||||
|
updatePayloadValue: (field: string, value: string | number) => void;
|
||||||
setUploadTarget: (target: { type: 'main' | 'slide'; index?: number } | null) => void;
|
setUploadTarget: (target: { type: 'main' | 'slide'; index?: number } | null) => void;
|
||||||
setIsMediaModalOpen: (open: boolean) => void;
|
setIsMediaModalOpen: (open: boolean) => void;
|
||||||
}
|
}
|
||||||
@@ -17,6 +18,7 @@ export default function EditorialTileForm({
|
|||||||
setEditingSection,
|
setEditingSection,
|
||||||
getLocalizedValue,
|
getLocalizedValue,
|
||||||
updateLocalizedValue,
|
updateLocalizedValue,
|
||||||
|
updatePayloadValue,
|
||||||
setUploadTarget,
|
setUploadTarget,
|
||||||
setIsMediaModalOpen,
|
setIsMediaModalOpen,
|
||||||
}: EditorialTileFormProps) {
|
}: EditorialTileFormProps) {
|
||||||
@@ -117,8 +119,8 @@ export default function EditorialTileForm({
|
|||||||
<label className="text-[10px] uppercase font-bold tracking-widest text-slate-400">Button Link</label>
|
<label className="text-[10px] uppercase font-bold tracking-widest text-slate-400">Button Link</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={getLocalizedValue(editingSection.payload, 'buttonLink')}
|
value={editingSection.payload?.buttonLink || ''}
|
||||||
onChange={(e) => updateLocalizedValue('buttonLink', e.target.value)}
|
onChange={(e) => updatePayloadValue('buttonLink', e.target.value)}
|
||||||
className="admin-input w-full"
|
className="admin-input w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ interface HeroArticleFormProps {
|
|||||||
editingLang: string;
|
editingLang: string;
|
||||||
getLocalizedValue: (payload: any, field: string) => string;
|
getLocalizedValue: (payload: any, field: string) => string;
|
||||||
updateLocalizedValue: (field: string, value: string) => void;
|
updateLocalizedValue: (field: string, value: string) => void;
|
||||||
|
updatePayloadValue: (field: string, value: string | number) => void;
|
||||||
setUploadTarget: (target: { type: 'main' | 'slide'; index?: number } | null) => void;
|
setUploadTarget: (target: { type: 'main' | 'slide'; index?: number } | null) => void;
|
||||||
setIsMediaModalOpen: (open: boolean) => void;
|
setIsMediaModalOpen: (open: boolean) => void;
|
||||||
}
|
}
|
||||||
@@ -17,6 +18,7 @@ export default function HeroArticleForm({
|
|||||||
setEditingSection,
|
setEditingSection,
|
||||||
getLocalizedValue,
|
getLocalizedValue,
|
||||||
updateLocalizedValue,
|
updateLocalizedValue,
|
||||||
|
updatePayloadValue,
|
||||||
setUploadTarget,
|
setUploadTarget,
|
||||||
setIsMediaModalOpen,
|
setIsMediaModalOpen,
|
||||||
}: HeroArticleFormProps) {
|
}: HeroArticleFormProps) {
|
||||||
@@ -74,8 +76,8 @@ export default function HeroArticleForm({
|
|||||||
<label className="text-[10px] uppercase font-bold tracking-widest text-slate-400">Author</label>
|
<label className="text-[10px] uppercase font-bold tracking-widest text-slate-400">Author</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={getLocalizedValue(editingSection.payload, 'author')}
|
value={editingSection.payload?.author || ''}
|
||||||
onChange={(e) => updateLocalizedValue('author', e.target.value)}
|
onChange={(e) => updatePayloadValue('author', e.target.value)}
|
||||||
className="admin-input w-full"
|
className="admin-input w-full"
|
||||||
placeholder="Author name"
|
placeholder="Author name"
|
||||||
/>
|
/>
|
||||||
@@ -85,8 +87,8 @@ export default function HeroArticleForm({
|
|||||||
<label className="text-[10px] uppercase font-bold tracking-widest text-slate-400">Category / Tag</label>
|
<label className="text-[10px] uppercase font-bold tracking-widest text-slate-400">Category / Tag</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={getLocalizedValue(editingSection.payload, 'category')}
|
value={editingSection.payload?.category || ''}
|
||||||
onChange={(e) => updateLocalizedValue('category', e.target.value)}
|
onChange={(e) => updatePayloadValue('category', e.target.value)}
|
||||||
className="admin-input w-full"
|
className="admin-input w-full"
|
||||||
placeholder="Story"
|
placeholder="Story"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ interface HeroFormProps {
|
|||||||
editingLang: string;
|
editingLang: string;
|
||||||
getLocalizedValue: (payload: any, field: string) => string;
|
getLocalizedValue: (payload: any, field: string) => string;
|
||||||
updateLocalizedValue: (field: string, value: string) => void;
|
updateLocalizedValue: (field: string, value: string) => void;
|
||||||
|
updatePayloadValue: (field: string, value: string | number) => void;
|
||||||
setUploadTarget: (target: { type: 'main' | 'slide'; index?: number } | null) => void;
|
setUploadTarget: (target: { type: 'main' | 'slide'; index?: number } | null) => void;
|
||||||
setIsMediaModalOpen: (open: boolean) => void;
|
setIsMediaModalOpen: (open: boolean) => void;
|
||||||
}
|
}
|
||||||
@@ -14,6 +15,7 @@ export default function HeroForm({
|
|||||||
editingSection,
|
editingSection,
|
||||||
getLocalizedValue,
|
getLocalizedValue,
|
||||||
updateLocalizedValue,
|
updateLocalizedValue,
|
||||||
|
updatePayloadValue,
|
||||||
setUploadTarget,
|
setUploadTarget,
|
||||||
setIsMediaModalOpen,
|
setIsMediaModalOpen,
|
||||||
}: HeroFormProps) {
|
}: HeroFormProps) {
|
||||||
@@ -95,8 +97,8 @@ export default function HeroForm({
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
required
|
required
|
||||||
value={getLocalizedValue(editingSection.payload, 'buttonLink')}
|
value={editingSection.payload?.buttonLink || ''}
|
||||||
onChange={(e) => updateLocalizedValue('buttonLink', e.target.value)}
|
onChange={(e) => updatePayloadValue('buttonLink', e.target.value)}
|
||||||
className="admin-input w-full"
|
className="admin-input w-full"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -118,6 +118,19 @@ export default function PageBuilderPage() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updatePayloadValue = (field: string, value: string | number) => {
|
||||||
|
setEditingSection(prev => {
|
||||||
|
if (!prev) return null;
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
payload: {
|
||||||
|
...(prev.payload || {}),
|
||||||
|
[field]: value
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const getLocalizedSlideValue = (slide: any, field: string) => {
|
const getLocalizedSlideValue = (slide: any, field: string) => {
|
||||||
if (!slide || slide[field] === undefined) return '';
|
if (!slide || slide[field] === undefined) return '';
|
||||||
const val = slide[field];
|
const val = slide[field];
|
||||||
@@ -150,6 +163,19 @@ export default function PageBuilderPage() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateSlidePayloadValue = (idx: number, field: string, value: string | number) => {
|
||||||
|
setEditingSection(prev => {
|
||||||
|
if (!prev) return null;
|
||||||
|
const currentSlides = [...(prev.payload?.slides || [])];
|
||||||
|
const slide = currentSlides[idx] || {};
|
||||||
|
currentSlides[idx] = { ...slide, [field]: value };
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
payload: { ...(prev.payload || {}), slides: currentSlides }
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const getLocalizedAnnouncementSlide = (slide: any) => {
|
const getLocalizedAnnouncementSlide = (slide: any) => {
|
||||||
if (typeof slide === 'string') {
|
if (typeof slide === 'string') {
|
||||||
return editingLang === 'th' ? slide : '';
|
return editingLang === 'th' ? slide : '';
|
||||||
@@ -1047,6 +1073,7 @@ export default function PageBuilderPage() {
|
|||||||
editingLang={editingLang}
|
editingLang={editingLang}
|
||||||
getLocalizedValue={getLocalizedValue}
|
getLocalizedValue={getLocalizedValue}
|
||||||
updateLocalizedValue={updateLocalizedValue}
|
updateLocalizedValue={updateLocalizedValue}
|
||||||
|
updatePayloadValue={updatePayloadValue}
|
||||||
setUploadTarget={setUploadTarget}
|
setUploadTarget={setUploadTarget}
|
||||||
setIsMediaModalOpen={setIsMediaModalOpen}
|
setIsMediaModalOpen={setIsMediaModalOpen}
|
||||||
/>
|
/>
|
||||||
@@ -1079,6 +1106,7 @@ export default function PageBuilderPage() {
|
|||||||
editingLang={editingLang}
|
editingLang={editingLang}
|
||||||
getLocalizedValue={getLocalizedValue}
|
getLocalizedValue={getLocalizedValue}
|
||||||
updateLocalizedValue={updateLocalizedValue}
|
updateLocalizedValue={updateLocalizedValue}
|
||||||
|
updatePayloadValue={updatePayloadValue}
|
||||||
setUploadTarget={setUploadTarget}
|
setUploadTarget={setUploadTarget}
|
||||||
setIsMediaModalOpen={setIsMediaModalOpen}
|
setIsMediaModalOpen={setIsMediaModalOpen}
|
||||||
/>
|
/>
|
||||||
@@ -1093,6 +1121,7 @@ export default function PageBuilderPage() {
|
|||||||
updateLocalizedValue={updateLocalizedValue}
|
updateLocalizedValue={updateLocalizedValue}
|
||||||
getLocalizedSlideValue={getLocalizedSlideValue}
|
getLocalizedSlideValue={getLocalizedSlideValue}
|
||||||
updateLocalizedSlideValue={updateLocalizedSlideValue}
|
updateLocalizedSlideValue={updateLocalizedSlideValue}
|
||||||
|
updateSlidePayloadValue={updateSlidePayloadValue}
|
||||||
setUploadTarget={setUploadTarget}
|
setUploadTarget={setUploadTarget}
|
||||||
setIsMediaModalOpen={setIsMediaModalOpen}
|
setIsMediaModalOpen={setIsMediaModalOpen}
|
||||||
/>
|
/>
|
||||||
@@ -1126,6 +1155,7 @@ export default function PageBuilderPage() {
|
|||||||
editingLang={editingLang}
|
editingLang={editingLang}
|
||||||
getLocalizedValue={getLocalizedValue}
|
getLocalizedValue={getLocalizedValue}
|
||||||
updateLocalizedValue={updateLocalizedValue}
|
updateLocalizedValue={updateLocalizedValue}
|
||||||
|
updatePayloadValue={updatePayloadValue}
|
||||||
setUploadTarget={setUploadTarget}
|
setUploadTarget={setUploadTarget}
|
||||||
setIsMediaModalOpen={setIsMediaModalOpen}
|
setIsMediaModalOpen={setIsMediaModalOpen}
|
||||||
/>
|
/>
|
||||||
@@ -1148,6 +1178,7 @@ export default function PageBuilderPage() {
|
|||||||
editingLang={editingLang}
|
editingLang={editingLang}
|
||||||
getLocalizedValue={getLocalizedValue}
|
getLocalizedValue={getLocalizedValue}
|
||||||
updateLocalizedValue={updateLocalizedValue}
|
updateLocalizedValue={updateLocalizedValue}
|
||||||
|
updatePayloadValue={updatePayloadValue}
|
||||||
setUploadTarget={setUploadTarget}
|
setUploadTarget={setUploadTarget}
|
||||||
setIsMediaModalOpen={setIsMediaModalOpen}
|
setIsMediaModalOpen={setIsMediaModalOpen}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user