diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue
index fb3ac10c3..de4724e55 100644
--- a/src/components/CrudModel.vue
+++ b/src/components/CrudModel.vue
@@ -124,11 +124,16 @@ async function onSubmit() {
});
}
isLoading.value = true;
- await saveChanges();
+ await saveChanges($props.saveFn ? formData.value : null);
}
async function saveChanges(data) {
- if ($props.saveFn) return $props.saveFn(data, getChanges);
+ if ($props.saveFn) {
+ $props.saveFn(data, getChanges);
+ isLoading.value = false;
+ hasChanges.value = false;
+ return;
+ }
const changes = data || getChanges();
try {
await axios.post($props.saveUrl || $props.url + '/crud', changes);
diff --git a/src/components/common/VnInputDate.vue b/src/components/common/VnInputDate.vue
index 2053eceb1..fe0866292 100644
--- a/src/components/common/VnInputDate.vue
+++ b/src/components/common/VnInputDate.vue
@@ -15,6 +15,10 @@ const props = defineProps({
type: Boolean,
default: false,
},
+ emitDateFormat: {
+ type: Boolean,
+ default: false,
+ },
});
const hover = ref(false);
@@ -37,7 +41,10 @@ const value = computed({
return props.modelValue;
},
set(value) {
- emit('update:modelValue', joinDateAndTime(value, time.value));
+ emit(
+ 'update:modelValue',
+ props.emitDateFormat ? new Date(value) : joinDateAndTime(value, time.value)
+ );
},
});
diff --git a/src/components/common/VnLog.vue b/src/components/common/VnLog.vue
index 8a91d3c95..340a9e550 100644
--- a/src/components/common/VnLog.vue
+++ b/src/components/common/VnLog.vue
@@ -421,12 +421,13 @@ setLogTree();
>
-
+
diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue
index 480d36e4f..05c74f00a 100644
--- a/src/components/common/VnSelect.vue
+++ b/src/components/common/VnSelect.vue
@@ -169,6 +169,7 @@ watch(modelValue, (newValue) => {
ref="vnSelectRef"
:class="{ required: $attrs.required }"
:rules="$attrs.required ? [requiredFieldRule] : null"
+ virtual-scroll-slice-size="options.length"
>
{
};
async function fetch() {
+ store.filter.skip = 0;
+ store.skip = 0;
await arrayData.fetch({ append: false });
if (!store.hasMoreData) {
isLoading.value = false;
diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue
index fc8475ace..344267ef7 100644
--- a/src/components/ui/VnSearchbar.vue
+++ b/src/components/ui/VnSearchbar.vue
@@ -81,8 +81,10 @@ async function search() {
const staticParams = Object.entries(store.userParams).filter(
([key, value]) => value && (props.staticParams || []).includes(key)
);
+ // const filter =props?.where? { where: JSON.parse(props.where) }: {}
await arrayData.applyFilter({
params: {
+ // filter ,
...Object.fromEntries(staticParams),
search: searchText.value,
},
@@ -106,6 +108,7 @@ async function search() {
let targetUrl;
if (path.endsWith('/list')) targetUrl = path.replace('/list', `/${targetId}/summary`);
+ if (path.endsWith('-list')) targetUrl = path.replace('-list', `/${targetId}/summary`);
else if (path.includes(':id')) targetUrl = path.replace(':id', targetId);
await router.push({ path: targetUrl });
diff --git a/src/components/ui/VnUserLink.vue b/src/components/ui/VnUserLink.vue
index 47287c12b..33836550a 100644
--- a/src/components/ui/VnUserLink.vue
+++ b/src/components/ui/VnUserLink.vue
@@ -1,6 +1,5 @@
@@ -292,6 +301,14 @@ async function importToNewRefundTicket() {
v-model:selected="selectedRows"
:grid="$q.screen.lt.md"
>
+
+
+
+ {{ value }}
+
+
+
+
@@ -383,6 +400,7 @@ async function importToNewRefundTicket() {
icon="check"
@click="regularizeClaim"
:disable="claim.claimStateFk == resolvedStateId"
+ :loading="loading"
/>
diff --git a/src/pages/Claim/Card/ClaimBasicData.vue b/src/pages/Claim/Card/ClaimBasicData.vue
index 56717c628..e2450a5e5 100644
--- a/src/pages/Claim/Card/ClaimBasicData.vue
+++ b/src/pages/Claim/Card/ClaimBasicData.vue
@@ -2,7 +2,7 @@
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
-
+import VnSelect from 'src/components/common/VnSelect.vue';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
@@ -37,23 +37,19 @@ const claimFilter = {
],
};
-const workers = ref([]);
-const workersCopy = ref([]);
const claimStates = ref([]);
const claimStatesCopy = ref([]);
+const optionsList = ref([]);
-function setWorkers(data) {
- workers.value = data;
- workersCopy.value = data;
-}
+const workersOptions = ref([]);
function setClaimStates(data) {
claimStates.value = data;
claimStatesCopy.value = data;
}
-let optionsList;
+
async function getEnumValues() {
- optionsList = [{ id: null, description: t('claim.basicData.null') }];
+ optionsList.value = [{ id: null, description: t('claim.basicData.null') }];
const { data } = await axios.get(`Applications/get-enum-values`, {
params: {
schema: 'vn',
@@ -62,29 +58,11 @@ async function getEnumValues() {
},
});
for (let value of data)
- optionsList.push({ id: value, description: t(`claim.basicData.${value}`) });
+ optionsList.value.push({ id: value, description: t(`claim.basicData.${value}`) });
}
+
getEnumValues();
-const workerFilter = {
- options: workers,
- filterFn: (options, value) => {
- const search = value.toLowerCase();
-
- if (value === '') return workersCopy.value;
-
- return options.value.filter((row) => {
- const id = row.id;
- const name = row.name.toLowerCase();
-
- const idMatches = id == search;
- const nameMatches = name.indexOf(search) > -1;
-
- return idMatches || nameMatches;
- });
- },
-};
-
const statesFilter = {
options: claimStates,
filterFn: (options, value) => {
@@ -104,7 +82,7 @@ const statesFilter = {
(workersOptions = data)"
auto-load
/>
@@ -133,18 +111,15 @@ const statesFilter = {
- filter(value, update, workerFilter)"
+ auto-load
:rules="validate('claim.claimStateFk')"
- :input-debounce="0"
>
@@ -155,7 +130,7 @@ const statesFilter = {
/>
-
+
{
-
+
+
+
+ {{ entity.ticket?.zone?.name }}
+
+
+
+
accumulator + sale.price * sale.quantity,
- 0
- );
+ for (const row of rows) {
+ const { sale } = row;
+ amount.value = amount.value + totalRow(sale);
+ const price = row.quantity * sale.price;
+ const discount = (sale.discount * price) / 100;
+ amountClaimed.value = amountClaimed.value + (price - discount);
+ }
+}
- amountClaimed.value = rows.reduce(
- (accumulator, line) => accumulator + line.sale.price * line.quantity,
- 0
- );
+function totalRow({ price, quantity, discount }) {
+ const amount = price * quantity;
+ const appliedDiscount = (discount * amount) / 100;
+ return amount - appliedDiscount;
}
const columns = computed(() => [
@@ -102,12 +107,7 @@ const columns = computed(() => [
{
name: 'total',
label: t('Total'),
- field: ({ sale }) => {
- const amount = sale.price * sale.quantity;
- const appliedDiscount = (sale.discount * amount) / 100;
-
- return amount - appliedDiscount;
- },
+ field: ({ sale }) => totalRow(sale),
format: (value) => toCurrency(value),
sortable: true,
},
@@ -129,6 +129,7 @@ async function updateDiscount({ saleFk, discount, canceller }) {
await axios.post(query, body, {
signal: canceller.signal,
});
+ await claimLinesForm.value.reload();
}
function onUpdateDiscount(response) {
@@ -151,8 +152,11 @@ function showImportDialog() {
.onOk(() => claimLinesForm.value.reload());
}
-function saveWhenHasChanges() {
- claimLinesForm.value.getChanges().updates && claimLinesForm.value.onSubmit();
+async function saveWhenHasChanges() {
+ if (claimLinesForm.value.getChanges().updates) {
+ await claimLinesForm.value.onSubmit();
+ await claimLinesForm.value.reload();
+ }
}
@@ -188,7 +192,6 @@ function saveWhenHasChanges() {
save-url="ClaimBeginnings/crud"
:filter="linesFilter"
@on-fetch="onFetch"
- @save-changes="onFetch"
v-model:selected="selected"
:default-save="false"
:default-reset="false"
diff --git a/src/pages/Claim/Card/ClaimSummary.vue b/src/pages/Claim/Card/ClaimSummary.vue
index f45d5765d..36a26008e 100644
--- a/src/pages/Claim/Card/ClaimSummary.vue
+++ b/src/pages/Claim/Card/ClaimSummary.vue
@@ -1,6 +1,6 @@
@@ -171,6 +179,7 @@ function openDialog(dmsId) {
@on-fetch="(data) => setClaimDms(data)"
ref="claimDmsRef"
/>
+ (ClaimStates = data)" auto-load />
{{ claim.id }} - {{ claim.client.name }} ({{ claim.client.id }})
+
+
+
+
+
+
+ {{ item.description }}
+
+
+
+
+
+
@@ -447,4 +486,8 @@ function openDialog(dmsId) {
.zindex {
z-index: 1;
}
+
+.change-state {
+ width: 10%;
+}
diff --git a/src/pages/Customer/Card/CustomerContacts.vue b/src/pages/Customer/Card/CustomerContacts.vue
index 6fb891dff..cd4d553df 100644
--- a/src/pages/Customer/Card/CustomerContacts.vue
+++ b/src/pages/Customer/Card/CustomerContacts.vue
@@ -1,5 +1,5 @@
@@ -30,6 +26,7 @@ onMounted(() => {
model="CustomerContacts"
ref="customerContactsRef"
url="ClientContacts"
+ auto-load
>
diff --git a/src/pages/Customer/components/CustomerAddressEdit.vue b/src/pages/Customer/components/CustomerAddressEdit.vue
index 3457c7ab5..734924993 100644
--- a/src/pages/Customer/components/CustomerAddressEdit.vue
+++ b/src/pages/Customer/components/CustomerAddressEdit.vue
@@ -180,10 +180,13 @@ function handleLocation(data, location) {
:rules="validate('Worker.postcode')"
:roles-allowed-to-create="['deliveryAssistant']"
:options="postcodesOptions"
- v-model="data.location"
+ v-model="data.postalCode"
@update:model-value="(location) => handleLocation(data, location)"
>
+
+
+
-
-
{{ t('Notes') }}
-import { ref, computed, onMounted } from 'vue';
+import { ref, computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
@@ -21,10 +21,6 @@ const sortEntryObservationOptions = (data) => {
);
};
-onMounted(() => {
- if (entryObservationsRef.value) entryObservationsRef.value.reload();
-});
-
const columns = computed(() => [
{
name: 'observationType',
@@ -65,6 +61,7 @@ const columns = computed(() => [
ref="entryObservationsRef"
:data-required="{ entryFk: params.id }"
v-model:selected="selected"
+ auto-load
>
[
const isNotEuro = (code) => code != 'EUR';
async function insert() {
- await axios.post('/InvoiceInDueDays/new ', { id: +invoiceId });
+ await axios.post('/InvoiceInDueDays/new', { id: +invoiceId });
await invoiceInFormRef.value.reload();
}
diff --git a/src/pages/Item/Card/ItemBarcode.vue b/src/pages/Item/Card/ItemBarcode.vue
index 26254ba84..b353d67c7 100644
--- a/src/pages/Item/Card/ItemBarcode.vue
+++ b/src/pages/Item/Card/ItemBarcode.vue
@@ -1,5 +1,5 @@
@@ -42,6 +38,7 @@ onMounted(async () => {
model="ItemBarcodes"
ref="itemBarcodeRef"
url="ItemBarcodes"
+ auto-load
>
diff --git a/src/pages/Item/Card/ItemDiary.vue b/src/pages/Item/Card/ItemDiary.vue
index 21249349f..c2687e0fd 100644
--- a/src/pages/Item/Card/ItemDiary.vue
+++ b/src/pages/Item/Card/ItemDiary.vue
@@ -1 +1,277 @@
-Item diary (CREAR CUANDO SE DESARROLLE EL MODULO DE ITEMS)
+
+
+
+ (itemBalances = data)"
+ />
+ (warehousesOptions = data)"
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ t('itemDiary.claim') }}: {{ row.claimFk }}
+
+
+
+
+
+
+
+ {{ toDateFormat(row.shipped) }}
+
+
+
+
+
+
+ {{ row.origin }}
+
+ {{ row.origin }}
+
+
+
+
+
+
+ {{ dashIfEmpty(row.name) }}
+
+
+ {{ dashIfEmpty(row.name) }}
+
+
+
+
+
+
+ {{ dashIfEmpty(row.invalue) }}
+
+
+
+
+
+
+ {{ dashIfEmpty(row.balance) }}
+
+
+
+
+
+
+
+
diff --git a/src/pages/Item/Card/ItemLastEntries.vue b/src/pages/Item/Card/ItemLastEntries.vue
new file mode 100644
index 000000000..5200db239
--- /dev/null
+++ b/src/pages/Item/Card/ItemLastEntries.vue
@@ -0,0 +1,317 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ row.entryFk }}
+
+
+
+
+
+
+ {{ dashIfEmpty(row.packing) }}
+ {{ t('lastEntries.packing') }}
+
+
+
+
+ {{ value }}
+
+ {{ t('lastEntries.grouping') }}/{{ t('lastEntries.packing') }}
+
+
+
+
+
+ {{ dashIfEmpty(row.grouping) }}
+ {{ t('lastEntries.grouping') }}
+
+
+
+
+
+
+ {{ toCurrency(row.cost, 'EUR', 3) }}
+
+ {{ t('lastEntries.cost') }}:
+ {{ toCurrency(dashIfEmpty(row.buyingValue), 'EUR', 3) }}
+ {{ t('lastEntries.package') }}:
+ {{ toCurrency(dashIfEmpty(row.packageValue), 'EUR', 3)
+ }}
+ {{ $t('lastEntries.freight') }}:
+ {{ toCurrency(dashIfEmpty(row.freightValue), 'EUR', 3)
+ }}
+ {{ t('lastEntries.comission') }}:
+ {{ toCurrency(dashIfEmpty(row.comissionValue), 'EUR', 3) }}
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/Item/Card/ItemTax.vue b/src/pages/Item/Card/ItemTax.vue
index 76663932c..489a2c7b2 100644
--- a/src/pages/Item/Card/ItemTax.vue
+++ b/src/pages/Item/Card/ItemTax.vue
@@ -1 +1,91 @@
-Item tax
+
+
+ (taxesOptions = data)"
+ auto-load
+ />
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/Item/ItemTypeCreate.vue b/src/pages/Item/ItemTypeCreate.vue
new file mode 100644
index 000000000..af3dc34ea
--- /dev/null
+++ b/src/pages/Item/ItemTypeCreate.vue
@@ -0,0 +1,91 @@
+
+
+
+ (workersOptions = data)"
+ :filter="{ order: 'firstName ASC', fields: ['id', 'firstName'] }"
+ auto-load
+ />
+ (categoriesOptions = data)"
+ :filter="{ order: 'name ASC', fields: ['id', 'name'] }"
+ auto-load
+ />
+ (temperaturesOptions = data)"
+ :filter="{ order: 'name ASC', fields: ['code', 'name'] }"
+ auto-load
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/Item/ItemTypeList.vue b/src/pages/Item/ItemTypeList.vue
new file mode 100644
index 000000000..9d826655f
--- /dev/null
+++ b/src/pages/Item/ItemTypeList.vue
@@ -0,0 +1,142 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{ t('globals.collapseMenu') }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ t('New item type') }}
+
+
+
+
+
+es:
+ New item type: Nueva familia
+ Name: Nombre
+ Search item type: Buscar familia
+ Search itemType by id, name or code: Buscar familia por id, nombre o código
+
diff --git a/src/pages/Item/locale/en.yml b/src/pages/Item/locale/en.yml
new file mode 100644
index 000000000..9acd1de4d
--- /dev/null
+++ b/src/pages/Item/locale/en.yml
@@ -0,0 +1,36 @@
+itemDiary:
+ date: Date
+ id: Id
+ state: State
+ reference: Reference
+ client: Client
+ in: In
+ out: Out
+ balance: Balance
+ claim: Claim
+ showBefore: Show what's before the inventory
+ since: Since
+ warehouse: Warehouse
+tax:
+ country: Country
+ class: Class
+lastEntries:
+ since: Since
+ to: To
+ ig: Ig
+ warehouse: Warehouse
+ landed: Landed
+ entry: Entry
+ pvp: PVP
+ label: Label
+ packing: Packing
+ grouping: Grouping
+ stems: Stems
+ quantity: Quantity
+ cost: Cost
+ kg: Kg.
+ cube: Cube
+ supplier: Supplier
+ package: Package
+ freight: Freight
+ comission: Comission
diff --git a/src/pages/Item/locale/es.yml b/src/pages/Item/locale/es.yml
new file mode 100644
index 000000000..46e0d9eb7
--- /dev/null
+++ b/src/pages/Item/locale/es.yml
@@ -0,0 +1,36 @@
+itemDiary:
+ date: Fecha
+ id: Id
+ state: Estado
+ reference: Referencia
+ client: Cliente
+ in: Entrada
+ out: Salida
+ balance: Balance
+ claim: Reclamación
+ showBefore: Mostrar lo anterior al inventario
+ since: Desde
+ warehouse: Almacén
+tax:
+ country: País
+ class: Clase
+lastEntries:
+ since: Desde
+ to: Hasta
+ ig: Ig
+ warehouse: Almacén
+ landed: F. Entrega
+ entry: Entrada
+ pvp: PVP
+ label: Etiquetas
+ packing: Packing
+ grouping: Grouping
+ stems: Tallos
+ quantity: Cantidad
+ cost: Coste
+ kg: Kg.
+ cube: Cubo
+ supplier: Proveedor
+ package: Embalaje
+ freight: Porte
+ comission: Comisión
diff --git a/src/pages/ItemType/Card/ItemTypeBasicData.vue b/src/pages/ItemType/Card/ItemTypeBasicData.vue
new file mode 100644
index 000000000..0bdfab951
--- /dev/null
+++ b/src/pages/ItemType/Card/ItemTypeBasicData.vue
@@ -0,0 +1,79 @@
+
+
+ (workersOptions = data)"
+ :filter="{ order: 'firstName ASC', fields: ['id', 'firstName'] }"
+ auto-load
+ />
+ (categoriesOptions = data)"
+ :filter="{ order: 'name ASC', fields: ['id', 'name'] }"
+ auto-load
+ />
+ (temperaturesOptions = data)"
+ :filter="{ order: 'name ASC', fields: ['code', 'name'] }"
+ auto-load
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/ItemType/Card/ItemTypeCard.vue b/src/pages/ItemType/Card/ItemTypeCard.vue
new file mode 100644
index 000000000..cb8adf7f6
--- /dev/null
+++ b/src/pages/ItemType/Card/ItemTypeCard.vue
@@ -0,0 +1,12 @@
+
+
+
+
diff --git a/src/pages/ItemType/Card/ItemTypeDescriptor.vue b/src/pages/ItemType/Card/ItemTypeDescriptor.vue
new file mode 100644
index 000000000..e565a791b
--- /dev/null
+++ b/src/pages/ItemType/Card/ItemTypeDescriptor.vue
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+ {{ t('Go to module index') }}
+
+
+
+
+
+
+
+
+ {{ entity.worker?.firstName }}
+
+
+
+
+
+
+
+
+
+es:
+ Go to module index: Ir al índice del módulo
+
diff --git a/src/pages/ItemType/Card/ItemTypeSummary.vue b/src/pages/ItemType/Card/ItemTypeSummary.vue
new file mode 100644
index 000000000..62d1c74ab
--- /dev/null
+++ b/src/pages/ItemType/Card/ItemTypeSummary.vue
@@ -0,0 +1,109 @@
+
+
+
+ setItemTypeData(data)"
+ class="full-width"
+ >
+
+
+
+
+
+ {{ itemType.id }} - {{ itemType.name }} -
+ {{ itemType.worker?.firstName }}
+ {{ itemType.worker?.lastName }}
+
+
+
+
+
+
+
+
+
+
+ {{ itemType.worker?.firstName }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/ItemType/ItemTypeFilter.vue b/src/pages/ItemType/ItemTypeFilter.vue
new file mode 100644
index 000000000..2a86795c2
--- /dev/null
+++ b/src/pages/ItemType/ItemTypeFilter.vue
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+ {{ t(`params.${tag.label}`) }}:
+ {{ formatFn(tag.value) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+en:
+ params:
+ name: Name
+ code: Code
+es:
+ params:
+ name: Nombre
+ code: Código
+ Name: Nombre
+ Code: Código
+
diff --git a/src/pages/ItemType/locale/en.yml b/src/pages/ItemType/locale/en.yml
new file mode 100644
index 000000000..7889418ea
--- /dev/null
+++ b/src/pages/ItemType/locale/en.yml
@@ -0,0 +1,12 @@
+shared:
+ code: Code
+ name: Name
+ worker: Worker
+ category: Category
+ temperature: Temperature
+summary:
+ id: id
+ life: Life
+ promo: Promo
+ itemPackingType: Item packing type
+ isUnconventionalSize: Is unconventional size
diff --git a/src/pages/ItemType/locale/es.yml b/src/pages/ItemType/locale/es.yml
new file mode 100644
index 000000000..9a94dceb6
--- /dev/null
+++ b/src/pages/ItemType/locale/es.yml
@@ -0,0 +1,17 @@
+shared:
+ code: Código
+ name: Nombre
+ worker: Trabajador
+ category: Reino
+ temperature: Temperatura
+summary:
+ id: id
+ code: Código
+ name: Nombre
+ worker: Trabajador
+ category: Reino
+ temperature: Temperatura
+ life: Vida
+ promo: Promoción
+ itemPackingType: Tipo de embalaje
+ isUnconventionalSize: Es de tamaño poco convencional
diff --git a/src/pages/Login/LoginMain.vue b/src/pages/Login/LoginMain.vue
index fcde51edf..5a3490f50 100644
--- a/src/pages/Login/LoginMain.vue
+++ b/src/pages/Login/LoginMain.vue
@@ -38,7 +38,13 @@ async function onSubmit() {
if (!multimediaToken) return;
- await session.login(data.token, multimediaToken.id, keepLogin.value);
+ const login = {
+ ...data,
+ created: Date.now(),
+ tokenMultimedia: multimediaToken.id,
+ keepLogin: keepLogin.value,
+ };
+ await session.login(login);
quasar.notify({
message: t('login.loginSuccess'),
diff --git a/src/pages/Route/Roadmap/RoadmapStops.vue b/src/pages/Route/Roadmap/RoadmapStops.vue
index 10d6e6066..5c3bd51e7 100644
--- a/src/pages/Route/Roadmap/RoadmapStops.vue
+++ b/src/pages/Route/Roadmap/RoadmapStops.vue
@@ -3,9 +3,9 @@ import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import FetchData from 'components/FetchData.vue';
-import { onMounted, ref } from 'vue';
+import { ref } from 'vue';
import CrudModel from 'components/CrudModel.vue';
-import RoadmapAddStopForm from "pages/Route/Roadmap/RoadmapAddStopForm.vue";
+import RoadmapAddStopForm from 'pages/Route/Roadmap/RoadmapAddStopForm.vue';
const { t } = useI18n();
const route = useRoute();
@@ -21,10 +21,6 @@ const updateDefaultStop = (data) => {
eta.setDate(eta.getDate() + 1);
defaultStop.value.eta = eta.toISOString();
};
-
-onMounted(() => {
- if (roadmapStopsCrudRef.value) roadmapStopsCrudRef.value.reload();
-});
@@ -43,6 +39,7 @@ onMounted(() => {
:filter="{ where: { roadmapFk: route.params?.id } }"
:default-remove="false"
:data-required="defaultStop"
+ auto-load
>
@@ -51,7 +48,10 @@ onMounted(() => {
:key="index"
class="row no-wrap"
>
-
+
$props.id || route.params.id);
-const isDialog = Boolean($props.id);
-const hideRightDrawer = () => {
- if (!isDialog) {
- stateStore.rightDrawer = false;
- }
-};
-onMounted(hideRightDrawer);
-onUnmounted(hideRightDrawer);
+const isDialog = false;
+// const hideRightDrawer = () => {
+// if (!isDialog) {
+// stateStore.rightDrawer = false;
+// }
+// };
+// onMounted(hideRightDrawer);
+// onUnmounted(hideRightDrawer);
const filter = {
include: [
{
@@ -46,23 +46,6 @@ const filter = {
-
-
-
-
-
- {{ t('globals.collapseMenu') }}
-
-
-
-
-
@@ -102,18 +85,4 @@ const filter = {
-
-
-
-
-
diff --git a/src/pages/Shelving/ShelvingList.vue b/src/pages/Shelving/ShelvingList.vue
index a5a24e84d..4584248bf 100644
--- a/src/pages/Shelving/ShelvingList.vue
+++ b/src/pages/Shelving/ShelvingList.vue
@@ -72,7 +72,6 @@ function exprBuilder(param, value) {
:filter="filter"
:expr-builder="exprBuilder"
:limit="20"
- auto-load
>
-import { ref, onMounted } from 'vue';
+import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
@@ -59,10 +59,6 @@ const setWireTransfer = async () => {
console.error('Error setting wire transfer', err);
}
};
-
-onMounted(() => {
- if (supplierAccountRef.value) supplierAccountRef.value.reload();
-});
{
:default-remove="false"
:data-required="{ supplierFk: route.params.id }"
@save-changes="onChangesSaved()"
+ auto-load
>
diff --git a/src/pages/Supplier/Card/SupplierAgencyTerm.vue b/src/pages/Supplier/Card/SupplierAgencyTerm.vue
index 769ff4dad..50a4f7adc 100644
--- a/src/pages/Supplier/Card/SupplierAgencyTerm.vue
+++ b/src/pages/Supplier/Card/SupplierAgencyTerm.vue
@@ -1,5 +1,5 @@
{
:data-required="{
supplierFk: route.params.id,
}"
+ auto-load
>
diff --git a/src/pages/Supplier/Card/SupplierContacts.vue b/src/pages/Supplier/Card/SupplierContacts.vue
index a78c376a9..92ba1c1fc 100644
--- a/src/pages/Supplier/Card/SupplierContacts.vue
+++ b/src/pages/Supplier/Card/SupplierContacts.vue
@@ -1,5 +1,5 @@
@@ -36,6 +32,7 @@ onMounted(() => {
ref="supplierContactRef"
:default-remove="false"
:data-required="{ supplierFk: route.params.id }"
+ auto-load
>
diff --git a/src/pages/Ticket/Card/TicketSummary.vue b/src/pages/Ticket/Card/TicketSummary.vue
index 364ae04a6..af501240b 100644
--- a/src/pages/Ticket/Card/TicketSummary.vue
+++ b/src/pages/Ticket/Card/TicketSummary.vue
@@ -188,7 +188,7 @@ async function changeState(value) {
:label="t('ticket.summary.landed')"
:value="toDate(ticket.landed)"
/>
-
+
{{ t('ticket.summary.consigneePhone') }}
diff --git a/src/pages/Zone/Card/ZoneCard.vue b/src/pages/Zone/Card/ZoneCard.vue
new file mode 100644
index 000000000..948636c55
--- /dev/null
+++ b/src/pages/Zone/Card/ZoneCard.vue
@@ -0,0 +1,6 @@
+
+
+
+
diff --git a/src/pages/Zone/Card/ZoneDescriptor.vue b/src/pages/Zone/Card/ZoneDescriptor.vue
new file mode 100644
index 000000000..486e4f063
--- /dev/null
+++ b/src/pages/Zone/Card/ZoneDescriptor.vue
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+ {{ t('Summary') }}
+
+
+
+
+
+ {{ console.log('entity', entity) }}
+
+
+
+
+
+
+
+
+
+
+es:
+ Summary: Detalles
+ The zone will be deleted: El envío será eliminado
+ Do you want to delete this zone?: ¿Quieres eliminar este envío?
+ All zones with current agency: Todos los envíos con la agencia actual
+ Agency: Agencia
+ Closing hour: Hora de cierre
+ zoneing days: Días de viaje
+ Price: Precio
+ Bonus: Bonificación
+
diff --git a/src/pages/Zone/Card/ZoneDescriptorMenuItems.vue b/src/pages/Zone/Card/ZoneDescriptorMenuItems.vue
new file mode 100644
index 000000000..b6c7f28b3
--- /dev/null
+++ b/src/pages/Zone/Card/ZoneDescriptorMenuItems.vue
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+ {{ t('To clone zone') }}
+
+
+
+
+
+ {{ t('deleteOrder') }}
+
+
+
+
+en:
+ deleteOrder: Delete order
+ confirmDeletion: Confirm deletion
+ confirmDeletionMessage: Are you sure you want to delete this order?
+
+es:
+ To clone zone: Clonar zone
+ deleteOrder: Eliminar pedido
+ confirmDeletion: Confirmar eliminación
+ confirmDeletionMessage: Seguro que quieres eliminar este pedido?
+
+
diff --git a/src/pages/Zone/Card/ZoneDescriptorProxy.vue b/src/pages/Zone/Card/ZoneDescriptorProxy.vue
new file mode 100644
index 000000000..15c5fb0e5
--- /dev/null
+++ b/src/pages/Zone/Card/ZoneDescriptorProxy.vue
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
diff --git a/src/pages/Zone/Card/ZoneSummary.vue b/src/pages/Zone/Card/ZoneSummary.vue
new file mode 100644
index 000000000..00df03cb0
--- /dev/null
+++ b/src/pages/Zone/Card/ZoneSummary.vue
@@ -0,0 +1,94 @@
+
+
+
+
+
+ {{ entity.id }} - {{ entity.firstName }} {{ entity.lastName }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ t('zone.summary.phoneExtension') }}
+
+
+
+
+
+ {{ t('zone.summary.entPhone') }}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ t('zone.summary.sipExtension') }}
+
+
+
+
+
+
+
diff --git a/src/router/index.js b/src/router/index.js
index 3e442f0e6..7a0aedcae 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -12,6 +12,7 @@ import { useSession } from 'src/composables/useSession';
import { useRole } from 'src/composables/useRole';
import { useUserConfig } from 'src/composables/useUserConfig';
import { toLowerCamel } from 'src/filters';
+import { useTokenConfig } from 'src/composables/useTokenConfig';
const state = useState();
const session = useSession();
@@ -55,6 +56,7 @@ export default route(function (/* { store, ssrContext } */) {
if (stateRoles.length === 0) {
await useRole().fetch();
await useUserConfig().fetch();
+ await useTokenConfig().fetch();
}
const matches = to.matched;
const hasRequiredRoles = matches.every((route) => {
diff --git a/src/router/modules/department.js b/src/router/modules/department.js
index aaffc3460..dfd5e64ba 100644
--- a/src/router/modules/department.js
+++ b/src/router/modules/department.js
@@ -6,6 +6,7 @@ export default {
meta: {
title: 'department',
icon: 'vn:greuge',
+ moduleName: 'Department',
},
component: RouterView,
redirect: { name: 'DepartmentCard' },
diff --git a/src/router/modules/index.js b/src/router/modules/index.js
index 6f4b0b35e..7fff2f2e5 100644
--- a/src/router/modules/index.js
+++ b/src/router/modules/index.js
@@ -16,6 +16,8 @@ import Entry from './entry';
import roadmap from './roadmap';
import Parking from './parking';
import Agency from './agency';
+import ItemType from './itemType';
+import Zone from './zone';
export default [
Item,
@@ -36,4 +38,6 @@ export default [
roadmap,
Parking,
Agency,
+ ItemType,
+ Zone,
];
diff --git a/src/router/modules/item.js b/src/router/modules/item.js
index bc1e72a94..f0c68f0e7 100644
--- a/src/router/modules/item.js
+++ b/src/router/modules/item.js
@@ -11,7 +11,13 @@ export default {
component: RouterView,
redirect: { name: 'ItemMain' },
menus: {
- main: ['ItemList', 'WasteBreakdown', 'ItemFixedPrice', 'ItemRequest'],
+ main: [
+ 'ItemList',
+ 'WasteBreakdown',
+ 'ItemFixedPrice',
+ 'ItemRequest',
+ 'ItemTypeList',
+ ],
card: [
'ItemBasicData',
'ItemLog',
@@ -20,6 +26,7 @@ export default {
'ItemTax',
'ItemBotanical',
'ItemBarcode',
+ 'ItemLastEntries',
],
},
children: [
@@ -68,6 +75,23 @@ export default {
'https://grafana.verdnatura.es/d/TTNXQAxVk';
},
},
+ {
+ path: 'item-type-list',
+ name: 'ItemTypeList',
+ meta: {
+ title: 'family',
+ icon: 'contact_support',
+ },
+ component: () => import('src/pages/Item/ItemTypeList.vue'),
+ },
+ {
+ path: 'item-type-list/create',
+ name: 'ItemTypeCreate',
+ meta: {
+ title: 'itemTypeCreate',
+ },
+ component: () => import('src/pages/Item/ItemTypeCreate.vue'),
+ },
{
path: 'request',
name: 'ItemRequest',
@@ -112,6 +136,15 @@ export default {
},
component: () => import('src/pages/Item/Card/ItemTags.vue'),
},
+ {
+ path: 'last-entries',
+ name: 'ItemLastEntries',
+ meta: {
+ title: 'lastEntries',
+ icon: 'vn:regentry',
+ },
+ component: () => import('src/pages/Item/Card/ItemLastEntries.vue'),
+ },
{
path: 'tax',
name: 'ItemTax',
@@ -121,6 +154,15 @@ export default {
},
component: () => import('src/pages/Item/Card/ItemTax.vue'),
},
+ {
+ path: 'botanical',
+ name: 'ItemBotanical',
+ meta: {
+ title: 'botanical',
+ icon: 'local_florist',
+ },
+ component: () => import('src/pages/Item/Card/ItemBotanical.vue'),
+ },
{
path: 'barcode',
name: 'ItemBarcode',
@@ -134,8 +176,8 @@ export default {
path: 'diary',
name: 'ItemDiary',
meta: {
- title: 'basicData',
- icon: 'vn:settings',
+ title: 'diary',
+ icon: 'vn:transaction',
},
component: () => import('src/pages/Item/Card/ItemDiary.vue'),
},
@@ -144,19 +186,10 @@ export default {
name: 'ItemLog',
meta: {
title: 'log',
- icon: 'history',
+ icon: 'vn:History',
},
component: () => import('src/pages/Item/Card/ItemLog.vue'),
},
- {
- path: 'botanical',
- name: 'ItemBotanical',
- meta: {
- title: 'botanical',
- icon: 'vn:botanical',
- },
- component: () => import('src/pages/Item/Card/ItemBotanical.vue'),
- },
],
},
],
diff --git a/src/router/modules/itemType.js b/src/router/modules/itemType.js
new file mode 100644
index 000000000..8064c41ff
--- /dev/null
+++ b/src/router/modules/itemType.js
@@ -0,0 +1,46 @@
+import { RouterView } from 'vue-router';
+
+export default {
+ path: '/item/item-type',
+ name: 'ItemType',
+ meta: {
+ title: 'itemType',
+ icon: 'contact_support',
+ moduleName: 'ItemType',
+ },
+ component: RouterView,
+ redirect: { name: 'ItemTypeList' },
+ menus: {
+ main: [],
+ card: ['ItemTypeBasicData'],
+ },
+ children: [
+ {
+ name: 'ItemTypeCard',
+ path: ':id',
+ component: () => import('src/pages/ItemType/Card/ItemTypeCard.vue'),
+ redirect: { name: 'ItemTypeSummary' },
+ children: [
+ {
+ name: 'ItemTypeSummary',
+ path: 'summary',
+ meta: {
+ title: 'summary',
+ },
+ component: () =>
+ import('src/pages/ItemType/Card/ItemTypeSummary.vue'),
+ },
+ {
+ name: 'ItemTypeBasicData',
+ path: 'basic-data',
+ meta: {
+ title: 'basicData',
+ icon: 'vn:settings',
+ },
+ component: () =>
+ import('src/pages/ItemType/Card/ItemTypeBasicData.vue'),
+ },
+ ],
+ },
+ ],
+};
diff --git a/src/router/modules/roadmap.js b/src/router/modules/roadmap.js
index 02edf94be..6b2aa6a13 100644
--- a/src/router/modules/roadmap.js
+++ b/src/router/modules/roadmap.js
@@ -6,6 +6,7 @@ export default {
meta: {
title: 'roadmap',
icon: 'vn:troncales',
+ moduleName: 'Roadmap',
},
component: RouterView,
redirect: { name: 'RouteMain' },
diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js
new file mode 100644
index 000000000..079dfaa84
--- /dev/null
+++ b/src/router/modules/zone.js
@@ -0,0 +1,160 @@
+import { RouterView } from 'vue-router';
+
+export default {
+ path: '/zone',
+ name: 'Zone',
+ meta: {
+ title: 'zones',
+ icon: 'vn:zone',
+ moduleName: 'Zone',
+ },
+ component: RouterView,
+ redirect: { name: 'ZoneMain' },
+ menus: {
+ main: [
+ /*'ZoneList', 'ZoneDeliveryList', 'ZoneUpcomingList'*/
+ ],
+ card: [
+ //
+ ],
+ },
+ children: [
+ // {
+ // path: '/zone',
+ // name: 'ZoneMain',
+ // component: () => import('src/pages/Zone/ZoneMain.vue'),
+ // redirect: { name: 'ZoneList' },
+ // children: [
+ // {
+ // path: 'list',
+ // name: 'ZoneList',
+ // meta: {
+ // title: 'zonesList',
+ // icon: 'vn:zone',
+ // },
+ // component: () => import('src/pages/Zone/ZoneList.vue'),
+ // },
+ // {
+ // path: 'create',
+ // name: 'ZoneCreate',
+ // meta: {
+ // title: 'zoneCreate',
+ // icon: 'create',
+ // },
+ // component: () => import('src/pages/Zone/ZoneCreate.vue'),
+ // },
+ // {
+ // path: ':id/edit',
+ // name: 'ZoneEdit',
+ // meta: {
+ // title: 'zoneEdit',
+ // icon: 'edit',
+ // },
+ // component: () => import('src/pages/Zone/ZoneCreate.vue'),
+ // },
+ // {
+ // path: 'counter',
+ // name: 'ZoneCounter',
+ // meta: {
+ // title: 'zoneCounter',
+ // icon: 'add_circle',
+ // },
+ // component: () => import('src/pages/Zone/ZoneCounter.vue'),
+ // },
+ // ],
+ // },
+ {
+ name: 'ZoneCard',
+ path: ':id',
+ component: () => import('src/pages/Zone/Card/ZoneCard.vue'),
+ redirect: { name: 'ZoneSummary' },
+ children: [
+ {
+ name: 'ZoneSummary',
+ path: 'summary',
+ meta: {
+ title: 'summary',
+ icon: 'launch',
+ },
+ component: () => import('src/pages/Zone/Card/ZoneSummary.vue'),
+ },
+ // {
+ // path: '/zone/delivery',
+ // name: 'ZoneDeliveryMain',
+ // component: () => import('src/pages/Zone/ZoneMain.vue'),
+ // redirect: { name: 'ZoneDeliveryList' },
+ // children: [
+ // {
+ // path: 'list',
+ // name: 'ZoneDeliveryList',
+ // meta: {
+ // title: 'deliveryList',
+ // icon: 'today',
+ // },
+ // component: () =>
+ // import('src/pages/Zone/Delivery/ZoneDeliveryList.vue'),
+ // },
+ // {
+ // path: 'create',
+ // name: 'ZoneDeliveryCreate',
+ // meta: {
+ // title: 'deliveryCreate',
+ // icon: 'create',
+ // },
+ // component: () =>
+ // import('src/pages/Zone/Delivery/ZoneDeliveryCreate.vue'),
+ // },
+ // {
+ // path: ':id/edit',
+ // name: 'ZoneDeliveryEdit',
+ // meta: {
+ // title: 'deliveryEdit',
+ // icon: 'edit',
+ // },
+ // component: () =>
+ // import('src/pages/Zone/Delivery/ZoneDeliveryCreate.vue'),
+ // },
+ // ],
+ // },
+ // {
+ // path: '/zone/upcoming',
+ // name: 'ZoneUpcomingMain',
+ // component: () => import('src/pages/Zone/ZoneMain.vue'),
+ // redirect: { name: 'ZoneUpcomingList' },
+ // children: [
+ // {
+ // path: 'list',
+ // name: 'ZoneUpcomingList',
+ // meta: {
+ // title: 'upcomingList',
+ // icon: 'today',
+ // },
+ // component: () =>
+ // import('src/pages/Zone/Upcoming/ZoneUpcomingList.vue'),
+ // },
+ // {
+ // path: 'create',
+ // name: 'ZoneUpcomingCreate',
+ // meta: {
+ // title: 'upcomingCreate',
+ // icon: 'create',
+ // },
+ // component: () =>
+ // import('src/pages/Zone/Upcoming/ZoneUpcomingCreate.vue'),
+ // },
+ // {
+ // path: ':id/edit',
+ // name: 'ZoneUpcomingEdit',
+ // meta: {
+ // title: 'upcomingEdit',
+ // icon: 'edit',
+ // },
+ // component: () =>
+ // import('src/pages/Zone/Upcoming/ZoneUpcomingCreate.vue'),
+ // },
+ // ],
+ // },
+ ],
+ },
+ ],
+};
diff --git a/src/router/routes.js b/src/router/routes.js
index ca52441e7..04780ee17 100644
--- a/src/router/routes.js
+++ b/src/router/routes.js
@@ -10,12 +10,14 @@ import supplier from './modules/Supplier';
import route from './modules/route';
import travel from './modules/travel';
import department from './modules/department';
+import ItemType from './modules/itemType';
import shelving from 'src/router/modules/shelving';
import order from 'src/router/modules/order';
import entry from 'src/router/modules/entry';
import roadmap from 'src/router/modules/roadmap';
import parking from 'src/router/modules/parking';
import agency from 'src/router/modules/agency';
+import zone from 'src/router/modules/zone';
const routes = [
{
@@ -73,6 +75,8 @@ const routes = [
entry,
parking,
agency,
+ ItemType,
+ zone,
{
path: '/:catchAll(.*)*',
name: 'NotFound',
diff --git a/src/stores/useNavigationStore.js b/src/stores/useNavigationStore.js
index f075301f6..ee1e04e9b 100644
--- a/src/stores/useNavigationStore.js
+++ b/src/stores/useNavigationStore.js
@@ -21,6 +21,7 @@ export const useNavigationStore = defineStore('navigationStore', () => {
'ticket',
'worker',
'wagon',
+ 'zone',
];
const pinnedModules = ref([]);
const role = useRole();
diff --git a/test/cypress/support/commands.js b/test/cypress/support/commands.js
index 28a8aa979..e7f8cb9d9 100755
--- a/test/cypress/support/commands.js
+++ b/test/cypress/support/commands.js
@@ -38,6 +38,15 @@ Cypress.Commands.add('login', (user) => {
},
}).then((response) => {
window.localStorage.setItem('token', response.body.token);
+ cy.request({
+ method: 'GET',
+ url: '/api/VnUsers/ShareToken',
+ headers: {
+ Authorization: window.localStorage.getItem('token'),
+ },
+ }).then(({ body }) => {
+ window.localStorage.setItem('tokenMultimedia', body.multimediaToken.id);
+ });
});
});
diff --git a/test/vitest/__tests__/composables/useSession.spec.js b/test/vitest/__tests__/composables/useSession.spec.js
index f9f3dcb80..2292859a9 100644
--- a/test/vitest/__tests__/composables/useSession.spec.js
+++ b/test/vitest/__tests__/composables/useSession.spec.js
@@ -1,5 +1,5 @@
-import { vi, describe, expect, it } from 'vitest';
-import { axios } from 'app/test/vitest/helper';
+import { vi, describe, expect, it, beforeAll, beforeEach } from 'vitest';
+import { axios, flushPromises } from 'app/test/vitest/helper';
import { useSession } from 'composables/useSession';
import { useState } from 'composables/useState';
@@ -63,73 +63,148 @@ describe('session', () => {
});
});
- describe('login', () => {
- const expectedUser = {
- id: 999,
- name: `T'Challa`,
- nickname: 'Black Panther',
- lang: 'en',
- userConfig: {
- darkMode: false,
- },
- };
- const rolesData = [
- {
- role: {
- name: 'salesPerson',
+ describe(
+ 'login',
+ () => {
+ const expectedUser = {
+ id: 999,
+ name: `T'Challa`,
+ nickname: 'Black Panther',
+ lang: 'en',
+ userConfig: {
+ darkMode: false,
},
- },
- {
- role: {
- name: 'admin',
+ };
+ const rolesData = [
+ {
+ role: {
+ name: 'salesPerson',
+ },
},
- },
- ];
+ {
+ role: {
+ name: 'admin',
+ },
+ },
+ ];
- it('should fetch the user roles and then set token in the sessionStorage', async () => {
- const expectedRoles = ['salesPerson', 'admin'];
- vi.spyOn(axios, 'get').mockResolvedValue({
- data: { roles: rolesData, user: expectedUser },
+ it('should fetch the user roles and then set token in the sessionStorage', async () => {
+ const expectedRoles = ['salesPerson', 'admin'];
+ vi.spyOn(axios, 'get').mockResolvedValue({
+ data: { roles: rolesData, user: expectedUser },
+ });
+
+ const expectedToken = 'mySessionToken';
+ const expectedTokenMultimedia = 'mySessionTokenMultimedia';
+ const keepLogin = false;
+
+ await session.login({
+ token: expectedToken,
+ tokenMultimedia: expectedTokenMultimedia,
+ keepLogin,
+ });
+
+ const roles = state.getRoles();
+ const localToken = localStorage.getItem('token');
+ const sessionToken = sessionStorage.getItem('token');
+
+ expect(roles.value).toEqual(expectedRoles);
+ expect(localToken).toBeNull();
+ expect(sessionToken).toEqual(expectedToken);
+
+ await session.destroy(); // this clears token and user for any other test
});
- const expectedToken = 'mySessionToken';
- const expectedTokenMultimedia = 'mySessionTokenMultimedia';
- const keepLogin = false;
+ it('should fetch the user roles and then set token in the localStorage', async () => {
+ const expectedRoles = ['salesPerson', 'admin'];
+ vi.spyOn(axios, 'get').mockResolvedValue({
+ data: { roles: rolesData, user: expectedUser },
+ });
- await session.login(expectedToken,expectedTokenMultimedia, keepLogin);
+ const expectedToken = 'myLocalToken';
+ const expectedTokenMultimedia = 'myLocalTokenMultimedia';
+ const keepLogin = true;
- const roles = state.getRoles();
- const localToken = localStorage.getItem('token');
- const sessionToken = sessionStorage.getItem('token');
+ await session.login({
+ token: expectedToken,
+ tokenMultimedia: expectedTokenMultimedia,
+ keepLogin,
+ });
- expect(roles.value).toEqual(expectedRoles);
- expect(localToken).toBeNull();
- expect(sessionToken).toEqual(expectedToken);
+ const roles = state.getRoles();
+ const localToken = localStorage.getItem('token');
+ const sessionToken = sessionStorage.getItem('token');
- await session.destroy(); // this clears token and user for any other test
+ expect(roles.value).toEqual(expectedRoles);
+ expect(localToken).toEqual(expectedToken);
+ expect(sessionToken).toBeNull();
+
+ await session.destroy(); // this clears token and user for any other test
+ });
+ },
+ {}
+ );
+
+ describe('RenewToken', () => {
+ const expectedToken = 'myToken';
+ const expectedTokenMultimedia = 'myTokenMultimedia';
+ const currentDate = new Date();
+ beforeAll(() => {
+ const tokenConfig = {
+ id: 1,
+ renewPeriod: 21600,
+ courtesyTime: 60,
+ renewInterval: 300,
+ };
+ state.setTokenConfig(tokenConfig);
+ sessionStorage.setItem('renewPeriod', 1);
});
+ it('NOT Should renewToken', async () => {
+ const data = {
+ token: expectedToken,
+ tokenMultimedia: expectedTokenMultimedia,
+ keepLogin: false,
+ ttl: 1,
+ created: Date.now(),
+ };
+ session.setSession(data);
+ expect(sessionStorage.getItem('keepLogin')).toBeFalsy();
+ expect(sessionStorage.getItem('created')).toBeDefined();
+ expect(sessionStorage.getItem('ttl')).toEqual(1);
+ await session.checkValidity();
+ expect(sessionStorage.getItem('token')).toEqual(expectedToken);
+ expect(sessionStorage.getItem('tokenMultimedia')).toEqual(
+ expectedTokenMultimedia
+ );
+ });
+ it('Should renewToken', async () => {
+ currentDate.setMinutes(currentDate.getMinutes() - 100);
+ const data = {
+ token: expectedToken,
+ tokenMultimedia: expectedTokenMultimedia,
+ keepLogin: false,
+ ttl: 1,
+ created: currentDate,
+ };
+ session.setSession(data);
- it('should fetch the user roles and then set token in the localStorage', async () => {
- const expectedRoles = ['salesPerson', 'admin'];
- vi.spyOn(axios, 'get').mockResolvedValue({
- data: { roles: rolesData, user: expectedUser },
- });
-
- const expectedToken = 'myLocalToken';
- const expectedTokenMultimedia = 'myLocalTokenMultimedia';
- const keepLogin = true;
-
- await session.login(expectedToken, expectedTokenMultimedia, keepLogin);
-
- const roles = state.getRoles();
- const localToken = localStorage.getItem('token');
- const sessionToken = sessionStorage.getItem('token');
-
- expect(roles.value).toEqual(expectedRoles);
- expect(localToken).toEqual(expectedToken);
- expect(sessionToken).toBeNull();
-
- await session.destroy(); // this clears token and user for any other test
+ vi.spyOn(axios, 'post')
+ .mockResolvedValueOnce({
+ data: { id: '' },
+ })
+ .mockResolvedValueOnce({
+ data: {
+ id: '',
+ },
+ });
+ expect(sessionStorage.getItem('keepLogin')).toBeFalsy();
+ expect(sessionStorage.getItem('created')).toBeDefined();
+ expect(sessionStorage.getItem('ttl')).toEqual(1);
+ await session.checkValidity();
+ expect(sessionStorage.getItem('token')).not.toEqual(expectedToken);
+ expect(sessionStorage.getItem('tokenMultimedia')).not.toEqual(
+ expectedTokenMultimedia
+ );
});
});
});
diff --git a/test/vitest/__tests__/composables/useTokenConfig.spec.js b/test/vitest/__tests__/composables/useTokenConfig.spec.js
new file mode 100644
index 000000000..a25a4abb1
--- /dev/null
+++ b/test/vitest/__tests__/composables/useTokenConfig.spec.js
@@ -0,0 +1,31 @@
+import { vi, describe, expect, it } from 'vitest';
+import { axios, flushPromises } from 'app/test/vitest/helper';
+import { useTokenConfig } from 'composables/useTokenConfig';
+const tokenConfig = useTokenConfig();
+
+describe('useTokenConfig', () => {
+ describe('fetch', () => {
+ it('should call setTokenConfig of the state with the expected data', async () => {
+ const data = {
+ id: 1,
+ renewPeriod: 21600,
+ courtesyTime: 60,
+ renewInterval: 300,
+ };
+ vi.spyOn(axios, 'get').mockResolvedValueOnce({
+ data,
+ });
+
+ vi.spyOn(tokenConfig.state, 'setTokenConfig');
+
+ tokenConfig.fetch();
+
+ await flushPromises();
+
+ expect(tokenConfig.state.setTokenConfig).toHaveBeenCalledWith(data);
+
+ const renewPeriod = sessionStorage.getItem('renewPeriod');
+ expect(renewPeriod).toEqual(data.renewPeriod);
+ });
+ });
+});