Skip to content

Commit

Permalink
fix: select current version
Browse files Browse the repository at this point in the history
  • Loading branch information
acnormun committed Oct 11, 2024
1 parent 999cb39 commit c7930b8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
26 changes: 26 additions & 0 deletions src/api/solutions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
}: {
data: {
results: {
version?: string;
feature_uuid: string;
description: string;
disclaimer: string;
Expand All @@ -21,13 +22,19 @@ export default {
}[];
name: string;
sectors: string[];
versions?: {
version: string;
globals: { [key: string]: { value: string } };
sectors: { [key: string]: { value: string[] } };
}[];
}[];
};
} = await request.$http.get(
`/v2/feature/${authStore.projectUuid}/?category=${category}`,
);

return data.results.map((solution) => ({
version: solution.version || '',
uuid: solution.feature_uuid,
title: solution.name,
description: solution.description,
Expand All @@ -50,6 +57,25 @@ export default {
}),
{},
),
versions:
solution.versions &&
solution.versions.map((version) => ({
version: version.version,
globals: Object.keys(version.globals).reduce(
(previous, key) => ({
...previous,
[key]: { value: version.globals[key].value },
}),
{},
),
sectors: Object.keys(version.sectors).reduce(
(previous, key) => ({
...previous,
[key]: { value: version.sectors[key].value },
}),
{},
),
})),
}));
},

Expand Down
48 changes: 11 additions & 37 deletions src/components/solutions/DrawerSolution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,36 +100,6 @@ const props = defineProps<{
solution?: Solution;
}>();
const solutionMock = {
version: '1.0',
feature_uuid: '4d983f31-065b-45c8-84fd-276469750c38',
name: 'Carrinho Abandonado',
description:
'Recupere vendas lembrando clientes de itens esquecidos no carrinho.',
disclaimer:
'Com essa solução, é possível aumentar suas chances de conversão, mantendo seu cliente próximo e incentivando a conclusão do pedido.',
documentation_url: null,
globals: [{ nome_loja: 'loja_roupa' }],
sectors: [],
versions: [
{
version: '1.0',
globals: ['nome_loja'],
sectors: [],
},
{
version: '2.0',
globals: ['loja'],
sectors: [
{
name: 'teste',
tags: '',
},
],
},
],
};
const { t } = useI18n();
const router = useRouter();
Expand All @@ -146,9 +116,11 @@ const formData = reactive<{
};
}>({});
const currentVersion = solutionMock.versions.find(
(item) => item.version === solutionMock.version,
);
const currentVersion =
props.solution &&
props.solution.versions.find(

Check failure on line 121 in src/components/solutions/DrawerSolution.vue

View workflow job for this annotation

GitHub Actions / Run tests and collect coverage

src/components/solutions/__tests__/DrawerSolution.spec.ts > DrawerSolution > when the solution does not have documentation > does not show the help box

TypeError: Cannot read properties of undefined (reading 'find') ❯ setup src/components/solutions/DrawerSolution.vue:121:27 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7768:25 ❯ setupComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7729:36 ❯ mountComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5084:7 ❯ processComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5050:9 ❯ patch node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4579:11 ❯ ReactiveEffect.componentUpdateFn [as fn] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5194:11 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19 ❯ setupRenderEffect node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5322:5

Check failure on line 121 in src/components/solutions/DrawerSolution.vue

View workflow job for this annotation

GitHub Actions / Run tests and collect coverage

src/components/solutions/__tests__/DrawerSolution.spec.ts > DrawerSolution > when the solution has documentation > shows the help box

TypeError: Cannot read properties of undefined (reading 'find') ❯ setup src/components/solutions/DrawerSolution.vue:121:27 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7768:25 ❯ setupComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7729:36 ❯ mountComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5084:7 ❯ processComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5050:9 ❯ patch node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4579:11 ❯ ReactiveEffect.componentUpdateFn [as fn] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5194:11 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19 ❯ setupRenderEffect node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5322:5

Check failure on line 121 in src/components/solutions/DrawerSolution.vue

View workflow job for this annotation

GitHub Actions / Run tests and collect coverage

src/components/solutions/__tests__/DrawerSolution.spec.ts > DrawerSolution > when the solution has documentation > when the user changes one global and one sector > when the drawer closes > emits close event

TypeError: Cannot read properties of undefined (reading 'find') ❯ setup src/components/solutions/DrawerSolution.vue:121:27 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7768:25 ❯ setupComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7729:36 ❯ mountComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5084:7 ❯ processComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5050:9 ❯ patch node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4579:11 ❯ ReactiveEffect.componentUpdateFn [as fn] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5194:11 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19 ❯ setupRenderEffect node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5322:5

Check failure on line 121 in src/components/solutions/DrawerSolution.vue

View workflow job for this annotation

GitHub Actions / Run tests and collect coverage

src/components/solutions/__tests__/DrawerSolution.spec.ts > DrawerSolution > when the solution has documentation > when the user changes one global and one sector > when the user clicks on cancel button > emits close event

TypeError: Cannot read properties of undefined (reading 'find') ❯ setup src/components/solutions/DrawerSolution.vue:121:27 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7768:25 ❯ setupComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7729:36 ❯ mountComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5084:7 ❯ processComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5050:9 ❯ patch node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4579:11 ❯ ReactiveEffect.componentUpdateFn [as fn] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5194:11 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19 ❯ setupRenderEffect node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5322:5

Check failure on line 121 in src/components/solutions/DrawerSolution.vue

View workflow job for this annotation

GitHub Actions / Run tests and collect coverage

src/components/solutions/__tests__/DrawerSolution.spec.ts > DrawerSolution > when the solution has documentation > when the user changes one global and one sector > when the user clicks on save button > calls integrateOrUpdate function from solutions store

TypeError: Cannot read properties of undefined (reading 'find') ❯ setup src/components/solutions/DrawerSolution.vue:121:27 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7768:25 ❯ setupComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7729:36 ❯ mountComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5084:7 ❯ processComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5050:9 ❯ patch node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4579:11 ❯ ReactiveEffect.componentUpdateFn [as fn] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5194:11 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19 ❯ setupRenderEffect node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5322:5

Check failure on line 121 in src/components/solutions/DrawerSolution.vue

View workflow job for this annotation

GitHub Actions / Run tests and collect coverage

src/components/solutions/__tests__/DrawerSolution.spec.ts > DrawerSolution > when the solution has documentation > when the user changes one global and one sector > when the user clicks on save button > emits close event

TypeError: Cannot read properties of undefined (reading 'find') ❯ setup src/components/solutions/DrawerSolution.vue:121:27 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7768:25 ❯ setupComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7729:36 ❯ mountComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5084:7 ❯ processComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5050:9 ❯ patch node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4579:11 ❯ ReactiveEffect.componentUpdateFn [as fn] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5194:11 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19 ❯ setupRenderEffect node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5322:5

Check failure on line 121 in src/components/solutions/DrawerSolution.vue

View workflow job for this annotation

GitHub Actions / Run tests and collect coverage

src/components/solutions/__tests__/DrawerSolution.spec.ts > DrawerSolution > when the solution has documentation > when the user changes one global and one sector > when the user clicks on save button > alerts that solution has been integrated

TypeError: Cannot read properties of undefined (reading 'find') ❯ setup src/components/solutions/DrawerSolution.vue:121:27 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7768:25 ❯ setupComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7729:36 ❯ mountComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5084:7 ❯ processComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5050:9 ❯ patch node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4579:11 ❯ ReactiveEffect.componentUpdateFn [as fn] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5194:11 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19 ❯ setupRenderEffect node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5322:5

Check failure on line 121 in src/components/solutions/DrawerSolution.vue

View workflow job for this annotation

GitHub Actions / Run tests and collect coverage

src/components/solutions/__tests__/DrawerSolution.spec.ts > DrawerSolution > when the solution has documentation > when the user changes one global and one sector > when the user clicks on save button > redirects to integrated-solutions page

TypeError: Cannot read properties of undefined (reading 'find') ❯ setup src/components/solutions/DrawerSolution.vue:121:27 ❯ callWithErrorHandling node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:200:19 ❯ setupStatefulComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7768:25 ❯ setupComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7729:36 ❯ mountComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5084:7 ❯ processComponent node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5050:9 ❯ patch node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:4579:11 ❯ ReactiveEffect.componentUpdateFn [as fn] node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5194:11 ❯ ReactiveEffect.run node_modules/@vue/reactivity/dist/reactivity.cjs.js:226:19 ❯ setupRenderEffect node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5322:5
(item) => props.solution && item.version === props.solution.version,
);
function close() {
isOpen.value = false;
Expand Down Expand Up @@ -216,7 +188,7 @@ watch(
);
});
Object.keys(props.solution.globals).forEach((globalName) => {
Object.keys(currentVersion.globals).forEach((globalName) => {
updateField(globalName, currentVersion.globals[globalName].value);
});
} else if (isOpen) {
Expand All @@ -230,11 +202,13 @@ function currentValueField(field: string) {
const type = fieldType(field);
const label = fieldLabel(field);
if (type === 'text' || type === 'tags') {
console.log('❤️', type, label, JSON.stringify(formData));
if (type === 'text') {
return formData[label];
} else if (type === 'tags') {
return formData[label];
}
return { value: null };
}
function updateField(field: string, value: string | boolean | string[]) {
Expand Down

0 comments on commit c7930b8

Please sign in to comment.