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,
|
||||
};
|
||||
|
||||
const ModuleForm = ({onSubmit, onCancel}) => {
|
||||
const ModuleForm = ({originalModule, onSubmit, onCancel}) => {
|
||||
|
||||
// Initialisation -------------
|
||||
|
||||
@@ -31,7 +31,7 @@ const ModuleForm = ({onSubmit, onCancel}) => {
|
||||
|
||||
// State ----------------------
|
||||
|
||||
const [module, setModule] = useState(defaultModule);
|
||||
const [module, setModule] = useState(originalModule || defaultModule);
|
||||
|
||||
// Handlers -------------------
|
||||
|
||||
@@ -44,8 +44,8 @@ const ModuleForm = ({onSubmit, onCancel}) => {
|
||||
|
||||
// View -----------------------
|
||||
|
||||
const submitLabel = 'Add';
|
||||
const submitIcon = <Icons.Add/>;
|
||||
const submitLabel = originalModule ? 'Modify' : 'Add';
|
||||
const submitIcon = originalModule ? <Icons.Edit/> : <Icons.Add/>;
|
||||
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
import {StyleSheet, Text} from "react-native";
|
||||
import Screen from "../layout/Screen";
|
||||
import ModuleForm from "../entity/modules/moduleForm";
|
||||
|
||||
export const ModuleModifyScreen = () => {
|
||||
export const ModuleModifyScreen = ({navigation, route}) => {
|
||||
// Initialisation -------------
|
||||
const {module, onModify} = route.params;
|
||||
|
||||
// State ----------------------
|
||||
// Handlers -------------------
|
||||
|
||||
const handleCancel = () => navigation.navigate.goBack();
|
||||
|
||||
// View -----------------------
|
||||
return (
|
||||
<Screen style={styles.container}>
|
||||
<Text>Modify</Text>
|
||||
<ModuleForm
|
||||
originalModule={module}
|
||||
onSubmit={onModify}
|
||||
onCancel={handleCancel}
|
||||
/>
|
||||
</Screen>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ export const ModuleViewScreen = ({navigation, route}) => {
|
||||
// State ----------------------
|
||||
// Handlers -------------------
|
||||
|
||||
const goToModifyScreen = () => navigation.navigate("ModuleModifyScreen");
|
||||
const goToModifyScreen = () => navigation.navigate("ModuleModifyScreen", { module, onModify });
|
||||
|
||||
// View -----------------------
|
||||
return (<Screen>
|
||||
|
||||
Reference in new issue
Block a user