diff options
author | Ivan Chen <ivan@thetaggid.com> | 2021-01-13 02:59:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-13 02:59:52 -0500 |
commit | 06cea95ec9463f1c010187973f401a68cce7b68d (patch) | |
tree | 290bc590b6a002f83888bad3bbe9da2a48074e30 /src/utils/common.ts | |
parent | 353c1ec685698bb86e0ff96a346d88205ee389cf (diff) |
[TMA-556] Temporary Fix for Re-ordering Categories (#178)
* done
* moved icon placement and added correct asset
* new icons
* moved things around resolved a bug
* Deleting existing predefined moment categories
* Revert "Deleting existing predefined moment categories"
This reverts commit f5f4464b5392902208ec548de1c189f4639261a5.
* Hit backend
Co-authored-by: Shravya Ramesh <shravs1208@gmail.com>
Co-authored-by: Ashm Walia <ashmwalia@outlook.com>
Co-authored-by: Ashm Walia <40498934+ashmgarv@users.noreply.github.com>
Diffstat (limited to 'src/utils/common.ts')
-rw-r--r-- | src/utils/common.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils/common.ts b/src/utils/common.ts index f13181c1..dbe8f270 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -48,6 +48,22 @@ export const getDateAge: ( } }; +export const moveCategory: ( + categories: string[], + category: string, + moveUp: boolean, +) => string[] = (categories, category, moveUp) => { + const i = categories.indexOf(category); + const swapTarget = moveUp ? i - 1 : i + 1; + if ((moveUp && i === 0) || (!moveUp && i > categories.length)) { + return categories; + } + const tmp = categories[i]; + categories[i] = categories[swapTarget]; + categories[swapTarget] = tmp; + return categories; +}; + export const checkImageUploadStatus = (statusMap: object) => { for (let [key, value] of Object.entries(statusMap)) { if (value != 'Success') { |