@homefile/components-v2 2.8.28 → 2.8.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,11 @@
1
- import { ChangeEvent } from "react";
1
+ import { ChangeEvent } from 'react';
2
2
  import { RoomItemI } from '../../interfaces';
3
- interface useRoomHeaderI {
3
+ interface UseRoomHeaderI {
4
4
  onSubmit: (room: RoomItemI) => void;
5
5
  room: RoomItemI;
6
6
  roomAmount: string;
7
7
  }
8
- export declare const useRoomHeader: ({ onSubmit, room: { _id, name, type, active, home }, roomAmount, }: useRoomHeaderI) => {
8
+ export declare const useRoomHeader: ({ onSubmit, room: { _id, name, type, active, home }, roomAmount, }: UseRoomHeaderI) => {
9
9
  formattedAmount: string;
10
10
  handleChange: (e: ChangeEvent<HTMLInputElement>) => void;
11
11
  handleClick: () => void;
@@ -1,5 +1,5 @@
1
- import { useState, useEffect } from "react";
2
- import { formatCurrency } from "../../utils";
1
+ import { useState, useEffect } from 'react';
2
+ import { formatCurrency } from '../../utils';
3
3
  export const useRoomHeader = ({ onSubmit, room: { _id, name, type, active, home }, roomAmount, }) => {
4
4
  const [isEditing, setIsEditing] = useState(false);
5
5
  const [inputValue, setInputValue] = useState(null);
@@ -8,12 +8,11 @@ export const useRoomHeader = ({ onSubmit, room: { _id, name, type, active, home
8
8
  setInputValue(name);
9
9
  }, [name]);
10
10
  const handleClick = () => {
11
- setIsEditing((editing) => {
12
- editing = !editing;
11
+ if (isEditing) {
13
12
  const roomRest = { active, home, _id, type };
14
- !editing && onSubmit(Object.assign({ name: inputValue || name }, roomRest));
15
- return editing;
16
- });
13
+ onSubmit(Object.assign({ name: inputValue !== null && inputValue !== void 0 ? inputValue : name }, roomRest));
14
+ }
15
+ setIsEditing(!isEditing);
17
16
  };
18
17
  const handleChange = (e) => {
19
18
  setInputValue(e.target.value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homefile/components-v2",
3
- "version": "2.8.28",
3
+ "version": "2.8.29",
4
4
  "author": "Homefile",
5
5
  "license": "UNLICENSED",
6
6
  "typings": "dist/index.d.ts",
@@ -1,8 +1,8 @@
1
- import { useState, useEffect, ChangeEvent } from "react"
2
- import { formatCurrency } from "@/utils"
1
+ import { useState, useEffect, ChangeEvent } from 'react'
2
+ import { formatCurrency } from '@/utils'
3
3
  import { RoomItemI } from '@/interfaces'
4
4
 
5
- interface useRoomHeaderI {
5
+ interface UseRoomHeaderI {
6
6
  onSubmit: (room: RoomItemI) => void
7
7
  room: RoomItemI
8
8
  roomAmount: string
@@ -12,7 +12,7 @@ export const useRoomHeader = ({
12
12
  onSubmit,
13
13
  room: { _id, name, type, active, home },
14
14
  roomAmount,
15
- }: useRoomHeaderI) => {
15
+ }: UseRoomHeaderI) => {
16
16
  const [isEditing, setIsEditing] = useState(false)
17
17
  const [inputValue, setInputValue] = useState<string | null>(null)
18
18
 
@@ -23,12 +23,11 @@ export const useRoomHeader = ({
23
23
  }, [name])
24
24
 
25
25
  const handleClick = () => {
26
- setIsEditing((editing) => {
27
- editing = !editing
26
+ if (isEditing) {
28
27
  const roomRest = { active, home, _id, type }
29
- !editing && onSubmit({ name: inputValue || name, ...roomRest })
30
- return editing
31
- })
28
+ onSubmit({ name: inputValue ?? name, ...roomRest })
29
+ }
30
+ setIsEditing(!isEditing)
32
31
  }
33
32
 
34
33
  const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
@@ -41,4 +40,4 @@ export const useRoomHeader = ({
41
40
  inputValue,
42
41
  isEditing,
43
42
  }
44
- }
43
+ }