fix(lint&types): resolve all lint warnings, typecheck errors and effect state updates across frontend application and admin panel
This commit is contained in:
1 parent
920dd532e8
commit
c1b2f416ed
29 files changed
+442
-352
No files matched your search
@@ -3,6 +3,7 @@ import { create } from "zustand";
|
||||
import { persist } from "zustand/middleware";
|
||||
import api from "../services/api";
|
||||
import { toast } from "sonner";
|
||||
import { useUserStore } from "./userStore";
|
||||
|
||||
export interface Reminder {
|
||||
id: string;
|
||||
@@ -54,7 +55,7 @@ interface PetStore {
|
||||
addReminder: (petId: string, reminder: Omit<Reminder, "id" | "completedDates">) => Promise<void>;
|
||||
toggleReminder: (petId: string, reminderId: string, date: string) => Promise<void>;
|
||||
addHealthLog: (petId: string, log: Omit<HealthLog, "id" | "date">) => Promise<void>;
|
||||
setPets: (pets: any[]) => void;
|
||||
setPets: (pets: Record<string, unknown>[]) => void;
|
||||
reset: () => void;
|
||||
}
|
||||
|
||||
@@ -125,7 +126,6 @@ export const usePetStore = create<PetStore>()(
|
||||
getActivePet: () => {
|
||||
const { pets, activePetId } = get();
|
||||
try {
|
||||
const { useUserStore } = require("./userStore");
|
||||
if (!useUserStore.getState().isLoggedIn) {
|
||||
return null;
|
||||
}
|
||||
@@ -195,29 +195,29 @@ export const usePetStore = create<PetStore>()(
|
||||
const mappedPets: PetProfile[] = backendPets.map(bp => {
|
||||
const existingLocal = currentLocalPets.find(lp => lp.id === bp.id);
|
||||
return {
|
||||
id: bp.id,
|
||||
name: bp.name,
|
||||
type: bp.type as any,
|
||||
breed: bp.breed,
|
||||
age: Number(bp.age),
|
||||
weight: Number(bp.weight),
|
||||
activityLevel: bp.activityLevel as any,
|
||||
medicalConditions: bp.medicalConditions?.map((mc: any) => mc.condition) || [],
|
||||
image: bp.imageUrl || undefined,
|
||||
reminders: bp.reminders?.map((r: any) => ({
|
||||
id: String(bp.id),
|
||||
name: String(bp.name),
|
||||
type: (bp.type as PetProfile['type']) || "سگ",
|
||||
breed: String(bp.breed || ''),
|
||||
age: Number(bp.age || 0),
|
||||
weight: Number(bp.weight || 0),
|
||||
activityLevel: (bp.activityLevel as PetProfile['activityLevel']) || "متوسط",
|
||||
medicalConditions: (bp.medicalConditions as Array<{ condition: string }>)?.map((mc) => mc.condition) || [],
|
||||
image: (bp.imageUrl as string) || undefined,
|
||||
reminders: (bp.reminders as Array<{ id: string; title: string; time: string; frequency: Reminder['frequency']; productId?: string; completions?: Array<{ completedDate: string }> }>)?.map((r) => ({
|
||||
id: r.id,
|
||||
title: r.title,
|
||||
time: r.time,
|
||||
frequency: r.frequency as any,
|
||||
frequency: r.frequency,
|
||||
productId: r.productId,
|
||||
completedDates: r.completions?.map((c: any) => c.completedDate) || []
|
||||
completedDates: r.completions?.map((c) => c.completedDate) || []
|
||||
})) || [],
|
||||
logs: bp.healthLogs?.map((hl: any) => ({
|
||||
logs: (bp.healthLogs as Array<{ id: string; loggedDate: string; appetite: HealthLog['appetite']; energy: HealthLog['energy']; digestion: HealthLog['digestion']; note?: string }>)?.map((hl) => ({
|
||||
id: hl.id,
|
||||
date: hl.loggedDate,
|
||||
appetite: hl.appetite as any,
|
||||
energy: hl.energy as any,
|
||||
digestion: hl.digestion as any,
|
||||
appetite: hl.appetite,
|
||||
energy: hl.energy,
|
||||
digestion: hl.digestion,
|
||||
note: hl.note || undefined
|
||||
})) || [],
|
||||
consumptions: existingLocal?.consumptions || []
|
||||
|
||||
Reference in new issue
Block a user