diff --git a/packages/app/modules/item/components/AddItem.tsx b/packages/app/modules/item/components/AddItem.tsx
index b79883668..1fff1a7da 100644
--- a/packages/app/modules/item/components/AddItem.tsx
+++ b/packages/app/modules/item/components/AddItem.tsx
@@ -102,6 +102,7 @@ export const AddItem = ({
}
showTrigger={showTrigger}
- footerButtons={[
- {
- label: 'Cancel',
- color: '#B22222',
- onClick: (_, closeModal) => closeModal(),
- },
- ]}
footerComponent={undefined}
isOpen={isAddItemModalOpen}
onOpen={() => setIsAddItemModalOpen(true)}
diff --git a/packages/app/modules/item/components/ImportForm.tsx b/packages/app/modules/item/components/ImportForm.tsx
index 330f9a2f6..6f57dbafd 100644
--- a/packages/app/modules/item/components/ImportForm.tsx
+++ b/packages/app/modules/item/components/ImportForm.tsx
@@ -6,6 +6,7 @@ import * as DocumentPicker from 'expo-document-picker';
import { useImportItem, useImportFromBucket } from '../hooks';
import { useImportPackItem } from '../../pack/hooks';
import useResponsive from 'app/hooks/useResponsive';
+import RPrimaryButton from 'app/components/RPrimaryButton';
interface ImportFormProps {
showSubmitButton?: boolean;
@@ -183,9 +184,11 @@ export const ImportForm: FC = ({
style={{ width: '100%' }}
/>
-
- {buttonText}
-
+
);
};
diff --git a/packages/app/modules/item/components/ItemForm.tsx b/packages/app/modules/item/components/ItemForm.tsx
index 8ea587144..488ddeb3b 100644
--- a/packages/app/modules/item/components/ItemForm.tsx
+++ b/packages/app/modules/item/components/ItemForm.tsx
@@ -8,6 +8,8 @@ import {
FormSelect,
FormRadioGroup,
DropdownComponent,
+ RButton,
+ XStack,
} from '@packrat/ui';
import { Platform, View } from 'react-native';
@@ -28,6 +30,7 @@ interface ItemFormProps {
isEdit?: boolean;
defaultValues: Partial- ;
validationSchema: any;
+ closeModalHandler?: () => void;
currentPack?: {
items: Array<{
category: {
@@ -39,6 +42,7 @@ interface ItemFormProps {
export const ItemForm = ({
handleSubmit,
+ closeModalHandler,
showSubmitButton = true,
isLoading,
isEdit,
@@ -123,14 +127,24 @@ export const ItemForm = ({
style={{ width: '100%' }}
/>
-
- {showSubmitButton && (
-
-
- {isLoading ? 'Loading..' : isEdit ? 'Edit item' : 'Add Item'}
-
-
- )}
+
+ {showSubmitButton && (
+
+
+ {isLoading ? 'Loading..' : isEdit ? 'Edit item' : 'Add Item'}
+
+
+ )}
+ {closeModalHandler && (
+
+ Cancel
+
+ )}
+
diff --git a/packages/app/modules/pack/components/EditPackModal.tsx b/packages/app/modules/pack/components/EditPackModal.tsx
index 9a58d5cee..cfbd17f63 100644
--- a/packages/app/modules/pack/components/EditPackModal.tsx
+++ b/packages/app/modules/pack/components/EditPackModal.tsx
@@ -1,12 +1,10 @@
import React, { useEffect, useState } from 'react';
import { BaseModal } from '../../../../ui/src/modal/BaseModal';
-import RButton from '@packrat/ui/src/RButton';
-import RInput from '@packrat/ui/src/RInput';
import { useEditPack } from '../hooks/useEditPack';
import RStack from '@packrat/ui/src/RStack';
import RText from '@packrat/ui/src/RText';
-import { Switch } from 'tamagui';
-import RSwitch from '@packrat/ui/src/RSwitch';
+import { Form, FormInput, FormSwitch, useFormSubmitTrigger } from '@packrat/ui';
+import { editPack as editPackSchema } from '@packrat/validations';
interface EditPackModalProps {
isOpen?: boolean;
@@ -23,14 +21,16 @@ export const EditPackModal: React.FC = ({
}) => {
const [packName, setPackName] = useState(currentPack?.name ?? '');
const [isPublic, setIsPublic] = useState(currentPack?.is_public ?? true);
+ const [formRef, triggerSubmit] = useFormSubmitTrigger();
const { editPack, isLoading, isError } = useEditPack();
- const handleEditPack = async () => {
+ const handleEditPack = async (closeModal, { name: packName, is_public }) => {
try {
editPack(
- { id: currentPack.id, name: packName, is_public: isPublic },
+ { id: currentPack.id, name: packName, is_public },
{
onSuccess: () => {
+ closeModal();
onClose?.();
refetch?.();
},
@@ -53,6 +53,15 @@ export const EditPackModal: React.FC = ({
showTrigger={false}
title="Edit Pack"
footerButtons={[
+ {
+ label: 'Save',
+ color: '#232323',
+ onClick: (_, closeModal) => {
+ if (typeof triggerSubmit === 'function') {
+ triggerSubmit(closeModal);
+ }
+ },
+ },
{
label: 'Cancel',
color: '#B22222',
@@ -65,31 +74,21 @@ export const EditPackModal: React.FC = ({
isOpen={isOpen}
onClose={onClose}
>
- setPackName(t)}
- style={{ width: 200 }}
- />
-
- Public
- setIsPublic((prev) => !prev)}
- size="$1.5"
+
+
+
+
+
-
- {isLoading ? 'Saving...' : 'Save'}
-
{isError && (
Failed to save changes
diff --git a/packages/ui/src/form/components/Form.tsx b/packages/ui/src/form/components/Form.tsx
index 73480cd09..780bdd925 100644
--- a/packages/ui/src/form/components/Form.tsx
+++ b/packages/ui/src/form/components/Form.tsx
@@ -12,7 +12,7 @@ export { useFormContext as useAppFormContext } from 'react-hook-form';
interface Props extends Omit {
validationSchema?: any;
formRef?: any;
- onSubmit?: FormSubmitHandler;
+ onSubmit?: any;
children: ReactNode;
}
@@ -23,17 +23,13 @@ export const Form = forwardRef(
resolver: validationSchema ? zodResolver(validationSchema) : undefined,
});
- useImperativeHandle(
- ref,
- () => {
- return {
- submit: (...params) =>
- typeof onSubmit === 'function' &&
- form.handleSubmit(onSubmit.bind(null, ...params))(),
- };
- },
- [form, onSubmit],
- );
+ useImperativeHandle(ref, () => {
+ return {
+ submit: (...params) =>
+ typeof onSubmit === 'function' &&
+ form.handleSubmit(onSubmit.bind(null, ...params))(),
+ };
+ }, [form, onSubmit]);
return (
diff --git a/packages/ui/src/form/components/FormSwitch.tsx b/packages/ui/src/form/components/FormSwitch.tsx
index 68c2b3e9a..745c679a5 100644
--- a/packages/ui/src/form/components/FormSwitch.tsx
+++ b/packages/ui/src/form/components/FormSwitch.tsx
@@ -3,8 +3,12 @@ import type { StyleProp, ViewStyle } from 'react-native';
export { LmSwitch as Switch } from '../lib';
interface Props
- extends LmSwitchRhfProps<{ label: string | number; value: any }> {
+ extends Omit<
+ LmSwitchRhfProps<{ label: string | number; value: any }>,
+ 'name'
+ > {
style?: StyleProp;
+ name: string;
}
// TODO change the name to "Input" after handling tamagui all components export,
diff --git a/packages/ui/src/form/components/SubmitButton.tsx b/packages/ui/src/form/components/SubmitButton.tsx
index 8f46ee8fa..3b560430e 100644
--- a/packages/ui/src/form/components/SubmitButton.tsx
+++ b/packages/ui/src/form/components/SubmitButton.tsx
@@ -12,11 +12,10 @@ export const SubmitButton = ({
return (
({
}}
disabledStyle={{ opacity: 0.6 }}
style={{
+ color: '#fff',
...safeStyle,
}}
{...props}
diff --git a/packages/ui/src/modal/BaseModal.tsx b/packages/ui/src/modal/BaseModal.tsx
index c8f3ed375..c56bc9f6f 100644
--- a/packages/ui/src/modal/BaseModal.tsx
+++ b/packages/ui/src/modal/BaseModal.tsx
@@ -139,12 +139,14 @@ export const BaseModal = ({
{children}
-
- {memoFooterButtons}
-
+ {!!memoFooterButtons?.length && (
+
+ {memoFooterButtons}
+
+ )}
{footerElement}