import React from 'react' ; import { IDesktopApp } from '../../types/ui/desktop-app' ; import Figma from '../Apps/Figma/Figma' ; import VsCode from '../Apps/VsCode/VsCode' ; import Likes from '../Likes/Likes' ; import { useRouter } from 'next/router' ; import Resume from '../Portfolio/Resume/Resume' ; import TrashBin from '../Folders/TrashBin/TrashBin' ; import CommentsForm from '../CommentsForm/CommentsForm' ; import PortfolioLanding from '../Portfolio/PortfolioLanding/PortfolioLanding' ; import PortfolioLayout from '../Portfolio/PortfolioLayout/PortfolioLayout' ; import { useTypedSelector } from '../../hooks/useTypedSelector' ; import Acknowledgments from '../Acknowledgments/Acknowledgments' ; import CommentsList from '../CommentsList/CommentsList' ; function returns { object } export const useDesktopApps = ( ) : { sortedAlphabetically : IDesktopApp [ ] ; sortedByDate : IDesktopApp [ ] ; sortedBySize : IDesktopApp [ ] ; appsInTrashBin : IDesktopApp [ ] ; } => { const router = useRouter ( ) ; const { removedApps , compressedApps } = useTypedSelector ( ( state ) => state . ui ) ; const initialDesktopAppsList = [ { id : 1 , text : 'Figma' , willOpenWindowWith : < Figma />, variant : 'desktop' , iconSrc : '/assets/icons/startmenu/figma.png' , iconSize : { width : 40 , height : 40 } , action : null , } , { id : 2 , text : 'VSCode' , willOpenWindowWith : < VsCode />, variant : 'desktop' , iconSrc : '/assets/icons/startmenu/vscode.svg' , iconSize : { width : 40 , height : 40 } , action : null , } , { id : 3 , text : 'Vova ✨' , willOpenWindowWith : ( < PortfolioLayout title = { 'Vova Ushenko | Full-Stack Web Developer' } > < PortfolioLanding /> < /PortfolioLayout>), variant : 'desktop' , iconSrc : '/assets/icons/Desktop/user-folder.png' , iconSize : { width : 40 , height : 40 } , action : null , } , { id : 4 , text : 'Likes' , willOpenWindowWith : < Likes />, variant : 'desktop' , iconSrc : '/assets/icons/Desktop/like.png' , iconSize : { width : 40 , height : 40 } , action : null , } , { id : 5 , text : 'Portfolio' , willOpenWindowWith : null , variant : 'desktop' , iconSrc : '/assets/portfolio/skills/react-original.svg' , iconSize : { width : 40 , height : 40 } , action : ( ) => router . push ( '/portfolio' ) , } , { id : 6 , text : 'Resume' , willOpenWindowWith : < Resume />, variant : 'desktop' , iconSrc : '/assets/icons/recommended/word.png' , iconSize : { width : 40 , height : 40 } , action : null , } , { id : 7 , text : 'Projects' , willOpenWindowWith : null , variant : 'desktop' , iconSrc : '/assets/icons/recommended/power-point.png' , iconSize : { width : 40 , height : 40 } , action : ( ) => router . push ( '/portfolio/projects' ) , } , { id : 8 , text : 'Trash' , willOpenWindowWith : < TrashBin />, variant : 'desktop' , iconSrc : removedApps . length > 0 ? '/assets/icons/Desktop/recycle-bin-full.png' : '/assets/icons/Desktop/recycle-bin-empty.png' , iconSize : { width : 42 , height : 42 } , action : null , } , { id : 9 , text : 'Comment' , willOpenWindowWith : < CommentsForm />, variant : 'desktop' , iconSrc : '/assets/icons/Desktop/comment.png' , iconSize : { width : 40 , height : 40 } , action : null , } , { id : 10 , text : 'Acknowledgments' , willOpenWindowWith : < Acknowledgments />, variant : 'desktop' , iconSrc : '/assets/icons/Desktop/acknowledgment.png' , iconSize : { width : 40 , height : 40 } , action : null , } , { id : 11 , text : 'Comments' , willOpenWindowWith : < CommentsList />, variant : 'desktop' , iconSrc : '/assets/icons/Desktop/comments.png' , iconSize : { width : 40 , height : 40 } , action : null , } , ] ; const compressedAppsList = [ ... initialDesktopAppsList ] . filter ( ( app ) => compressedApps . includes ( app . text ) ) . map ( ( compressedApp ) => ( { ... compressedApp , text : compressedApp . text + '.zip' , iconSrc : '/assets/icons/Desktop/zip.png' , willOpenWindowWith : null , action : null , id : compressedApp . id + 777 , } ) ) ; const desktopAppsList = [ ... initialDesktopAppsList , ... compressedAppsList , ] . filter ( ( app ) => ! removedApps . includes ( app . text ) ) ; const appsInTrashBin = [ ... initialDesktopAppsList ] . filter ( ( app ) => removedApps . includes ( app . text ) ) ; const sortedAlphabetically = [ ... desktopAppsList ] . sort ( ( a , b ) => a . text . toLowerCase ( ) . localeCompare ( b . text . toLowerCase ( ) ) ) ; const sortedBySize = [ ... desktopAppsList ] ; const sortedByDate = [ ... desktopAppsList ] . sort ( ( a , b ) => b . id - a . id ) ; return { sortedAlphabetically , sortedByDate , sortedBySize , appsInTrashBin , } ; } ;