Refactor sound context and update sound settings functionality; remove console logs and improve sound file handling
This commit is contained in:
@@ -12,20 +12,10 @@ const SoundSettingsFields = () => {
|
||||
{ name: "hotlist2", sound: "" },
|
||||
];
|
||||
|
||||
const soundOptions = [
|
||||
{
|
||||
value: "switch",
|
||||
label: "Switch (Default)",
|
||||
},
|
||||
{
|
||||
value: "notification",
|
||||
label: "Notification",
|
||||
},
|
||||
{
|
||||
value: "popup",
|
||||
label: "popup",
|
||||
},
|
||||
];
|
||||
const soundOptions = state?.soundOptions?.map((soundOption) => ({
|
||||
value: soundOption?.name,
|
||||
label: soundOption?.name,
|
||||
}));
|
||||
|
||||
const initialValues: FormValues = {
|
||||
sightingSound: state.sightingSound ?? "switch",
|
||||
@@ -37,7 +27,6 @@ const SoundSettingsFields = () => {
|
||||
dispatch({ type: "UPDATE", payload: values });
|
||||
toast.success("Sound settings updated");
|
||||
};
|
||||
console.log(state);
|
||||
return (
|
||||
<Formik initialValues={initialValues} onSubmit={handleSubmit}>
|
||||
{({ values }) => (
|
||||
@@ -49,7 +38,7 @@ const SoundSettingsFields = () => {
|
||||
name="sightingSound"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full md:w-60"
|
||||
>
|
||||
{soundOptions.map(({ value, label }) => {
|
||||
{soundOptions?.map(({ value, label }) => {
|
||||
return (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
@@ -65,7 +54,7 @@ const SoundSettingsFields = () => {
|
||||
name="NPEDsound"
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full md:w-60"
|
||||
>
|
||||
{soundOptions.map(({ value, label }) => (
|
||||
{soundOptions?.map(({ value, label }) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
@@ -97,7 +86,7 @@ const SoundSettingsFields = () => {
|
||||
id={`hotlists.${index}.sound`}
|
||||
className="p-2 border border-gray-400 rounded-lg text-white bg-[#253445] w-full md:w-60"
|
||||
>
|
||||
{soundOptions.map(({ value, label }) => (
|
||||
{soundOptions?.map(({ value, label }) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
|
||||
Reference in New Issue
Block a user