-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
126 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
{"name":"aa","description":"bb","createdOn":{"$$date":1688242303554},"status":false,"updatedOn":{"$$date":1688242303554},"_id":"2tIWq8geXQN0MEH3"} | ||
{"name":"aaa","description":"ddd","createdOn":{"$$date":1688242198336},"status":false,"updatedOn":{"$$date":1688242198337},"_id":"Iuk6NNE4vI8kN5cA"} | ||
{"name":"key1","description":"dcdcdcd","createdOn":{"$$date":1688242491814},"status":false,"updatedOn":{"$$date":1688242491814},"_id":"mTnayQkL0tMgLmKn"} | ||
|
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,6 @@ | ||
|
||
export const generateKey = (val: string) => { | ||
return val.toLowerCase() | ||
.replace(/ /g, "-") | ||
.replace(/[^\w-]+/g, ""); | ||
} |
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
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,8 +1,60 @@ | ||
import { Switch } from "@headlessui/react"; | ||
import { useState } from "react"; | ||
import { classNames } from "../helpers/classHelper"; | ||
import { FlagModel } from "../models/FlagModel"; | ||
import * as dateHelper from "../helpers/dateHelper"; | ||
|
||
export const FlagsItem: React.FC<FlagModel> = (props) => { | ||
|
||
return(<> | ||
|
||
</>); | ||
} | ||
export const FlagsItem: React.FC<{ flag: FlagModel }> = (props) => { | ||
const [enabled, setEnabled] = useState(false) | ||
|
||
return ( | ||
|
||
|
||
<div className="bg-white shadow sm:rounded-lg m-4"> | ||
<Switch.Group as="div" className="px-4 py-5 sm:p-6"> | ||
|
||
<div className=" sm:flex sm:items-start sm:justify-between"> | ||
<div className="max-w-xl text-base text-gray-500"> | ||
<Switch.Label as="h3" className="text-base font-semibold leading-6 text-gray-900"> | ||
{props.flag.name} | ||
</Switch.Label> | ||
<div className="mt-3"> | ||
<Switch.Description> | ||
{props.flag.description} | ||
</Switch.Description> | ||
</div> | ||
<div className="mt-3"> | ||
<code className="bg-slate-100 px-2 py-1 rounded-md text-sm">{props.flag.key}</code> | ||
</div> | ||
|
||
|
||
</div> | ||
<div className=" sm:ml-6 sm:mt-0 sm:flex sm:flex-shrink-0 sm:items-center"> | ||
<div className="flex flex-col"> | ||
<div className="text-base text-gray-500"> {dateHelper.formatDateTime(props.flag.createdOn)}</div> | ||
<div className="text-right"> | ||
<Switch | ||
checked={enabled} | ||
onChange={setEnabled} | ||
className={classNames( | ||
enabled ? 'bg-green-600' : 'bg-gray-200', | ||
'mt-3 relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2', | ||
'border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2' | ||
)} | ||
> | ||
<span | ||
aria-hidden="true" | ||
className={classNames( | ||
enabled ? 'translate-x-5' : 'translate-x-0', | ||
'inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out' | ||
)} | ||
/> | ||
</Switch> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</Switch.Group> | ||
</div> | ||
); | ||
} |
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,4 +1,11 @@ | ||
export const FlagsList: React.FC = () => { | ||
|
||
return(<></>); | ||
import { FlagModel } from "../models/FlagModel"; | ||
import { FlagsItem } from "./FlagsItem"; | ||
|
||
export const FlagsList: React.FC<{ flags: FlagModel[] }> = (props) => { | ||
|
||
return (<> | ||
{props.flags.map(flagItem => ( | ||
<FlagsItem flag={flagItem} /> | ||
))} | ||
</>); | ||
} |
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,27 @@ | ||
import { DateTime } from "luxon"; | ||
|
||
export const formatDateTime = (dateStr: string | undefined) => { | ||
|
||
if (dateStr === undefined) { | ||
return ""; | ||
} | ||
|
||
return DateTime.fromISO(dateStr).toFormat("MMM dd, yyyy @ hh:mm a"); | ||
}; | ||
|
||
export const utcNow = () : DateTime=> { | ||
return DateTime.utc(); | ||
} | ||
|
||
export const getDateWithOffset = (nrDays: number, start: DateTime) : DateTime=> { | ||
return start.minus({"days": nrDays}); | ||
} | ||
|
||
export const diffFromUtcInDays = (date: string | undefined) => { | ||
|
||
if (date === undefined) { | ||
return; | ||
} | ||
|
||
return DateTime.fromISO(date).diff( DateTime.utc(), ["days"]).toObject().days?.toFixed(0); | ||
}; |
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,9 +1,9 @@ | ||
import { DateTime } from "luxon"; | ||
|
||
export interface FlagModel { | ||
name: string; | ||
description?: string; | ||
createdOn: DateTime; | ||
updatedOn: DateTime; | ||
createdOn: string; | ||
updatedOn: string; | ||
status: boolean; | ||
key: string; | ||
} |
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