Skip to content

Commit

Permalink
Fixing flow
Browse files Browse the repository at this point in the history
  • Loading branch information
wsieroci committed Feb 18, 2024
1 parent 08e0d13 commit b7f6233
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
21 changes: 17 additions & 4 deletions src/components/Simulai.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@
</div>
</div>
<div
v-if="page.isChat && block.isRequired === false && i === currentVisibleBlock">
v-if="checkIfBlockShouldShowSkipButton(i, block)">
<button
@click="showNextBlock()"
class="mt-2 mb-4 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-700 transition duration-300 cursor-pointer">
class="mt-0 mb-4 ml-9 px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-700 transition duration-300 cursor-pointer">
Skip
</button>
</div>
Expand Down Expand Up @@ -314,6 +314,11 @@ async function publishPage() {
}
}
function checkIfBlockShouldShowSkipButton(i, block) {
debugger;
return props.page.isChat && block.isRequired === false && i === currentVisibleBlock.value
}
function setBotName() {
const name = botName.value === null ? "Potter" : botName.value
let botNameString = prompt("Please enter bot name", name);
Expand Down Expand Up @@ -416,7 +421,11 @@ function copyPublishUrl() {
}
function typingHasCompleted() {
goNextBlock()
debugger;
const currentBlock = props.page.blocks[currentVisibleBlock.value]
if(!getBlockOptions(currentBlock).isInput && !getBlockOptions(currentBlock).isNextButton) {
goNextBlock()
}
}
function showNextBlock() {
Expand Down Expand Up @@ -553,6 +562,7 @@ function isYouVisibleBlock(block: Block, i: number) {
}
function goNextBlock() {
debugger;
showNextBlock()
const currentBlock = props.page.blocks[currentVisibleBlock.value]
if (chatInput.value && shouldWaitForValueFromInput(currentBlock)) {
Expand Down Expand Up @@ -586,7 +596,6 @@ function handleMessage(message) {
}
function validateNextBlock(block) {
debugger;
const validationResult = validateUIBlock(block)
if (validationResult.error) {
Expand Down Expand Up @@ -932,6 +941,10 @@ function duplicateBlock(blockIdx: number) {
}
async function setBlockType(blockIdx: number, type: BlockType) {
if(props.page.isChat === false) {
return;
}
if (props.onUnsetAll) props.onUnsetAll(props.page.blocks[blockIdx])
if (blockElements.value[blockIdx].content.onUnset) {
blockElements.value[blockIdx].content.onUnset()
Expand Down
2 changes: 1 addition & 1 deletion src/components/blocks/CountryBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ watch([selectedCountry], () => {
onMounted(() => {
// Set initial values if not already set
onSet();
// onSet();
})
defineExpose({
Expand Down
2 changes: 1 addition & 1 deletion src/components/blocks/PhoneBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ watch([selectedCountryCode, phoneNumber], () => {
onMounted(() => {
// Set initial values if not already set
onSet();
// onSet();
})
defineExpose({
Expand Down
1 change: 0 additions & 1 deletion src/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export function validateUIBlock(block: BlockAnswer | null) {
const validationResult = {}

if(block.isRequired) {
debugger;
const emptyMessage = 'Please provide answer to my last message and click on the next button'

if(block.items) {
Expand Down

0 comments on commit b7f6233

Please sign in to comment.