feat(topics) - add list topic

This commit is contained in:
2026-02-06 15:32:46 +07:00
parent 2ce6a4ab8c
commit 2172614789
15 changed files with 188 additions and 86 deletions

View File

@@ -11,17 +11,15 @@ export default function SettingsFeature() {
tower: "",
floor: "",
unit: "",
credential: "",
});
const [loading, setLoading] = useState<boolean>(false);
function isObjectValueDifferent(
a: MerchantForm,
b: MerchantForm
): boolean {
return (Object.keys(a) as (keyof MerchantForm)[]).some(
(key) => a[key] !== b[key]
);
}
function isObjectValueDifferent(a: MerchantForm, b: MerchantForm): boolean {
return (Object.keys(a) as (keyof MerchantForm)[]).some(
(key) => a[key] !== b[key],
);
}
function handleChange(e: React.ChangeEvent<HTMLInputElement>) {
const { name, value } = e.target;
@@ -31,29 +29,26 @@ function isObjectValueDifferent(
}));
}
function handleSubmit(e: React.FormEvent) {
e.preventDefault();
function handleSubmit(e: React.FormEvent) {
e.preventDefault();
const merchant = getMerchant();
const merchant = getMerchant();
if(merchant){
const isDifferent = isObjectValueDifferent(merchant, form);
if (isDifferent) {
clearDevice(); // reset device kalau merchant berubah
if (merchant) {
const isDifferent = isObjectValueDifferent(merchant, form);
if (isDifferent) {
clearDevice(); // reset device kalau merchant berubah
}
}
setLoading(true);
saveMerchant(form);
setTimeout(() => {
setLoading(false);
navigate({ to: "/" });
}, 200);
}
setLoading(true);
saveMerchant(form);
setTimeout(() => {
setLoading(false);
navigate({ to: "/" });
}, 200);
}
useEffect(() => {
const merchant = getMerchant();
@@ -119,6 +114,18 @@ function handleSubmit(e: React.FormEvent) {
className="p-2 border border-neutral-200 w-full rounded-md"
/>
</div>
<div>
<label className="mb-1 text-neutral-900 block font-semibold">
Credential
</label>
<input
name="credential"
value={form.credential}
onChange={handleChange}
className="p-2 border border-neutral-200 w-full rounded-md"
/>
</div>
</div>
</div>