-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Kagashino/dev
refactor: migrate almanac helpers to published npm package
- Loading branch information
Showing
10 changed files
with
60 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,3 @@ export default { | |
} | ||
} | ||
} | ||
|
||
export const getAlmanacSet = ()=>import('./almanac_set.json'); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,5 @@ | ||
import {useEffect, useState} from "react"; | ||
import {init} from "programmer-almanac-generator"; | ||
|
||
import { getAlmanacSet } from "../assets/api"; | ||
import { generateAlmanac } from "../assets/helpers/Almanac"; | ||
import { AlmanacResult, AlmanacSet} from "../types"; | ||
|
||
export const useAlmanac = ()=>{ | ||
const [result, setResult] = useState<AlmanacResult>({ | ||
bad: [], | ||
direction: '', | ||
drink: [], | ||
good: [], | ||
rate: '', | ||
todayStr: '', | ||
}) | ||
useEffect(()=>{ | ||
getAlmanacSet().then(res=>{ | ||
const Assets: AlmanacSet = res.default; | ||
const Almanac = generateAlmanac(Assets, new Date()) | ||
setResult(Almanac); | ||
}) | ||
}, []) | ||
return result; | ||
export const useAlmanac = (): AlmanacResult => { | ||
return init(new Date()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
declare type AlmanacActivity = { | ||
name: string, | ||
good: string, | ||
bad: string, | ||
weekend?: boolean | ||
} | ||
|
||
|
||
declare type AlmanacSet = { | ||
Weeks: Array | ||
Activities: Array | ||
Specials: Array | ||
Directions: Array | ||
Tools: Array | ||
Variables: Array | ||
Drinks: Array | ||
} | ||
|
||
|
||
declare type AlmanacResult = { | ||
todayStr: string | ||
good: Array<{ name: string, good: string, bad: string, weekend?: boolean }> | ||
bad: Array<{ name: string, good: string, bad: string, weekend?: boolean }> | ||
direction: string | ||
drink: string[] | ||
rate: string | ||
} | ||
|
||
declare module 'programmer-almanac-generator'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export interface Paging { | ||
page: number, | ||
size?: number, | ||
count: number, | ||
} | ||
|
||
export interface PagingList<T> extends Paging { | ||
list: T[] | ||
} | ||
|
||
export interface Article { | ||
access: number, | ||
author: string, | ||
content?: string, | ||
created: number, | ||
id: number | string, | ||
tags: string | ||
title: string | ||
} | ||
|
||
export interface Articles extends PagingList<Article>{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters