Record of discriminated union

Issue Taken this structured messages: type MessageVariant<T extends string, P = {}> = { type: T; payload: P; }; type BoundsChangedMessage = MessageVariant< "bounds_changed", { bounds: number[][]; } >; type ChangeLayoutMessage = MessageVariant< "change_layout", { name: string; } >; type

Continue reading

Svelte dynamic multiple component array

Issue EDIT: REPL for answer https://svelte.dev/repl/eb7616fd162a4829b14a778c3d1627e4?version=3.48.0 What I’m talking would render this: First we have a button: <button on:click={add}> Add </button> <div id="columnflexbox"> When I click it, this should happen: <button on:click={add}> Add </button> <!– This exists in DOM–> <div

Continue reading

How to convert token JWT to object in reactjs

Issue I have reactjs project, when i login i save my token to localstorage, how can i convert token JWT to object and get id_user? Thank you guys eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NCwiZW1haWwiOiJhZG1pbkBnbWFpbC5jb20iLCJhdXRob3JpemF0aW9uIjoib3duZXIiLCJpYXQiOjE2NTQ5NDkxMjksImV4cCI6MTY1NDk1MjcyOX0.5e-KzJ0Rv3iWmY5MFtEGjRXZBJNlddiZ97X8pHJD03g Decoded Solution You can also use basic JavaScript to decode it:

Continue reading

How to merge two list of objects in a new one by date

Issue I have a list of dates: const dates = [ ‘2022-04-10T00:00:00.000Z’, ‘2022-04-11T00:00:00.000Z’, ‘2022-04-12T00:00:00.000Z’, ‘2022-04-13T00:00:00.000Z’, ‘2022-04-14T00:00:00.000Z’, ‘2022-04-15T00:00:00.000Z’, ‘2022-04-16T00:00:00.000Z’, ‘2022-04-17T00:00:00.000Z’ ] and I have a list of workouts: const workouts = [ { "id": "221bf3b1-2728-41f7-a10e-d004fdd1d0b6", "title": "ONE MORE TIME", "description": "Complete

Continue reading