Last active
April 26, 2022 20:52
-
-
Save sidneycalebe/4668200d0f637fbf88ca399ab071af6f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CurrentSheet = SpreadsheetApp.getActiveSpreadsheet(); | |
var prazos = CurrentSheet.getSheetByName('Prazos'); | |
function doGet(e) { | |
var customerEmail = e.parameter.email; | |
var data = { data_entrega: `${doSearch(customerEmail)}` }; | |
return ContentService.createTextOutput(JSON.stringify(data)).setMimeType(ContentService.MimeType.JSON); | |
} | |
function doSearch(customerEmail) { | |
var customerRow = searchRow(customerEmail); | |
if (customerRow != '') { | |
var result = prazos.getRange(`C${customerRow}`).getValue(); | |
customerSearchesNumber(customerRow); | |
return Utilities.formatDate(result, "GMT-3", "dd/MM/yyyy"); | |
} | |
return ''; | |
} | |
function searchRow(customerEmail) { | |
var dataTable = prazos.getRange('B:B').getValues(); | |
return dataTable.findIndex(customers => { return customers[0] === customerEmail }) + 1; | |
} | |
function customerSearchesNumber(customerRow) { | |
var qtdPesquisas = prazos.getRange(`E${customerRow}`).getValue(); | |
prazos.getRange(`D${customerRow}`).getValue = ! null && prazos.getRange(`E${customerRow}`).setValue(qtdPesquisas + 1); | |
prazos.getRange(`D${customerRow}`).setValue(`${Utilities.formatDate(new Date(), "GMT-3", "dd/MM/yyyy HH:mm:ss")}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment