fix: Correct incomplete $state initialization in multiple Svelte components and pages.
This commit is contained in:
@@ -8,9 +8,9 @@
|
||||
const pedidosQuery = useQuery(api.pedidos.list, {});
|
||||
const acoesQuery = useQuery(api.acoes.list, {});
|
||||
|
||||
const pedidos = $derived(pedidosQuery.data || []);
|
||||
const loading = $derived(pedidosQuery.isLoading || acoesQuery.isLoading);
|
||||
const error = $derived(pedidosQuery.error?.message || acoesQuery.error?.message || null);
|
||||
let pedidos = $derived(pedidosQuery.data || []);
|
||||
let loading = $derived(pedidosQuery.isLoading || acoesQuery.isLoading);
|
||||
let error = $derived(pedidosQuery.error?.message || acoesQuery.error?.message || null);
|
||||
|
||||
function formatStatus(status: string) {
|
||||
switch (status) {
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
const acoesQuery = useQuery(api.acoes.list, {});
|
||||
|
||||
// Derived state
|
||||
const pedido = $derived(pedidoQuery.data);
|
||||
const items = $derived(itemsQuery.data || []);
|
||||
const history = $derived(historyQuery.data || []);
|
||||
const objetos = $derived(objetosQuery.data || []);
|
||||
const acoes = $derived(acoesQuery.data || []);
|
||||
let pedido = $derived(pedidoQuery.data);
|
||||
let items = $derived(itemsQuery.data || []);
|
||||
let history = $derived(historyQuery.data || []);
|
||||
let objetos = $derived(objetosQuery.data || []);
|
||||
let acoes = $derived(acoesQuery.data || []);
|
||||
|
||||
// Group items by user
|
||||
const groupedItems = $derived.by(() => {
|
||||
let groupedItems = $derived.by(() => {
|
||||
const groups: Record<string, { name: string; items: typeof items }> = {};
|
||||
for (const item of items) {
|
||||
const userId = item.adicionadoPor;
|
||||
@@ -50,7 +50,7 @@
|
||||
return Object.values(groups);
|
||||
});
|
||||
|
||||
const loading = $derived(
|
||||
let loading = $derived(
|
||||
pedidoQuery.isLoading ||
|
||||
itemsQuery.isLoading ||
|
||||
historyQuery.isLoading ||
|
||||
@@ -58,7 +58,7 @@
|
||||
acoesQuery.isLoading
|
||||
);
|
||||
|
||||
const error = $derived(
|
||||
let error = $derived(
|
||||
pedidoQuery.error?.message ||
|
||||
itemsQuery.error?.message ||
|
||||
historyQuery.error?.message ||
|
||||
@@ -183,7 +183,7 @@
|
||||
return unitValue * quantidade;
|
||||
}
|
||||
|
||||
const totalGeral = $derived(
|
||||
let totalGeral = $derived(
|
||||
items.reduce((sum, item) => sum + calculateItemTotal(item.valorEstimado, item.quantidade), 0)
|
||||
);
|
||||
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
const client = useConvexClient();
|
||||
|
||||
const acoesQuery = useQuery(api.acoes.list, {});
|
||||
const acoes = $derived(acoesQuery.data || []);
|
||||
let acoes = $derived(acoesQuery.data || []);
|
||||
|
||||
let searchQuery = $state('');
|
||||
const searchResultsQuery = useQuery(api.objetos.search, () => ({
|
||||
query: searchQuery
|
||||
}));
|
||||
const searchResults = $derived(searchResultsQuery.data);
|
||||
let searchResults = $derived(searchResultsQuery.data);
|
||||
|
||||
const formData = $state({
|
||||
let formData = $state({
|
||||
numeroSei: ''
|
||||
});
|
||||
let creating = $state(false);
|
||||
@@ -33,7 +33,7 @@
|
||||
};
|
||||
|
||||
let selectedItems = $state<SelectedItem[]>([]);
|
||||
const selectedObjetoIds = $derived(selectedItems.map((i) => i.objeto._id));
|
||||
let selectedObjetoIds = $derived(selectedItems.map((i) => i.objeto._id));
|
||||
|
||||
// Item configuration modal
|
||||
let showItemModal = $state(false);
|
||||
|
||||
Reference in New Issue
Block a user