Add client banner-by-id API and point frontend at new client endpoints.
Also save admin uploads locally under /public/images with a 10MB limit. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a3c87d231b
commit
ca0692d190
5 files changed
+144
-98
No files matched your search
@@ -143,6 +143,8 @@ func (h *handler) getProfile(c *gin.Context) {
|
|||||||
// @Router /admin/file [post]
|
// @Router /admin/file [post]
|
||||||
func (h *handler) fileUpload(c *gin.Context) {
|
func (h *handler) fileUpload(c *gin.Context) {
|
||||||
|
|
||||||
|
const maxUploadBytes = 10 << 20 // 10 MB
|
||||||
|
|
||||||
file, header, err := c.Request.FormFile("file")
|
file, header, err := c.Request.FormFile("file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(http.StatusBadRequest, "get form err: %s", err.Error())
|
c.String(http.StatusBadRequest, "get form err: %s", err.Error())
|
||||||
@@ -156,42 +158,56 @@ func (h *handler) fileUpload(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}(file)
|
}(file)
|
||||||
|
|
||||||
|
if header.Size > maxUploadBytes {
|
||||||
|
c.JSON(http.StatusBadRequest, gin.H{"error": "file size must not exceed 10 MB"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cfg := config.GetConfig()
|
cfg := config.GetConfig()
|
||||||
appDirPath := cfg.PublicFilePath + "/images/"
|
appDirPath := cfg.PublicFilePath + "/images/"
|
||||||
|
|
||||||
err = os.MkdirAll(appDirPath, os.ModePerm)
|
err = os.MkdirAll(appDirPath, os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("wwwww", err)
|
fmt.Println("wwwww", err)
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to create upload directory"})
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
appName := fmt.Sprintf("%d%s", time.Now().UnixNano(), filepath.Ext(header.Filename))
|
appName := fmt.Sprintf("%d%s", time.Now().UnixNano(), filepath.Ext(header.Filename))
|
||||||
dbPath := "/images/" + appName
|
dbPath := "/public/images/" + appName
|
||||||
|
localPath := appDirPath + appName
|
||||||
|
|
||||||
minioClient, err := minioUpload.ConnectionMinio()
|
if err := c.SaveUploadedFile(header, localPath); err != nil {
|
||||||
if err != nil {
|
fmt.Println("Error saving file to public/images:", err)
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "connection to MinIO failed"})
|
c.JSON(http.StatusInternalServerError, gin.H{"error": "File upload failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
contentType := header.Header.Get("Content-Type")
|
// minioClient, err := minioUpload.ConnectionMinio()
|
||||||
ctx := context.Background()
|
// if err != nil {
|
||||||
|
// c.JSON(http.StatusInternalServerError, gin.H{"error": "connection to MinIO failed"})
|
||||||
if err := minioUpload.EnsureBucket(ctx, minioClient); err != nil {
|
// return
|
||||||
fmt.Println("ensure bucket:", err)
|
// }
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to create MinIO bucket"})
|
//
|
||||||
return
|
// contentType := header.Header.Get("Content-Type")
|
||||||
}
|
// ctx := context.Background()
|
||||||
|
//
|
||||||
size := header.Size
|
// if err := minioUpload.EnsureBucket(ctx, minioClient); err != nil {
|
||||||
if size <= 0 {
|
// fmt.Println("ensure bucket:", err)
|
||||||
size = -1
|
// c.JSON(http.StatusInternalServerError, gin.H{"error": "failed to create MinIO bucket"})
|
||||||
}
|
// return
|
||||||
_, err = minioClient.PutObject(ctx, minioUpload.BucketName, appName, file, size, minio.PutObjectOptions{ContentType: contentType})
|
// }
|
||||||
if err != nil {
|
//
|
||||||
fmt.Println("Error uploading file to MinIO:", err)
|
// size := header.Size
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"error": "File upload to MinIO failed"})
|
// if size <= 0 {
|
||||||
return
|
// size = -1
|
||||||
}
|
// }
|
||||||
|
// _, err = minioClient.PutObject(ctx, minioUpload.BucketName, appName, file, size, minio.PutObjectOptions{ContentType: contentType})
|
||||||
|
// if err != nil {
|
||||||
|
// fmt.Println("Error uploading file to MinIO:", err)
|
||||||
|
// c.JSON(http.StatusInternalServerError, gin.H{"error": "File upload to MinIO failed"})
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
successResult := appresult.Success
|
successResult := appresult.Success
|
||||||
successResult.Data = dbPath
|
successResult.Data = dbPath
|
||||||
|
|||||||
@@ -180,6 +180,27 @@ func (r repository) GetBanners(ctx context.Context, limit, page int) (users.Data
|
|||||||
return dt, nil
|
return dt, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r repository) GetBannerById(ctx context.Context, id int) (users.BannerDTO, error) {
|
||||||
|
var b users.BannerDTO
|
||||||
|
|
||||||
|
q := ` SELECT
|
||||||
|
id, title,
|
||||||
|
content_tm, content_ru, content_en,
|
||||||
|
img, created_at
|
||||||
|
FROM banner
|
||||||
|
WHERE id = $1;`
|
||||||
|
|
||||||
|
err := r.client.QueryRow(ctx, q, id).Scan(
|
||||||
|
&b.Id, &b.Title,
|
||||||
|
&b.ContentTm, &b.ContentRu, &b.ContentEn,
|
||||||
|
&b.Image, &b.CreatedAt,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return b, err
|
||||||
|
}
|
||||||
|
return b, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (r repository) GetStatics(ctx context.Context, limit, page int) (users.DataStaticDTO, error) {
|
func (r repository) GetStatics(ctx context.Context, limit, page int) (users.DataStaticDTO, error) {
|
||||||
|
|
||||||
var dt users.DataStaticDTO
|
var dt users.DataStaticDTO
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ const (
|
|||||||
getCategoriesURL = "/categories"
|
getCategoriesURL = "/categories"
|
||||||
getOneSubCategoryURL = "/sub-categories/:id"
|
getOneSubCategoryURL = "/sub-categories/:id"
|
||||||
getBannersURL = "/banners"
|
getBannersURL = "/banners"
|
||||||
|
getOneBannerURL = "/banners/:id"
|
||||||
getStaticsURL = "/static"
|
getStaticsURL = "/static"
|
||||||
getOneStaticURL = "/static/:id"
|
getOneStaticURL = "/static/:id"
|
||||||
getCurrencyURL = "/currency"
|
getCurrencyURL = "/currency"
|
||||||
@@ -40,6 +41,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
|
|||||||
router.GET(getCategoriesURL, h.GetCategories)
|
router.GET(getCategoriesURL, h.GetCategories)
|
||||||
router.GET(getOneSubCategoryURL, h.GetSubCategory)
|
router.GET(getOneSubCategoryURL, h.GetSubCategory)
|
||||||
router.GET(getBannersURL, h.GetBanners)
|
router.GET(getBannersURL, h.GetBanners)
|
||||||
|
router.GET(getOneBannerURL, h.GetOneBanner)
|
||||||
router.GET(getStaticsURL, h.GetStatics)
|
router.GET(getStaticsURL, h.GetStatics)
|
||||||
router.GET(getOneStaticURL, h.GetOneStatic)
|
router.GET(getOneStaticURL, h.GetOneStatic)
|
||||||
router.GET(getCurrencyURL, h.GetCurrency)
|
router.GET(getCurrencyURL, h.GetCurrency)
|
||||||
@@ -154,6 +156,32 @@ func (h *handler) GetBanners(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, successResult)
|
c.JSON(http.StatusOK, successResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetOneBanner godoc
|
||||||
|
// @Description banner by id
|
||||||
|
// @Tags banners
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param id path int true "banner ID"
|
||||||
|
// @Success 200 {object} BannerDTO
|
||||||
|
// @Router /client/users/banners/{id} [get]
|
||||||
|
func (h *handler) GetOneBanner(c *gin.Context) {
|
||||||
|
id, err := strconv.Atoi(c.Param("id"))
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusNotFound, appresult.ErrNotAcceptable)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := h.repository.GetBannerById(c.Request.Context(), id)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
successResult := appresult.Success
|
||||||
|
successResult.Data = result
|
||||||
|
c.JSON(http.StatusOK, successResult)
|
||||||
|
}
|
||||||
|
|
||||||
// GetStatics godoc
|
// GetStatics godoc
|
||||||
// @Description all static data
|
// @Description all static data
|
||||||
// @Tags statics
|
// @Tags statics
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ type Repository interface {
|
|||||||
GetSubCategoryById(ctx context.Context, id int) (SubCategoryDTO, error)
|
GetSubCategoryById(ctx context.Context, id int) (SubCategoryDTO, error)
|
||||||
|
|
||||||
GetBanners(ctx context.Context, limit, page int) (DataBannerDTO, error)
|
GetBanners(ctx context.Context, limit, page int) (DataBannerDTO, error)
|
||||||
|
GetBannerById(ctx context.Context, id int) (BannerDTO, error)
|
||||||
|
|
||||||
GetStatics(ctx context.Context, limit, page int) (DataStaticDTO, error)
|
GetStatics(ctx context.Context, limit, page int) (DataStaticDTO, error)
|
||||||
GetStaticById(ctx context.Context, id int) (StaticDTO, error)
|
GetStaticById(ctx context.Context, id int) (StaticDTO, error)
|
||||||
|
|||||||
+55
-75
@@ -26,21 +26,29 @@ function removeByClassName(className) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function baseUrl() {
|
function baseUrl() {
|
||||||
return 'https://tbbank.gov.tm';
|
return 'http://216.250.10.141';
|
||||||
}
|
}
|
||||||
|
|
||||||
function postData(url = '', data = {}) {
|
function getData(url = '') {
|
||||||
return fetch(baseUrl() + url, {
|
return fetch(baseUrl() + url, {
|
||||||
method: 'POST',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json'
|
||||||
'Content-Type': 'application/json'
|
}
|
||||||
},
|
|
||||||
body: JSON.stringify(data)
|
|
||||||
})
|
})
|
||||||
.then(response => response.json());
|
.then(response => response.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function localizedContent(item) {
|
||||||
|
if (window.locale === 'ru') {
|
||||||
|
return item.contentRu
|
||||||
|
}
|
||||||
|
if (window.locale === 'en') {
|
||||||
|
return item.contentEn
|
||||||
|
}
|
||||||
|
return item.contentTm
|
||||||
|
}
|
||||||
|
|
||||||
function getCurrentLang()
|
function getCurrentLang()
|
||||||
{
|
{
|
||||||
return window.location.search.includes('lang=ru') ? 'ru' : '';
|
return window.location.search.includes('lang=ru') ? 'ru' : '';
|
||||||
@@ -89,8 +97,7 @@ function setTranslations() {
|
|||||||
|
|
||||||
function fetchPhoneNumbers()
|
function fetchPhoneNumbers()
|
||||||
{
|
{
|
||||||
fetch(baseUrl() + '/api/v1/setting/get')
|
getData('/api/v1/client/users/setting')
|
||||||
.then(response => response.json())
|
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (! response.status) {
|
if (! response.status) {
|
||||||
return;
|
return;
|
||||||
@@ -120,20 +127,18 @@ async function fetchMenuItems() {
|
|||||||
const container = $_ID('menu-items-container')
|
const container = $_ID('menu-items-container')
|
||||||
const sideBarMenuItems = $_ID('sidebar-menu-items')
|
const sideBarMenuItems = $_ID('sidebar-menu-items')
|
||||||
|
|
||||||
const response = await postData('/api/v1/category/get-no-content')
|
const response = await getData('/api/v1/client/users/categories')
|
||||||
|
|
||||||
response.data.forEach(menuItem => {
|
response.data.forEach(menuItem => {
|
||||||
let subcategoriesTemplate = '';
|
let subcategoriesTemplate = '';
|
||||||
|
|
||||||
if (menuItem.subCat && menuItem.subCat.length > 0 ) {
|
if (menuItem.subCategories && menuItem.subCategories.length > 0 ) {
|
||||||
menuItem.subCat.forEach(subcategory => {
|
menuItem.subCategories.forEach(subcategory => {
|
||||||
if (subcategory.UUID && subcategory.name) {
|
if (subcategory.id && subcategory.name) {
|
||||||
subcategoriesTemplate += `
|
subcategoriesTemplate += `
|
||||||
<li>
|
<li>
|
||||||
<a class="bg-trasparent lg:bg-white" href="${
|
<a class="bg-trasparent lg:bg-white" href="${
|
||||||
(subcategory.link || subcategory.pdf)
|
'/page.html?id=' + subcategory.id + '&lang=' + getCurrentLang()
|
||||||
? subcategory.link ? subcategory.link : subcategory.pdf
|
|
||||||
: '/page.html?uuid=' + subcategory.UUID + '&lang=' + getCurrentLang()
|
|
||||||
}">
|
}">
|
||||||
${subcategory.name[window.locale]}
|
${subcategory.name[window.locale]}
|
||||||
</a>
|
</a>
|
||||||
@@ -181,21 +186,21 @@ async function fetchMenuItems() {
|
|||||||
async function fetchSliders() {
|
async function fetchSliders() {
|
||||||
const imageSliderContainer = $_ID('slider-images-container')
|
const imageSliderContainer = $_ID('slider-images-container')
|
||||||
|
|
||||||
const response = await postData('/api/v1/main_slider/get-all')
|
const response = await getData('/api/v1/client/users/banners')
|
||||||
|
|
||||||
removeByClassName('homepage-slider-loader')
|
removeByClassName('homepage-slider-loader')
|
||||||
|
|
||||||
response.data.forEach(slider => {
|
response.data.banners.forEach(slider => {
|
||||||
imageSliderContainer.insertAdjacentHTML('beforeend', `
|
imageSliderContainer.insertAdjacentHTML('beforeend', `
|
||||||
<swiper-slide>
|
<swiper-slide>
|
||||||
|
|
||||||
<a href="${
|
<a href="${
|
||||||
slider.UUID
|
slider.id
|
||||||
? `/banner.html?uuid=${slider.UUID}` + '&lang=' + getCurrentLang()
|
? `/banner.html?id=${slider.id}` + '&lang=' + getCurrentLang()
|
||||||
: ''
|
: ''
|
||||||
}">
|
}">
|
||||||
<img
|
<img
|
||||||
src="${baseUrl() + slider.slider}"
|
src="${baseUrl() + slider.imagePath}"
|
||||||
class="mx-auto w-fit cursor-pointer" alt="slider"
|
class="mx-auto w-fit cursor-pointer" alt="slider"
|
||||||
>
|
>
|
||||||
</a>
|
</a>
|
||||||
@@ -207,44 +212,21 @@ async function fetchSliders() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function fetchMiniSliders() {
|
async function fetchMiniSliders() {
|
||||||
const imageSliderContainer = $_ID('mini-slider')
|
|
||||||
const dotsContainer = $_ID('mini-slider-dots-container')
|
|
||||||
|
|
||||||
const response = await postData('/api/v1/mini_slider/get-all')
|
|
||||||
|
|
||||||
removeByClassName('minislider-loader')
|
removeByClassName('minislider-loader')
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
response.data.forEach(slider => {
|
|
||||||
count++;
|
|
||||||
|
|
||||||
imageSliderContainer.insertAdjacentHTML('beforeend', `
|
|
||||||
<div class="mySlides fade w-full relative">
|
|
||||||
<div class="numbertext"></div>
|
|
||||||
<img class="w-full" src="${baseUrl() + slider.path}" loading="lazy">
|
|
||||||
<div
|
|
||||||
class="text mb-5 py-5 px-3 text-white text-2xl"
|
|
||||||
style="background-color: rgba(0, 0, 0, .75)"
|
|
||||||
>${slider.title['tm']}</div>
|
|
||||||
</div>
|
|
||||||
`)
|
|
||||||
})
|
|
||||||
|
|
||||||
initializeMiniSlider()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchMiniCategories() {
|
async function fetchMiniCategories() {
|
||||||
const miniCategoryContainer = $_ID('mini-category-content-container')
|
const miniCategoryContainer = $_ID('mini-category-content-container')
|
||||||
|
|
||||||
const response = await postData('/api/v1/mini_category/get-all')
|
const response = await getData('/api/v1/client/users/static')
|
||||||
|
|
||||||
removeByClassName('mini-categories-loader')
|
removeByClassName('mini-categories-loader')
|
||||||
|
|
||||||
response.data.forEach(category => {
|
response.data.statics.forEach(category => {
|
||||||
miniCategoryContainer.insertAdjacentHTML('beforeend', `
|
miniCategoryContainer.insertAdjacentHTML('beforeend', `
|
||||||
<a href="/action.html?uuid=${category.UUID + '&lang=' + getCurrentLang()}">
|
<a href="/action.html?id=${category.id + '&lang=' + getCurrentLang()}">
|
||||||
<div class="bg-gray-100 flex flex-1 flex-col items-center gap-3 py-7 px-3 mt-2 rounded-md">
|
<div class="bg-gray-100 flex flex-1 flex-col items-center gap-3 py-7 px-3 mt-2 rounded-md">
|
||||||
<img src="${baseUrl() + category.path}" class="w-16 h-16" alt="..." loading="lazy">
|
<img src="${baseUrl() + category.logo}" class="w-16 h-16" alt="..." loading="lazy">
|
||||||
<h1 class="text-gray-700 uppercase text-center">${category.title[window.locale]}</h1>
|
<h1 class="text-gray-700 uppercase text-center">${category.title[window.locale]}</h1>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
@@ -254,7 +236,7 @@ async function fetchMiniCategories() {
|
|||||||
|
|
||||||
async function fetchCurrencies() {
|
async function fetchCurrencies() {
|
||||||
const currencyTable = $_ID('currency-table')
|
const currencyTable = $_ID('currency-table')
|
||||||
const response = await postData('/api/v1/currency/get')
|
const response = await getData('/api/v1/client/users/currency')
|
||||||
|
|
||||||
removeByClassName('currency-table-loader')
|
removeByClassName('currency-table-loader')
|
||||||
currencyTable.innerHTML = response.data.content[window.locale];
|
currencyTable.innerHTML = response.data.content[window.locale];
|
||||||
@@ -277,11 +259,11 @@ async function fetchCurrencies() {
|
|||||||
|
|
||||||
async function fetchNews() {
|
async function fetchNews() {
|
||||||
const newsContainer = $_ID('news-content-container')
|
const newsContainer = $_ID('news-content-container')
|
||||||
const response = await postData('/api/v1/news/get-all')
|
const response = await getData('/api/v1/client/users/news')
|
||||||
|
|
||||||
removeByClassName('news-loaders')
|
removeByClassName('news-loaders')
|
||||||
let count = 0;
|
let count = 0;
|
||||||
response.data.forEach(news => {
|
response.data.news.forEach(news => {
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (count > 6) {
|
if (count > 6) {
|
||||||
@@ -289,10 +271,10 @@ async function fetchNews() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newsContainer.insertAdjacentHTML('beforeend', `
|
newsContainer.insertAdjacentHTML('beforeend', `
|
||||||
<a href="news.html?uuid=${news.UUID + '&lang=' + getCurrentLang()}">
|
<a href="news.html?id=${news.id + '&lang=' + getCurrentLang()}">
|
||||||
<div class="flex flex-col px-3 mt-3">
|
<div class="flex flex-col px-3 mt-3">
|
||||||
<div class="h-60">
|
<div class="h-60">
|
||||||
<img src="${baseUrl() + news.path}" class="news-img-size" alt="..." loading="lazy">
|
<img src="${baseUrl() + news.imagePath}" class="news-img-size" alt="..." loading="lazy">
|
||||||
</div>
|
</div>
|
||||||
<h1 class="text-base text-gray-800 mt-2 py-2 px-1 text-center">${news.title[window.locale]}</h1>
|
<h1 class="text-base text-gray-800 mt-2 py-2 px-1 text-center">${news.title[window.locale]}</h1>
|
||||||
</div>
|
</div>
|
||||||
@@ -304,15 +286,13 @@ async function fetchNews() {
|
|||||||
async function fetchSubCategory() {
|
async function fetchSubCategory() {
|
||||||
const pageURL = new URL(location);
|
const pageURL = new URL(location);
|
||||||
|
|
||||||
if (! pageURL.searchParams.has('uuid')) {
|
if (! pageURL.searchParams.has('id')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageContent = $_ID('page-content');
|
const pageContent = $_ID('page-content');
|
||||||
|
|
||||||
const response = await postData('/api/v1/category/sub-get', {
|
const response = await getData('/api/v1/client/users/sub-categories/' + pageURL.searchParams.get('id'))
|
||||||
UUID: pageURL.searchParams.get('uuid')
|
|
||||||
})
|
|
||||||
|
|
||||||
removeByClassName('page-content-loader')
|
removeByClassName('page-content-loader')
|
||||||
|
|
||||||
@@ -330,29 +310,33 @@ async function fetchSubCategory() {
|
|||||||
async function fetchBannerContent() {
|
async function fetchBannerContent() {
|
||||||
const pageURL = new URL(location);
|
const pageURL = new URL(location);
|
||||||
|
|
||||||
if (! pageURL.searchParams.has('uuid')) {
|
if (! pageURL.searchParams.has('id')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageContent = $_ID('page-content');
|
const pageContent = $_ID('page-content');
|
||||||
|
const bannerId = Number(pageURL.searchParams.get('id'))
|
||||||
|
|
||||||
const response = await postData('/api/v1/main_slider/get', {
|
const response = await getData('/api/v1/client/users/banners')
|
||||||
UUID: pageURL.searchParams.get('uuid')
|
const banner = (response.data.banners || []).find(item => item.id === bannerId)
|
||||||
})
|
|
||||||
|
|
||||||
removeByClassName('page-content-loader')
|
removeByClassName('page-content-loader')
|
||||||
|
|
||||||
|
if (! banner) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
pageContent.innerHTML = `
|
pageContent.innerHTML = `
|
||||||
<h1 id="page-title" class="uppercase mt-5 mb-5 text-center text-lg green-color text-bold">
|
<h1 id="page-title" class="uppercase mt-5 mb-5 text-center text-lg green-color text-bold">
|
||||||
${response.data.title[window.locale]}
|
${banner.title[window.locale]}
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<img src="${baseUrl() + response.data.path}" class="w-full">
|
<img src="${baseUrl() + banner.imagePath}" class="w-full">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
${response.data.content[window.locale]}
|
${localizedContent(banner)}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -360,15 +344,13 @@ async function fetchBannerContent() {
|
|||||||
async function fetchMiniCategory() {
|
async function fetchMiniCategory() {
|
||||||
const pageURL = new URL(location);
|
const pageURL = new URL(location);
|
||||||
|
|
||||||
if (! pageURL.searchParams.has('uuid')) {
|
if (! pageURL.searchParams.has('id')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageContent = $_ID('page-content');
|
const pageContent = $_ID('page-content');
|
||||||
|
|
||||||
const response = await postData('/api/v1/mini_category/get', {
|
const response = await getData('/api/v1/client/users/static/' + pageURL.searchParams.get('id'))
|
||||||
UUID: pageURL.searchParams.get('uuid')
|
|
||||||
})
|
|
||||||
|
|
||||||
removeByClassName('page-content-loader')
|
removeByClassName('page-content-loader')
|
||||||
|
|
||||||
@@ -378,7 +360,7 @@ async function fetchMiniCategory() {
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
${response.data.content[window.locale]}
|
${localizedContent(response.data)}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
@@ -386,15 +368,13 @@ async function fetchMiniCategory() {
|
|||||||
async function fetchNewsContent() {
|
async function fetchNewsContent() {
|
||||||
const pageURL = new URL(location);
|
const pageURL = new URL(location);
|
||||||
|
|
||||||
if (! pageURL.searchParams.has('uuid')) {
|
if (! pageURL.searchParams.has('id')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageContent = $_ID('page-content');
|
const pageContent = $_ID('page-content');
|
||||||
|
|
||||||
const response = await postData('/api/v1/news/get', {
|
const response = await getData('/api/v1/client/users/news/' + pageURL.searchParams.get('id'))
|
||||||
UUID: pageURL.searchParams.get('uuid')
|
|
||||||
})
|
|
||||||
|
|
||||||
removeByClassName('page-content-loader')
|
removeByClassName('page-content-loader')
|
||||||
|
|
||||||
@@ -404,12 +384,12 @@ async function fetchNewsContent() {
|
|||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<div class="mb-5">
|
<div class="mb-5">
|
||||||
<img class="w-full max-h-[600px] object-contain" src="${baseUrl() + response.data.path}">
|
<img class="w-full max-h-[600px] object-contain" src="${baseUrl() + response.data.imagePath}">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p class="mb-2">
|
<p class="mb-2">
|
||||||
${ new Date(response.data.date).toLocaleDateString('en-GB').replace(/\//g, '.') + 'ý' }
|
${ new Date(response.data.dateRelease).toLocaleDateString('en-GB').replace(/\//g, '.') + 'ý' }
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
${response.data.content[window.locale]}
|
${response.data.content[window.locale]}
|
||||||
|
|||||||
Reference in new issue
Block a user