Skip to content
This repository was archived by the owner on Aug 24, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/core/data/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const SUGGESTED_DEEDS: Deed[] = [
icon: 'book-open-page-variant',
category: 'QURAN',
statuses: GENERIC_STATUSES,
goal: { value: 1, unit: 'page' },
isCore: false,
},
{
Expand All @@ -89,6 +90,7 @@ export const SUGGESTED_DEEDS: Deed[] = [
icon: 'brain',
category: 'QURAN',
statuses: GENERIC_STATUSES,
goal: { value: 1, unit: 'ayah' },
isCore: false,
},
// LEARNING
Expand All @@ -98,6 +100,7 @@ export const SUGGESTED_DEEDS: Deed[] = [
icon: 'book-education',
category: 'LEARNING',
statuses: GENERIC_STATUSES,
goal: { value: 1, unit: 'page' },
isCore: false,
},
// SOCIAL
Expand All @@ -119,6 +122,21 @@ export const SUGGESTED_DEEDS: Deed[] = [
},
];

const suggestedDeedById = new Map(SUGGESTED_DEEDS.map((deed) => [deed.id, deed]));

export const hydrateSuggestedDeed = (deed: Deed): Deed => {
const suggestedDeed = suggestedDeedById.get(deed.id);

if (!suggestedDeed?.goal || deed.goal) {
return deed;
}

return {
...deed,
goal: suggestedDeed.goal,
};
};

export const MOCK_LOGS: DeedLog[] = [
// Today's logs
{
Expand Down
12 changes: 10 additions & 2 deletions src/core/store/appStore.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
// src/core/store/appStore.ts
import { create } from 'zustand';
import { Deed, DeedLog, DeedStatus } from '../data/models';
import { GENERIC_STATUSES, MOCK_DEEDS, MOCK_LOGS, SUGGESTED_DEEDS } from '../data/mock';
import {
GENERIC_STATUSES,
MOCK_DEEDS,
MOCK_LOGS,
SUGGESTED_DEEDS,
hydrateSuggestedDeed,
} from '../data/mock';
import { loadData, saveData } from '../storage/storageService';
import { formatISO } from 'date-fns';
import { Alert, Appearance, I18nManager } from 'react-native';
Expand Down Expand Up @@ -66,6 +72,8 @@ const defaultSettings: AppSettings = {
reminderTime: '20:00',
};

const hydrateBuiltInDeedGoals = (deeds: Deed[]) => deeds.map(hydrateSuggestedDeed);

const persistState = (state: AppState) => {
const dataToSave: AppData = {
// Only save the user's actual deeds and logs, not the demo ones
Expand Down Expand Up @@ -103,7 +111,7 @@ const useAppStore = create<AppState & AppActions>((set, get) => ({

if (loadedData) {
settings = { ...defaultSettings, ...loadedData.settings };
initialDeeds = loadedData.deeds;
initialDeeds = hydrateBuiltInDeedGoals(loadedData.deeds);
initialLogs = loadedData.logs;
}

Expand Down
3 changes: 2 additions & 1 deletion src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Screen } from '@/components/Screen';
import { ThemedText } from '@/components/base/ThemedText';
import { FAB } from '@/components/FAB';
import { AppTheme } from '@/constants/theme';
import { hydrateSuggestedDeed } from '@/core/data/mock';
import { Deed, DeedLog, DeedStatus } from '@/core/data/models';
import i18n, { dateLocales } from '@/core/i18n';
import useAppStore from '@/core/store/appStore';
Expand Down Expand Up @@ -77,7 +78,7 @@ const HomeScreen = () => {
});

const sections: { title: string; data: Deed[] }[] = [];
const deedsByCategory = visibleDeeds.reduce(
const deedsByCategory = visibleDeeds.map(hydrateSuggestedDeed).reduce(
(acc, deed) => {
(acc[deed.category] = acc[deed.category] || []).push(deed);
return acc;
Expand Down
Loading