Skip to content

Commit

Permalink
Removed url and discovery fields from add/edit property
Browse files Browse the repository at this point in the history
  • Loading branch information
azdak committed Dec 20, 2024
1 parent cda5334 commit 624d027
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
14 changes: 7 additions & 7 deletions src/components/forms/property-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { useSubmit } from 'react-router-dom';

const PropertySchema = z.object({
propertyName: z.string().min(1, 'Please enter a Property name.'),
propertyUrl: z.string().url('Please enter a valid URL.'),
propertyDiscovery: z.enum(['single', 'sitemap', 'discovery_process']),
//propertyUrl: z.string().url('Please enter a valid URL.'),
//propertyDiscovery: z.enum(['single', 'sitemap', 'discovery_process']),
});

type PropertyFormInputs = z.infer<typeof PropertySchema>;
Expand Down Expand Up @@ -78,7 +78,7 @@ const PropertyForm: React.FC<PropertyFormProps> = ({
</FormItem>
)}
/>
<FormField
{/* <FormField
control={form.control}
name="propertyUrl"
render={({ field }) => (
Expand All @@ -99,8 +99,8 @@ const PropertyForm: React.FC<PropertyFormProps> = ({
<FormMessage />
</FormItem>
)}
/>
<FormField
/> */}
{/* <FormField
control={form.control}
name="propertyDiscovery"
render={({ field }) => (
Expand All @@ -123,8 +123,8 @@ const PropertyForm: React.FC<PropertyFormProps> = ({
</FormControl>
<FormMessage />
</FormItem>
)}
/>
)}
/>*/}
</form>
</HookFormProvider>
);
Expand Down
11 changes: 4 additions & 7 deletions src/routes/protected/properties/add-property.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,10 @@ const AddProperty = () => {
const propertyName = form?.elements.namedItem(
'propertyName',
) as HTMLInputElement;
const propertyUrl = form?.elements.namedItem(
'propertyUrl',
) as HTMLInputElement;

if (propertyName && propertyUrl) {
if (propertyName) {
const isFormValid =
propertyName.value.trim() !== '' && propertyUrl.value.trim() !== '';
propertyName.value.trim() !== '';
setIsFormValid(isFormValid);
}
};
Expand All @@ -86,8 +83,8 @@ const AddProperty = () => {
actionUrl="/properties/add"
defaultValues={{
propertyName: '',
propertyUrl: '',
propertyDiscovery: 'single',
//propertyUrl: '',
//propertyDiscovery: 'single',
}}
formId="add-property-form"
onChange={handleFormChange}
Expand Down
10 changes: 5 additions & 5 deletions src/routes/protected/properties/edit-property.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,16 @@ const EditProperty = () => {
const { name, value } = event.target;
if (name === 'propertyName' && value.trim() !== property?.name.trim()) {
setIsFormChanged(true);
} else if (
} /* else if (
name === 'propertyUrl' &&
value.trim() !== property?.propertyUrl.trim()
) {
setIsFormChanged(true);
} else if (name === 'propertyDiscovery' && value !== property?.discovery) {
setIsFormChanged(true);
} else {
}*/ else {
setIsFormChanged(false);
}
}
};

const handleDeleteProperty = async () => {
Expand Down Expand Up @@ -360,8 +360,8 @@ const EditProperty = () => {
actionUrl={`/properties/${propertyId}/edit`}
defaultValues={{
propertyName: property?.name || '',
propertyUrl: property?.propertyUrl || '',
propertyDiscovery: property?.discovery || 'single',
//propertyUrl: property?.propertyUrl || '',
//propertyDiscovery: property?.discovery || 'single',
}}
formId="edit-property-form"
onChange={handleFormChange}
Expand Down

0 comments on commit 624d027

Please sign in to comment.