Is there a solution for this issue? I am currently developing a switch button for a configuration page. The problem arises when I toggle the switch from active to maintenance mode, save it successfully, but upon refreshing the page, the switch reverts back to active status.
[Before refresh][1] [1]: https://i.sstatic.net/eDYQp.png
If you observe the image before refreshing and after refreshing the page, you will notice that the status changes back to active. How can I ensure that the changed status is retained even after page refresh in next js?
Here's the updated code snippet:
import React, { useEffect, useState } from 'react'
import { useRouter } from 'next/router'
import { WebConfigurationType, WebConfigType } from '@/type/web'
import { getData, postData, putData } from '@/utility/fetch'
import { showMessage } from '@/components/alerts/showMessage';
...
I have associated this with a JSON schema as follows:
{ "id": "d9cbf36e-bb51-11ee-a740-00155db75f50", "name": "Beranda", "code": "home", "position": 1, "is_maintenance": false }