mirror of
https://github.com/mudabbir-ahmad/Project-MAD-crudler.git
synced 2026-10-07 20:40:20 +00:00
Added modify functionality.
This commit is contained in:
1 parent
1f76cd8015
commit
924b57186f
3 files changed
+17
-7
No files matched your search
@@ -13,7 +13,7 @@ const defaultModule = {
|
|||||||
ModuleImage: null,
|
ModuleImage: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const ModuleForm = ({onSubmit, onCancel}) => {
|
const ModuleForm = ({originalModule, onSubmit, onCancel}) => {
|
||||||
|
|
||||||
// Initialisation -------------
|
// Initialisation -------------
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ const ModuleForm = ({onSubmit, onCancel}) => {
|
|||||||
|
|
||||||
// State ----------------------
|
// State ----------------------
|
||||||
|
|
||||||
const [module, setModule] = useState(defaultModule);
|
const [module, setModule] = useState(originalModule || defaultModule);
|
||||||
|
|
||||||
// Handlers -------------------
|
// Handlers -------------------
|
||||||
|
|
||||||
@@ -44,8 +44,8 @@ const ModuleForm = ({onSubmit, onCancel}) => {
|
|||||||
|
|
||||||
// View -----------------------
|
// View -----------------------
|
||||||
|
|
||||||
const submitLabel = 'Add';
|
const submitLabel = originalModule ? 'Modify' : 'Add';
|
||||||
const submitIcon = <Icons.Add/>;
|
const submitIcon = originalModule ? <Icons.Edit/> : <Icons.Add/>;
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,14 +1,24 @@
|
|||||||
import {StyleSheet, Text} from "react-native";
|
import {StyleSheet, Text} from "react-native";
|
||||||
import Screen from "../layout/Screen";
|
import Screen from "../layout/Screen";
|
||||||
|
import ModuleForm from "../entity/modules/moduleForm";
|
||||||
|
|
||||||
export const ModuleModifyScreen = () => {
|
export const ModuleModifyScreen = ({navigation, route}) => {
|
||||||
// Initialisation -------------
|
// Initialisation -------------
|
||||||
|
const {module, onModify} = route.params;
|
||||||
|
|
||||||
// State ----------------------
|
// State ----------------------
|
||||||
// Handlers -------------------
|
// Handlers -------------------
|
||||||
|
|
||||||
|
const handleCancel = () => navigation.navigate.goBack();
|
||||||
|
|
||||||
// View -----------------------
|
// View -----------------------
|
||||||
return (
|
return (
|
||||||
<Screen style={styles.container}>
|
<Screen style={styles.container}>
|
||||||
<Text>Modify</Text>
|
<ModuleForm
|
||||||
|
originalModule={module}
|
||||||
|
onSubmit={onModify}
|
||||||
|
onCancel={handleCancel}
|
||||||
|
/>
|
||||||
</Screen>
|
</Screen>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const ModuleViewScreen = ({navigation, route}) => {
|
|||||||
// State ----------------------
|
// State ----------------------
|
||||||
// Handlers -------------------
|
// Handlers -------------------
|
||||||
|
|
||||||
const goToModifyScreen = () => navigation.navigate("ModuleModifyScreen");
|
const goToModifyScreen = () => navigation.navigate("ModuleModifyScreen", { module, onModify });
|
||||||
|
|
||||||
// View -----------------------
|
// View -----------------------
|
||||||
return (<Screen>
|
return (<Screen>
|
||||||
|
|||||||
Reference in new issue
Block a user