Skip to content

Commit

Permalink
refactor: creates estoquePath variable in constants file
Browse files Browse the repository at this point in the history
  • Loading branch information
diasjoaovitor committed Nov 27, 2024
1 parent 2af3ab1 commit e11d773
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/bot/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const estoquePath = 'estoque2'
4 changes: 3 additions & 1 deletion src/bot/functions/regex.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { estoquePath } from '../constants'

export function getEstoqueURL(html: string) {
const result = html.match(
/(?<=href=")https:\/\/www.sambanet.net.br\/sambanet\/estoque.+(?===".+demo)/
Expand All @@ -11,6 +13,6 @@ export function getEntradaNfURL(html: string) {
const result = html.match(/(?<=href=")EntradaNfRM.+(?=" title.+tabindex)/)
if (!result) return null
const [href] = result
const url = 'https://www.sambanet.net.br/sambanet/estoque/Forms/' + href
const url = `https://www.sambanet.net.br/sambanet/${estoquePath}/Forms/${href}`
return url
}
3 changes: 2 additions & 1 deletion src/bot/functions/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import puppeteer from 'puppeteer'
import { logger } from '@/config'
import { delay, print } from '@/utils'
import type { TNote, TProduct } from '../types'
import { estoquePath } from '../constants'

export async function start(url: string) {
try {
Expand Down Expand Up @@ -152,7 +153,7 @@ export async function navigateToNextPage(page: Page, nextPageId: string) {
}

export async function navigateToItensDaNF(code: string, browser: Browser) {
const itensNfURL = `https://www.sambanet.net.br/sambanet/estoque/Forms/EntradaNFItensRM.aspx?nf=${code}`
const itensNfURL = `https://www.sambanet.net.br/sambanet/${estoquePath}/Forms/EntradaNFItensRM.aspx?nf=${code}`
try {
const itensNf = await browser.newPage()
await itensNf.goto(itensNfURL)
Expand Down

0 comments on commit e11d773

Please sign in to comment.