mirror of
https://github.com/mudabbir-ahmad/Project-MAD-crudler.git
synced 2026-10-07 20:40:20 +00:00
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:
1 parent
0439b7ab33
commit
54e73d32e0
3 files changed
+21
-15
No files matched your search
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user