diff --git a/Discord/discordIndex.js b/Discord/discordIndex.js index ed5bde2..0b62dc6 100644 --- a/Discord/discordIndex.js +++ b/Discord/discordIndex.js @@ -183,7 +183,7 @@ module.exports = (Discord2, client) => { new Discord.EmbedBuilder() .setTitle('Selecione abaixo o item que deseja excluir!') .setDescription(`Clique em cancelar caso desista de excluir um item!`) - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) + .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png` }) .setColor('personalize' in server && 'colorDest' in server.personalize ? server.personalize.colorDest : '#6E58C7') .setThumbnail(`https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp`) .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) @@ -213,7 +213,6 @@ module.exports = (Discord2, client) => { preCarrinhos[interaction.user.id] if (findCart) { preCarrinhos[interaction.user.id][findIndexCart].quantidade = parseInt(value) - console.log(preCarrinhos[interaction.user.id][findIndexCart]); } else { preCarrinhos[interaction.user.id].push({ product: product, @@ -227,10 +226,9 @@ module.exports = (Discord2, client) => { - // interacao do botao de compra de um produto - if (interaction.customId && interaction.customId.includes('comprar')) { + async function comprarFunction(productID) { let server = await db.findOne({ colecao: "servers", doc: interaction.guildId }) - let product = await server.products.find(product => product.productID == interaction.customId.replace('comprar_', '')) + let product = await server.products.find(product => product.productID == productID) let findChannel = interaction.guild.channels.cache.find(c => c.topic === interaction.user.id && c.name && c.name.includes('🛒・carrinho・')) if (!product || server.error == true || product.estoque.length <= 0) { await interaction.reply({ content: `⚠️| O produto selecionado está sem estoque!`, ephemeral: true }) @@ -259,7 +257,7 @@ module.exports = (Discord2, client) => { return } async function findUniCarrinhos() { - let prodid = await interaction.customId.replace('comprar_', '') + let prodid = productID let findItem if (preCarrinhos[interaction.user.id]) { findItem = await preCarrinhos[interaction.user.id].find(element => element.product == prodid) @@ -284,7 +282,7 @@ module.exports = (Discord2, client) => { await deleteExpiredCart(interaction.guildId, interaction, findChannel.id) return } - let prodid = await interaction.customId.replace('comprar_', '') + let prodid = await productID let findProductCart = await carrinhos[interaction.user.id].find((item) => item.product == prodid) let findProductCartIndex = await carrinhos[interaction.user.id].findIndex((item) => item.product == prodid) if (findProductCart) { @@ -383,13 +381,15 @@ module.exports = (Discord2, client) => { edit: false }) } - + } + // interacao do botao de compra de um produto + if (interaction.customId && interaction.customId.includes('comprar')) { + comprarFunction(interaction.customId.replace('comprar_', '')) } - - - - + if (interaction.customId == 'multSelectProduct') { + comprarFunction(interaction.values[0]) + } @@ -559,7 +559,7 @@ module.exports = (Discord2, client) => { .setDescription(`Pix Copiar e Colar: ${'**```' + cpc + '```**'}`) .setImage('attachment://qrcodepix.png') - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) + .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png` }) .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) ], components: [new Discord.ActionRowBuilder() @@ -689,7 +689,7 @@ module.exports = (Discord2, client) => { } if (interaction.customId && interaction.customId.includes('productSendConfirm')) { - let quantidade = parseInt(interaction.customId.replace('productSendConfirm-','')) + let quantidade = parseInt(interaction.customId.replace('productSendConfirm-', '')) if (sendProduct[interaction.guild.id] && sendProduct[interaction.guild.id].user && sendProduct[interaction.guild.id].product) { let server = await db.findOne({ colecao: "servers", doc: interaction.guild.id }) const user = await client.users.fetch(await sendProduct[interaction.guild.id].user); @@ -706,13 +706,13 @@ module.exports = (Discord2, client) => { for (let index = 0; index < quantidade; index++) { const element2 = estoqueData[0].conteudo; - await element2.forEach(element=>{ + await element2.forEach(element => { fields.push({ name: element.title, value: "`" + element.content + "`" }) }) await estoqueData.splice(0, 1); product.estoque = estoqueData server.products[productIndex] = product - db.update('servers',interaction.guild.id,{ + db.update('servers', interaction.guild.id, { products: server.products }) } @@ -724,19 +724,19 @@ module.exports = (Discord2, client) => { new Discord.EmbedBuilder() .setTitle(`🛍️ | Você recebeu um produto!`) .setDescription(`Você recebeu um novo produto de ${SendUser.globalName}`) - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) + .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png` }) .setColor('personalize' in server && 'colorDest' in server.personalize ? server.personalize.colorDest : '#6E58C7') .setTimestamp() .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp ` }) ], - files:[attachment] + files: [attachment] }).then((res) => { interaction.reply({ embeds: [ new Discord.EmbedBuilder() .setTitle(`✅ | Produto enviado!`) .setDescription(`Você enviou um produto para ${user.globalName} Abaixo esta uma copia do que foi enviado:`) - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) + .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png` }) .setColor('personalize' in server && 'colorDest' in server.personalize ? server.personalize.colorDest : '#6E58C7') .setTimestamp() .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp ` }) @@ -746,7 +746,7 @@ module.exports = (Discord2, client) => { }).catch(err => { console.log("err", err); }) - + db.update('servers', interaction.guild.id, { products: server.products @@ -1554,7 +1554,7 @@ module.exports.sendProductPayment = async (params, id, type) => { productID: element.product, edit: true }) - }else{ + } else { require('../Discord/createProductMessage.js')(Discord, client, { channelID: product.channel, serverID: params.serverID, @@ -1572,7 +1572,7 @@ module.exports.sendProductPayment = async (params, id, type) => { productID: element.product, edit: true }) - }else{ + } else { require('../Discord/createProductMessage.js')(Discord, client, { channelID: product.channel, serverID: params.serverID, @@ -1591,7 +1591,7 @@ module.exports.sendProductPayment = async (params, id, type) => { productID: element.product, edit: true }) - }else{ + } else { require('../Discord/createProductMessage.js')(Discord, client, { channelID: product.channel, serverID: params.serverID, @@ -1634,7 +1634,7 @@ module.exports.sendProductPayment = async (params, id, type) => { new Discord.EmbedBuilder() .setTitle('📦 | Sua entrega chegou!') .setDescription(`Abaixo estão os dados da sua entrega:`) - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) + .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png` }) .setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7') .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) ], @@ -1645,57 +1645,58 @@ module.exports.sendProductPayment = async (params, id, type) => { const fetched = await findChannel.messages.fetch({ limit: 100 }).then(() => { }).catch(() => { }); findChannel.bulkDelete(fetched).then(() => { }).catch(() => { }) - if (fields.length >= 25) { - sendTxtMensage(findChannel) - sendTxtMensage(user) - sendTxtMensage(dono) - } else { - try { - // dono.send({ files: [attachment] }).catch(()=>{}); - await user.send({ - embeds: [ - new Discord.EmbedBuilder() - .setTitle('📦 | Sua entrega chegou!') - .setDescription(`Abaixo estão os dados da sua entrega:`) - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`,}) - .setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7') - .addFields(...fields) - .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) - ], - }).catch(() => { - sendTxtMensage(user) - }) - findChannel.send({ - embeds: [ - new Discord.EmbedBuilder() - .setTitle('📦 | Sua entrega chegou!') - .setDescription(`Enviamos a entrega no seu privado caso não tenha recebido o seu privado pode esta bloqueado então tenha certeza de baixar os arquivos antes que o carrinho seja fechado`) - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) - .setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7') - .addFields(...fields) - .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) - ], - components: [ - new Discord.ActionRowBuilder() - .addComponents( - new Discord.ButtonBuilder() - .setStyle(4) - .setLabel('Fechar carrinho') - .setCustomId('cancel') - ) - ], - }).catch(() => { - sendTxtMensage(findChannel) - }) - // findChannel.send({ files: [attachment] }).catch(()=>{}); - - } catch (error) { - sendTxtMensage(findChannel) - sendTxtMensage(user) - sendTxtMensage(dono) - } - } + + // if (fields.length >= 25) { + sendTxtMensage(findChannel) + sendTxtMensage(user) + // } else { + // try { + // // dono.send({ files: [attachment] }).catch(()=>{}); + // await user.send({ + // embeds: [ + // new Discord.EmbedBuilder() + // .setTitle('📦 | Sua entrega chegou!') + // .setDescription(`Abaixo estão os dados da sua entrega:`) + // .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`,}) + // .setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7') + // .addFields(...fields) + // .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) + // ], + // }).catch(() => { + // sendTxtMensage(user) + // }) + // findChannel.send({ + // embeds: [ + // new Discord.EmbedBuilder() + // .setTitle('📦 | Sua entrega chegou!') + // .setDescription(`Enviamos a entrega no seu privado caso não tenha recebido o seu privado pode esta bloqueado então tenha certeza de baixar os arquivos antes que o carrinho seja fechado`) + // .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) + // .setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7') + // .addFields(...fields) + // .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) + // ], + // components: [ + // new Discord.ActionRowBuilder() + // .addComponents( + // new Discord.ButtonBuilder() + // .setStyle(4) + // .setLabel('Fechar carrinho') + // .setCustomId('cancel') + // ) + // ], + // }).catch(() => { + // sendTxtMensage(findChannel) + // }) + // // findChannel.send({ files: [attachment] }).catch(()=>{}); + + + // } catch (error) { + // sendTxtMensage(findChannel) + // sendTxtMensage(user) + // sendTxtMensage(dono) + // } + // } if ('saleLogs' in serverData && serverData.saleLogs.publicLog) { try { @@ -1718,7 +1719,7 @@ module.exports.sendProductPayment = async (params, id, type) => { .addComponents( new Discord.ButtonBuilder() .setStyle(5) - .setLabel('📤・Ir para o produto') + .setLabel('📤・Produto') .setURL(`https://discord.com/channels/${params.serverID}/${findChannelProduct.id}`) )] } @@ -1744,30 +1745,7 @@ module.exports.sendProductPayment = async (params, id, type) => { if ('saleLogs' in serverData && serverData.saleLogs.privateLog) { let findChannelPrivate = DiscordServer.channels.cache.find(c => c.id === serverData.saleLogs.privateLog) try { - - findChannelPrivate.send({ - embeds: [ - new Discord.EmbedBuilder() - .setTitle(`Nova compra no servidor!`) - .setDescription(`Abaixo estão os dados que foram entregues:`) - .addFields( - { name: '\u200B', value: '\u200B' }, - { name: 'Nome do usuario comprador', value: user.username, inline: true }, - { name: 'ID do usuario', value: user.id, inline: true }, - { name: 'ID da compra', value: findChannel.id }, - { name: 'Data e hora da compra', value: dataHoraFormatada }, - { name: '\u200B', value: '\u200B' }, - ...fields - ) - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) - .setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7') - .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) - ], - }).catch(() => { - - sendTxtMensage(dono) - }) - } catch (error) { + findChannelPrivate.send({ embeds: [ new Discord.EmbedBuilder() @@ -1781,14 +1759,14 @@ module.exports.sendProductPayment = async (params, id, type) => { { name: 'Data e hora da compra', value: dataHoraFormatada }, { name: '\u200B', value: '\u200B' }, ) - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) + .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png` }) .setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7') .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) ], }) - sendTxtMensage(dono) - } - }else{ + findChannelPrivate.send({ files: [attachment] }).catch(() => { }); + } catch (error) { } + } else { try { await dono.send({ embeds: [ @@ -1804,13 +1782,12 @@ module.exports.sendProductPayment = async (params, id, type) => { { name: '\u200B', value: '\u200B' }, ...fields ) - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) + .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png` }) .setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7') .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) ], - }).catch(() => { - sendTxtMensage(dono) }) + dono.send({ files: [attachment] }).catch(() => { }); } catch (error) { await dono.send({ embeds: [ @@ -1825,7 +1802,7 @@ module.exports.sendProductPayment = async (params, id, type) => { { name: 'Data e hora da compra', value: dataHoraFormatada }, { name: '\u200B', value: '\u200B' }, ) - .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png`}) + .setAuthor({ name: "SDKApps", iconURL: `https://res.cloudinary.com/dgcnfudya/image/upload/v1711769157/vyzyvzxajoboweorxh9s.png` }) .setColor('personalize' in serverData && 'colorDest' in serverData.personalize ? serverData.personalize.colorDest : '#6E58C7') .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) ], @@ -1833,7 +1810,7 @@ module.exports.sendProductPayment = async (params, id, type) => { sendTxtMensage(dono) } } - + if ('personalize' in serverData && 'cargoPay' in serverData.personalize) { try { diff --git a/public/css/sales.css b/public/css/sales.css index d96cfb7..02f895c 100644 --- a/public/css/sales.css +++ b/public/css/sales.css @@ -145,208 +145,214 @@ - -#product-cadastro-containner { +.estoque-config-input-content-conteudo { width: 90%; display: flex; - justify-content: center; + flex-direction: column; +} + +.product-cadastro-containner{ + width: 90%; + flex-direction: column; align-items: center; - margin-top: 6%; - margin-bottom: 5em; + justify-content: center; + display: flex; + margin-bottom: 2em; +} +.product-cadastro-content { + padding: 1em; + width: 90%; + border-radius: var(--border-radius-min); + background-color: var(--secundary-color); - #product-cadastro-content { + .cadastro-content { + width: 100%; + height: calc(100% - 2.5em); + display: flex; padding: 1em; - width: 90%; - border-radius: var(--border-radius-min); - background-color: var(--secundary-color); + gap: 1em; + justify-content: space-around; + align-items: center; - #cadastro-content { - width: 100%; - height: calc(100% - 2.5em); - display: flex; + .cadastro-left-content, + .cadastro-rigth-content { + width: 45%; + height: 100%; padding: 1em; - gap: 1em; - justify-content: space-around; + margin-top: 1em; + } + + .cadastro-left-content { + display: flex; align-items: center; + justify-content: space-around; + flex-direction: column; + gap: 1em; - #cadastro-left-content, - #cadastro-rigth-content { - width: 45%; - height: 100%; - padding: 1em; - margin-top: 1em; + .channels-containner { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + gap: 1em; + + .cannels-title { + text-align: center; + font-size: 1.2em; + font-weight: 500; + color: var(--color-text-primary); + font-family: 'poppins'; + } } - #cadastro-left-content { + .backGround-containner { display: flex; - align-items: center; - justify-content: space-around; flex-direction: column; - gap: 1em; + gap: 1.5em; - #channels-containner { + .backGround-title { + text-align: center; + font-size: 1.2em; + font-weight: 500; + color: var(--color-text-primary); + font-family: 'poppins'; display: flex; - flex-direction: column; - justify-content: center; align-items: center; - gap: 1em; + justify-content: center; - #cannels-title { - text-align: center; - font-size: 1.2em; - font-weight: 500; - color: var(--color-text-primary); - font-family: 'poppins'; + #svg-premium { + width: 2em; } } - #backGround-containner { + .backGround-content { display: flex; flex-direction: column; + align-items: center; gap: 1.5em; + justify-content: space-around; - #backGround-title { + .backGround-image-preview { + display: flex; + flex-direction: column; + align-items: center; + width: 100%; text-align: center; - font-size: 1.2em; - font-weight: 500; + } + + .backGround-image-preview label { + font-size: 0.8em; + font-weight: 400; color: var(--color-text-primary); font-family: 'poppins'; - display: flex; - align-items: center; - justify-content: center; + } + + .backGround-image-preview img { + width: 80%; + max-width: 14em; + height: 10em; + object-fit: cover; + border-radius: var(--border-radius-min); - #svg-premium { - width: 2em; - } } - #backGround-content { + .backGround-image-input-content { display: flex; - flex-direction: column; + justify-content: center; align-items: center; - gap: 1.5em; - justify-content: space-around; + width: 100%; - #backGround-image-preview { + .image-lable { + border: 2px solid var(--secundary-color-purple); + border-radius: var(--border-radius-mid); + width: 80%; + height: 3em; display: flex; - flex-direction: column; + justify-content: center; align-items: center; - width: 100%; - text-align: center; - } - - #backGround-image-preview label { - font-size: 0.8em; - font-weight: 400; + font-size: 1.2em; + font-weight: 500; color: var(--color-text-primary); font-family: 'poppins'; + cursor: pointer; } + } + } + } - #backGround-image-preview img { - width: 80%; - max-width: 14em; - height: 10em; - object-fit: cover; - border-radius: var(--border-radius-min); - } + } - #backGround-image-input-content { - display: flex; - justify-content: center; - align-items: center; - width: 100%; - - #button-image-input { - border: 2px solid var(--secundary-color-purple); - border-radius: var(--border-radius-mid); - width: 80%; - height: 3em; - display: flex; - justify-content: center; - align-items: center; - font-size: 1.2em; - font-weight: 500; - color: var(--color-text-primary); - font-family: 'poppins'; - cursor: pointer; - } - } - } - } + .cadastro-rigth-content { + display: flex; + align-items: center; + justify-content: space-around; + flex-direction: column; + gap: 1em; - } - #cadastro-rigth-content { + .rigth-content { display: flex; - align-items: center; justify-content: space-around; + align-items: center; flex-direction: column; gap: 1em; + .inputs-containner { + width: 100%; + } - #rigth-content { + #product-desc { + resize: none; + height: 6em; + } + + .unic-containner { display: flex; - justify-content: space-around; - align-items: center; - flex-direction: column; + flex-wrap: wrap; gap: 1em; + width: 100%; + justify-content: space-between; + align-items: center; + height: 100%; - .inputs-containner { - width: 100%; - - } - - #product-desc { - resize: none; - height: 6em; - } - - #unic-containner { + .doble-containner { + width: 60%; display: flex; - flex-wrap: wrap; + flex-direction: column; gap: 1em; justify-content: space-between; - align-items: center; - height: 100%; - - #doble-containner { - width: 60%; - display: flex; - flex-direction: column; - gap: 1em; - justify-content: space-between; - } + } - #product-logo-content { - display: flex; - align-items: center; - flex-direction: column; - gap: 1em; - width: 30%; - justify-content: center; + .product-logo-content { + display: flex; + align-items: center; + flex-direction: column; + gap: 1em; + width: 30%; + justify-content: center; - #logo-preview { - cursor: pointer; - width: 8em; - height: 8em; - border-radius: var(--border-radius-mid); - } + #logo-preview { + cursor: pointer; + width: 8em; + height: 8em; + border-radius: var(--border-radius-mid); } - } } } + } } } -#rigth-content-title, -#logo-title { + +.rigth-content-title, +.logo-title { font-size: 1.2em; font-weight: 500; color: var(--color-text-primary); @@ -612,8 +618,8 @@ flex-direction: column; gap: 1em; - #rigth-content-title, - #logo-title { + .rigth-content-title, + .logo-title { font-size: 1.2em; font-weight: 500; color: var(--color-text-primary); @@ -1041,6 +1047,148 @@ } + +#create-mult-product-embend-containner { + width: 90%; + display: flex; + justify-content: center; + align-items: center; + margin-bottom: 5em; + #create-mult-product-embend-content { + padding: 1em; + width: 90%; + border-radius: var(--border-radius-min); + background-color: var(--secundary-color); + } +} + +#logo-preview-multi { + cursor: pointer; + width: 9em; + height: 9em; + border-radius: var(--border-radius-mid); +} + + +#select-product-containner{ + width: 100%; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + #select-product-content{ + width: 99%; + padding: 0.5em; + display: flex; + flex-direction: column; + gap: 1em; + max-height: 15em; + overflow: auto; + border: 1px solid var(--text-gray-color-primary); + #select-product-row{ + width: 100%; + display: flex; + flex-wrap: wrap; + gap: 0.5em; + justify-content: center; + align-items: center; + .select-product-col{ + width: 8.3em; + display: flex; + gap: 0.5em; + padding: 0.5em; + align-items: center; + justify-content: space-between; + border-radius: var(--border-radius-mid); + background-color: var(--primary-color-opacity); + .select-product-col-text{ + display: flex; + flex-direction: column; + } + .select-product-col-exclud-button{ + font-family: 'poppins'; + font-size: 1.2em; + + font-weight: 900; + cursor: pointer; + border: none; + background-color: transparent; + color: var(--red-color); + } + .select-product-col-title{ + font-family: 'poppins'; + font-size: 1em; + text-overflow: ellipsis; + overflow: hidden; + color: var(--color-text-primary); + } + .select-product-col-desc{ + font-family: 'poppins'; + font-size: 0.6em; + text-overflow: ellipsis; + overflow: hidden; + color: var(--text-gray-color-primary); + } + } + + } + } + +} + +.select-product-options-col-title{ + font-family: 'poppins'; + font-size: 1.2em; + text-overflow: ellipsis; + overflow: hidden; + color: var(--color-text-primary); +} +.select-product-options-col-desc{ + font-family: 'poppins'; + font-size: 0.8em; + + color: var(--text-gray-color-primary); +} + + + +#select-product-options-containner{ + position: absolute ; + justify-content: center; + align-items: center; + padding: 0.5em; + border-radius: var(--border-radius-min); + background-color: var(--primary-color); + #select-product-options-row{ + width: 100%; + display: flex; + flex-direction: column; + gap: 1em; + } + .select-product-options-col{ + width: 100% ; + display: flex; + align-items: center; + justify-content: center; + gap: 1em; + opacity: 1; + transition: 0.7s; + padding: 0.5em; + + &:hover{ + background-color: var(--menu-color); + opacity: 0.8; + transition: 0.7s; + cursor: pointer; + border-radius: var(--border-radius-min); + } + } +} +.select-product-options-col-image{ + width: 2em; + height: 2em; + border-radius: var(--border-radius-max); +} @media screen and (max-width:800px) { #pagamentos-produtos-containner{ flex-direction: column; @@ -1050,7 +1198,7 @@ #pagamentos-containner,#produtos-containner{ width: 90% !important; } - #cadastro-content{ + .cadastro-content{ flex-direction: column; } #estoque-config-add-button{ @@ -1059,7 +1207,7 @@ #estoque-config-col{ width: 100% !important; } - #cadastro-rigth-content,#cadastro-left-content{ + .cadastro-rigth-content,#cadastro-left-content{ width: 100% !important; } .estoque-config-col{ @@ -1089,7 +1237,7 @@ #pagamentos-produtos-containner{ gap: 1em; } - #product-cadastro-containner{ + .product-cadastro-containner{ width: 100% !important; } #cadastro-content{ diff --git a/public/js/sales.js b/public/js/sales.js index 7e1d175..f47f6b6 100644 --- a/public/js/sales.js +++ b/public/js/sales.js @@ -3,8 +3,8 @@ let serverID = location.pathname.replace('/server/sales/', "") -document.getElementById('add-pix-popup-tutorial').addEventListener('click',()=>{ - window.open('https://www.youtube.com/watch?v=jK4JmvWDvAc',"_blank") +document.getElementById('add-pix-popup-tutorial').addEventListener('click', () => { + window.open('https://www.youtube.com/watch?v=jK4JmvWDvAc', "_blank") }) if (document.getElementById('bank-input-list')) { @@ -494,13 +494,13 @@ document.addEventListener('click', async (event) => { body: JSON.stringify({ productID: productID, serverID: serverID, - txt:linhas, - title:document.getElementById('input-title-txt').value + txt: linhas, + title: document.getElementById('input-title-txt').value }), }).then(response => { return response.json() }) if (productData.success == true) { successNotify('Estoque adicionado!') - }else{ + } else { errorNotify('Erro ao adicionar estoque!') } }; @@ -805,6 +805,14 @@ document.getElementById('backGround-input-edit').addEventListener('change', func }); +document.getElementById('image-input-multi').addEventListener('change', function () { + previewImage(this, document.getElementById('image-preview-multi')); +}); +document.getElementById('logo-input-multi').addEventListener('change', function () { + previewImage(this, document.getElementById('logo-preview-multi')); +}); + + @@ -818,7 +826,7 @@ function clearCadastroProduct() { document.getElementById('logo-preview').src = 'https://res.cloudinary.com/dgcnfudya/image/upload/v1704981573/gxorbaldn7fw5ojcv1s0.jpg' document.getElementById('image-preview').src = 'https://res.cloudinary.com/dgcnfudya/image/upload/v1704981573/gxorbaldn7fw5ojcv1s0.jpg' - document.querySelector('#product-cadastro-containner #estoque-config-row').innerHTML = ` + document.querySelector('.product-cadastro-containner #estoque-config-row').innerHTML = `

Estoque 1

@@ -844,14 +852,14 @@ function clearCadastroProduct() { } -document.getElementById("product-cadastro-content").addEventListener("submit", function (event) { +document.getElementById("form-prodc").addEventListener("submit", function (event) { event.preventDefault(); if (!document.getElementById('logo-input').files[0]) { return errorNotify('Nenhuma logo foi inserida!') } // coletar os dados do estoque - let row = document.querySelector('#product-cadastro-containner #estoque-config-row') + let row = document.querySelector('.product-cadastro-containner #estoque-config-row') var EstoqueData = []; Array.from(row.children).forEach((element, index) => { @@ -943,7 +951,7 @@ document.getElementById('private-log-input').addEventListener('blur', function ( } }); -document.getElementById('save-button-private-log').addEventListener('click',async()=>{ +document.getElementById('save-button-private-log').addEventListener('click', async () => { if (document.getElementById('private-log-input').value <= 0) { errorNotify('Selecione um canal primeiro!') return @@ -963,12 +971,12 @@ document.getElementById('save-button-private-log').addEventListener('click',asyn }, body: JSON.stringify({ channelID: channelID, - serverID:serverID + serverID: serverID }), }).then(response => { return response.json() }) if (session.success == true) { successNotify(session.data) - }else{ + } else { errorNotify(session.data) } }) @@ -985,7 +993,7 @@ document.getElementById('public-log-input').addEventListener('blur', function () } }); -document.getElementById('save-button-public-log').addEventListener('click',async()=>{ +document.getElementById('save-button-public-log').addEventListener('click', async () => { if (document.getElementById('public-log-input').value <= 0) { errorNotify('Selecione um canal primeiro!') return @@ -1005,13 +1013,195 @@ document.getElementById('save-button-public-log').addEventListener('click',async }, body: JSON.stringify({ channelID: channelID, - serverID:serverID + serverID: serverID }), }).then(response => { return response.json() }) if (session.success == true) { successNotify(session.data) - }else{ + } else { errorNotify(session.data) } }) + + + + + + + + + + + + + + + + + +let selectProdsList = [] + +let optionsIsOpen = false +function exibOptionsSelect() { + optionsIsOpen = true + let selectProdOptions = document.getElementById('select-product-options-containner') + let selectProdContent = document.getElementById('select-product-content') + document.getElementById('select-product-options-containner').style.display = 'flex' + selectProdOptions.style.width = (selectProdContent.offsetWidth + 3) + 'px' + selectProdOptions.style.left = (selectProdContent.offsetLeft - 2) + 'px' + selectProdOptions.style.top = selectProdContent.offsetTop + selectProdContent.offsetHeight + 5 + 'px' +} +document.addEventListener('click', async (event) => { + const target = event.target; + if (target.closest('.select-product-col-exclud-button')) { + let deleteTarget = target.closest('.select-product-col-exclud-button') + let id = deleteTarget.getAttribute('data-id') + + selectProdsList.splice(selectProdsList.indexOf(id), 1); + document.getElementById('select-product-row').removeChild(deleteTarget.parentNode.parentNode) + } + if (target.closest('.select-product-options-col')) { + let targetSelect = target.closest('.select-product-options-col') + let prodID = targetSelect.getAttribute('data-id') + selectProdsList.push(prodID) + + document.getElementById('select-product-row').innerHTML += ` +
+
+

${targetSelect.querySelector('.select-product-options-col-title').textContent}

+

${targetSelect.querySelector('.select-product-options-col-desc').textContent}

+
+
+ +
+
+ ` + exibOptionsSelect() + document.getElementById('select-product-options-row').removeChild(targetSelect) + } + if (optionsIsOpen == true && !target.closest('.select-product-options-col') && !target.closest('#select-product-focus-button')) { + document.getElementById('select-product-options-containner').style.display = 'none' + optionsIsOpen = false + } +}) + + +document.getElementById('select-product-focus-button').addEventListener('click', async () => { + exibOptionsSelect() + + let productData = await fetch('/product/get', { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + serverID: serverID + }), + }).then(response => { return response.json() }) + if (productData.success == true) { + function formatarMoeda(numeroCentavos) { + const valorReal = numeroCentavos / 100; + return valorReal.toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' }); + } + document.getElementById('select-product-options-row').innerHTML = '' + productData.data.forEach((element) => { + if (!selectProdsList.includes(element.productID)) { + document.getElementById('select-product-options-row').innerHTML += ` +
+ + +

${element.productName}

+
+

${formatarMoeda(element.price)}

+
+ ` + } + }) + } +}) +document.getElementById('channel-multi-input').addEventListener('blur', function () { + const inputValue = this.value.toLowerCase(); + const datalistOptions = Array.from(document.getElementById('channel-multi-list').getElementsByTagName('option')); + const validOptions = datalistOptions.map(option => option.value.toLowerCase()); + + if (!validOptions.includes(inputValue)) { + errorNotify('Por favor, selecione um canal válido da lista.'); + this.value = ''; + } +}); +document.getElementById("form-prodc-mult").addEventListener("submit", function (event) { + event.preventDefault(); + + if (selectProdsList.length <= 0) { + errorNotify('Selecione um ou mais produtos para continuar!') + return + } + if (document.getElementById('channel-multi-input').value.trim().length <= 0) { + errorNotify('Selecione um canal para ser enviado o produto!') + return + } + if (document.getElementById('product-name-mult').value.trim().length <= 0) { + errorNotify('Adicione um nome primeiro!') + return + } + if (document.getElementById('product-desc-multi').value.trim().length <= 0) { + errorNotify('Adicione uma descrição primeiro!') + return + } + // coletar o id do canal + const opcoes = document.getElementById('channel-multi-list').querySelectorAll('option'); + let channelID = null; + + opcoes.forEach(option => { + if (option.value === document.getElementById('channel-multi-input').value) { + channelID = option.getAttribute('data-channel'); + } + }); + + + + + var formData = new FormData(); + + + formData.append('channelID', channelID); + formData.append('productName', document.getElementById('product-name-mult').value.trim()); + formData.append('producDesc', document.getElementById('product-desc-multi').value.trim()); + formData.append('serverID', serverID); + formData.append('productsList',selectProdsList) + if (document.getElementById('logo-input-multi').files[0]) { + formData.append('productLogo', document.getElementById('logo-input-multi').files[0]); + } + if (document.getElementById('image-input-multi').files[0]) { + formData.append('backGround', document.getElementById('image-input-multi').files[0]); + } + + document.getElementById('select-product-row').innerHTML = '' + selectProdsList = [] + document.getElementById('logo-input-multi').value = '' + document.getElementById('product-name-mult').value = '' + document.getElementById('channel-multi-input').value = '' + document.getElementById('product-desc-multi').value = '' + document.getElementById('image-preview-multi').src = 'https://res.cloudinary.com/dgcnfudya/image/upload/v1704981573/gxorbaldn7fw5ojcv1s0.jpg' + document.getElementById('logo-preview-multi').src = 'https://res.cloudinary.com/dgcnfudya/image/upload/v1704981573/gxorbaldn7fw5ojcv1s0.jpg' + $.ajax({ + traditional: true, + url: '/product/mult', + type: 'POST', + data: formData, + processData: false, + contentType: false, + success: function (response) { + if (response.success) { + successNotify('Multiproduto criado!') + } else { + errorNotify(response.data) + } + + }, + error: function (xhr, status, error) { + console.error(error); + } + }) +}) \ No newline at end of file diff --git a/stripe/productsRoutes.js b/stripe/productsRoutes.js index ecbc1bd..ce710bd 100644 --- a/stripe/productsRoutes.js +++ b/stripe/productsRoutes.js @@ -29,12 +29,108 @@ const upload = multer({ storage }); let Discord = require('discord.js') const botConfig = require('../config/bot-config.js'); -const { error } = require('console'); +const { error, log } = require('console'); const { rejects } = require('assert'); const client = new Discord.Client({ intents: botConfig.intents }) client.login(botConfig.discordToken) +router.post('/product/mult', upload.fields([{ name: 'productLogo', maxCount: 1 }, { name: 'backGround', maxCount: 1 }]), async (req, res) => { + try { + var DiscordServer = await client.guilds.cache.get(req.body.serverID); + var DiscordChannel = await DiscordServer.channels.cache.get(req.body.channelID) + let serverDb = await db.findOne({ colecao: 'servers', doc: req.body.serverID }) + + let dburl = null + let Newdbres = null + if (req.files.backGround) { + const bannerPath = req.files.backGround[0].path; + let file = await fs.readFileSync(bannerPath); + let buffer = Buffer.from(file, 'binary'); + let newBuffer = await sharp(buffer).jpeg().toBuffer() + const attachment = new Discord.AttachmentBuilder(newBuffer, { name: 'test.jpg' }); + let dbBannerDiscordServer = await client.guilds.cache.get('1246186853241978911') + let dbBannerDiscordChannel = await dbBannerDiscordServer.channels.cache.get('1253279027662426142') + let dbres = await dbBannerDiscordChannel.send({ + files: [attachment] + }) + Newdbres = dbres + dburl = await dbres.attachments.first().url + fs.unlink(req.files.backGround[0].path, (err) => { + if (err) { + console.error('Erro ao apagar o arquivo original:', err); + + } + }); + } + let dburl2 = null + let Newdbres2 = null + if (req.files.productLogo) { + const bannerPath = req.files.productLogo[0].path + let file = await fs.readFileSync(bannerPath); + let buffer = Buffer.from(file, 'binary'); + let newBuffer = await sharp(buffer).jpeg().toBuffer() + const attachment = new Discord.AttachmentBuilder(newBuffer, { name: 'test.jpg' }); + let dbBannerDiscordServer = await client.guilds.cache.get('1246186853241978911') + let dbBannerDiscordChannel = await dbBannerDiscordServer.channels.cache.get('1253279027662426142') + let dbres = await dbBannerDiscordChannel.send({ + files: [attachment] + }) + Newdbres2 = dbres + dburl2 = await dbres.attachments.first().url + fs.unlink(req.files.productLogo[0].path, (err) => { + if (err) { + console.error('Erro ao apagar o arquivo original:', err); + return { error: true, err: err } + } else { + return null + } + }); + } + + let productsArrayOptions = [] + let productList = await req.body.productsList.split(',') + for (let index = 0; index < productList.length; index++) { + const element = await productList[index]; + let produto = await serverDb.products.find(product => product.productID == element) + await productsArrayOptions.push( + await new Discord.StringSelectMenuOptionBuilder().setLabel(produto.productName).setDescription(functions.formatarMoeda(produto.price)).setValue(produto.productID) + ) + } + + DiscordChannel.send({ + embeds: [ + new Discord.EmbedBuilder() + .setTitle(req.body.productName) + .setDescription(req.body.producDesc) + .setColor('personalize' in serverDb && 'colorDest' in serverDb.personalize ? serverDb.personalize.colorDest : '#6E58C7') + .setTimestamp() + .setThumbnail(dburl2) + .setImage(dburl) + .setFooter({ text: DiscordServer.name, iconURL: `https://cdn.discordapp.com/icons/${DiscordServer.id}/${DiscordServer.icon}.webp` }) + ], + components: [ + new Discord.ActionRowBuilder().addComponents( + new Discord.StringSelectMenuBuilder() + .setCustomId('multSelectProduct') + .setPlaceholder('Selecione um produto!') + .setMinValues(1) + .setMaxValues(1) + .addOptions(...productsArrayOptions) + ) + ] + }) + if (!res.headersSent) { + res.status(200).json({ success: true, data: 'Mensagem enviada!' }) + } + } catch (error) { + if (!res.headersSent) { + res.status(200).json({ success: false, data: 'Erro ao tentar enviar a mensagem!' }) + } + console.log(error); + } +}) + router.post('/product/create', upload.fields([{ name: 'productLogo', maxCount: 1 }, { name: 'backGround', maxCount: 1 }]), async (req, res) => { try { let server = await db.findOne({ colecao: 'servers', doc: req.body.serverID }) @@ -98,7 +194,7 @@ router.post('/product/create', upload.fields([{ name: 'productLogo', maxCount: 1 serverID: req.body.serverID, productID: product.id, }) - }else{ + } else { require('../Discord/createProductMessage.js')(Discord, client, { channelID: req.body.channelID, serverID: req.body.serverID, @@ -175,9 +271,9 @@ router.post('/product/update', upload.fields([{ name: 'productLogo', maxCount: 1 let produtos = server.products produto.productName = req.body.productName, - produto.producDesc = req.body.producDesc, - produto.price = req.body.price, - produto.priceID = price.id + produto.producDesc = req.body.producDesc, + produto.price = req.body.price, + produto.priceID = price.id if (logo != null) { produto.productLogo = logo } @@ -193,12 +289,12 @@ router.post('/product/update', upload.fields([{ name: 'productLogo', maxCount: 1 }) if (produto.embendType == 0) { require('../Discord/createProductMessageEmbend.js')(Discord, client, { - channelID: produto.channel, + channelID: produto.channel, serverID: req.body.serverID, productID: productID, edit: true }) - }else{ + } else { require('../Discord/createProductMessage.js')(Discord, client, { channelID: produto.channel, serverID: req.body.serverID, @@ -370,12 +466,12 @@ router.post('/estoque/txt', async (req, res) => { }) if (product.embendType == 0) { require('../Discord/createProductMessageEmbend.js')(Discord, client, { - channelID: product.channel, + channelID: product.channel, serverID: req.body.serverID, productID: productID, edit: true }) - }else{ + } else { require('../Discord/createProductMessage.js')(Discord, client, { channelID: product.channel, serverID: req.body.serverID, @@ -425,12 +521,12 @@ router.post('/product/estoqueAdd', async (req, res) => { }) if (product.embendType == 0) { require('../Discord/createProductMessageEmbend.js')(Discord, client, { - channelID: product.channel, + channelID: product.channel, serverID: req.body.serverID, productID: productID, edit: true }) - }else{ + } else { require('../Discord/createProductMessage.js')(Discord, client, { channelID: product.channel, serverID: req.body.serverID, @@ -469,7 +565,7 @@ router.post('/product/estoqueAdd', async (req, res) => { }) -router.post('/product/mensage', async(req, res) => { +router.post('/product/mensage', async (req, res) => { try { let server = await db.findOne({ colecao: 'servers', doc: req.body.serverID }) let productID = req.body.productID @@ -482,7 +578,7 @@ router.post('/product/mensage', async(req, res) => { productID: req.body.productID, edit: true }) - }else{ + } else { require('../Discord/createProductMessage.js')(Discord, client, { channelID: req.body.channelID, serverID: req.body.serverID, diff --git a/views/sales.ejs b/views/sales.ejs index 7cafc00..96c74c9 100644 --- a/views/sales.ejs +++ b/views/sales.ejs @@ -47,7 +47,7 @@
-

Mudar logo:

+

Mudar logo:

@@ -230,15 +230,15 @@
-
-
+
+

Cadastrar Produto

-
-
-
-

Selecione o canal de anuncio do produto:

-
+
+
+
+

Selecione o canal de anuncio do produto:

+
<% channels.forEach(element => { %> @@ -247,23 +247,23 @@
-
-

Imagem de fundo do produto:

-
-
+
+

Imagem de fundo do produto:

+
+
-
- +
+ name="" id="image-input">
-
-

Dados do produto:

-
+
+

Dados do produto:

+
@@ -272,9 +272,9 @@
-
-
-
+
+
+
@@ -290,8 +290,8 @@
-
-

Adicionar logo:

+
+

Adicionar logo:

@@ -350,6 +350,103 @@
+ + + + + + + + + + + + + + + + + + +
+
+

Cadastrar de multi Produtos

+
+
+
+
+

Selecione o canal de anuncio do produto:

+
+ + + <% channels.forEach(element => { %> + + <% }) %> + +
+
+
+

Imagem de fundo do produto:

+
+
+ + +
+
+ + name="" id="image-input-multi"> +
+
+
+
+
+

Dados do multi produto:

+
+
+ + +
+
+ + +
+
+
+
+
+
+
+ + +
+
+ +
+
+ + +
+
+ +
+
+

Adicionar logo:

+ + +
+
+ +
+
+
+
+