3forges / poc-preact-rtk-flowbite

0 stars 1 forks source link

usage de redux toolkit query #7

Open Jean-Baptiste-Lasselle opened 1 year ago

Jean-Baptiste-Lasselle commented 1 year ago

modifier l'application pour quelle ait un nouveau slice "notifications", qui fasse usage de rtk query

https://wanago.io/2021/12/27/redux-toolkit-query-typescript/

Jean-Baptiste-Lasselle commented 1 year ago

ok on a mergé une première PR, @BorisTherin , maintenant, il faut voir comment créer/update / delete des projets :

  endpoints: build => ({
    createProject: build.query<PestoProjectApiEntity[], void>({
      query() {
        return {
          url: "pesto-project",
          params: {
            limit: 10
          },
          method: 'POST',
          body: {
            name: "exemple",
            git_ssh_uri: "git@github.com:ouais/exemple",
            description: "exemple",
          }
        }
      }
    }),
Jean-Baptiste-Lasselle commented 1 year ago

pour terminer, deux excellents articles pour voir comment faire UPDATE DELETE CREATE avec mutation :

Jean-Baptiste-Lasselle commented 1 year ago

ok, j'y suis presque pour faire un update avec rtk query , voilà les tests curl sur l'api pour comparer à l'effet du front end:


export EG_PAYLOAD='{
    "_id": "6526bb5cf88cd05417311b33",
    "name": "autrement8945",
    "git_ssh_uri": "git@github.com:fundefinedjskh/rqfxy",
    "description": "msrnjusm juykm yloyrjjli",
    "createdAt": "2023-10-11T15:12:28.604Z"
}'
export PRJ_ID="6526bb5cf88cd05417311b33"
curl -iv \
  -X PUT \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d "${EG_PAYLOAD}" \
  http://localhost:3000/pesto-project/${PRJ_ID} | tail -n 1 | jq .

curl -iv   -X GET   -H 'Content-Type: application/json'   -H 'Accept: application/json' http://localhost:3000/pesto-project/${PRJ_ID} | tail -n 1 | jq .

export EG_PAYLOAD='
    "_id": "6526bb5cf88cd05417311b33",
    "name": "autrement44544",
    "git_ssh_uri": "git@github.com:fundefinedjskh/rqfxy",
    "description": "msrnjusm juykm yloyrjjli",
    "createdAt": "2023-10-11T15:12:28.604Z"
}'
export PRJ_ID="6526bb5cf88cd05417311b33"
curl -iv \
  -X PUT \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d "${EG_PAYLOAD}" \
  http://localhost:3000/pesto-project/${PRJ_ID} | tail -n 1 | jq .

curl -iv   -X GET   -H 'Content-Type: application/json'   -H 'Accept: application/json' http://localhost:3000/pesto-project/${PRJ_ID} | tail -n 1 | jq .