aboutsummaryrefslogtreecommitdiff
path: root/src/server/Model/Json/Category.hs
blob: 8b5e52753130a8d936e8bff15a210e37d42c06fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE DeriveGeneric #-}

module Model.Json.Category
  ( Category(..)
  , fromCategory
  ) where

import Data.Aeson
import Data.Text (Text)
import GHC.Generics

import Model.Category (CategoryId)
import qualified Model.Category as M

data Category = Category
  { id :: CategoryId
  , name :: Text
  , color :: Text
  } deriving (Show, Generic)

instance ToJSON Category

fromCategory :: M.Category -> Category
fromCategory category = Category (M.id category) (M.name category) (M.color category)