const fieldType = {
  "[object Object]": {},
  "[object Array]": [],
  "[object Number]": "",
  "[object String]": "",
  "[object Boolean]": false,
};

const useReset = <T extends Record<string, any>>(fields: T): T => {
  const typeString = Object.prototype.toString;

  Object.keys(fields).forEach((field) => {
    const type = typeString.call(fields[field] as T[keyof T]);
    (fields[field] as T[keyof T]) = (<Record<string, any>>fieldType)[type];
  });

  return fields as T;
};

export default useReset;
