Added Deleting modules functionality and removed modules import on module list that was stopping the screen from updating as it was using imported attribute rather than what was pasased onto it.

This commit is contained in:
bobbert committed 2025-10-25 22:04:16 +01:00
1 parent 0439b7ab33
commit 54e73d32e0
3 files changed
+21 -15

No files matched your search

+12 -7
View File
@@ -1,23 +1,28 @@
import {StyleSheet } from "react-native";
import { useState } from "react";
import { StyleSheet } from "react-native";
import Screen from "../layout/Screen";
import initialModules from "../../data/modules.js";
import ModuleList from "../entity/modules/ModuleList";
import initialModules from "../../data/modules.js";
export const ModuleListScreen = () => {
const ModuleListScreen = () => {
// Initialisation -------------
const modules = initialModules;
// let modules = initialModules;
// State ----------------------
const [ modules, setModules] = useState(initialModules);
// Handlers -------------------
const handleSelect = (module) => alert(`Item ${module.ModuleName} selected`);
const handleDelete = (module) =>
setModules(modules.filter((item) => item.ModuleID !== module.ModuleID));
// View -----------------------
return (
<Screen>
<ModuleList modules={{modules}} onSelect={handleSelect} />
<ModuleList modules={modules} onSelect={handleDelete} />
</Screen>
);
};