generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
95822dd
commit e4da311
Showing
10 changed files
with
551 additions
and
4 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 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
Large diffs are not rendered by default.
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,64 @@ | ||
import React from 'react'; | ||
import { FaRegCalendarAlt } from 'react-icons/fa'; | ||
import { MdUpdate } from 'react-icons/md'; | ||
import { formatTimestamp } from '../utils/format-timestamp'; | ||
|
||
interface FeatureFlag { | ||
id: string; | ||
name: string; | ||
description: string; | ||
status: 'ENABLED' | 'DISABLED'; | ||
createdAt: number; | ||
createdBy: string; | ||
updatedAt: number; | ||
updatedBy: string; | ||
} | ||
|
||
interface FeatureFlagCardProps { | ||
flag: FeatureFlag; | ||
onCardClick: (id: string) => void; | ||
} | ||
|
||
const FeatureFlagCard: React.FC<FeatureFlagCardProps> = ({ flag, onCardClick }) => { | ||
return ( | ||
<div | ||
onClick={() => onCardClick(flag.id)} | ||
className="bg-white rounded-xl shadow-lg hover:shadow-xl transition-all duration-300 overflow-hidden cursor-pointer hover:-translate-y-1" | ||
Check failure on line 26 in src/components/FeatureFlagCard.tsx GitHub Actions / lint_test
|
||
> | ||
<div className="p-6"> | ||
<div className="flex justify-between items-start mb-4"> | ||
<h2 className="text-xl font-bold text-gray-800 hover:text-primary-600 transition-colors"> | ||
{flag.name} | ||
</h2> | ||
<div className="flex items-center"> | ||
<span className="text-sm font-medium text-gray-600 mr-2">Status:</span> | ||
<span className={`px-3 py-1 rounded-full text-sm font-semibold | ||
${flag.status === 'ENABLED' | ||
Check failure on line 36 in src/components/FeatureFlagCard.tsx GitHub Actions / lint_test
|
||
? 'bg-green-100 text-green-700' | ||
: 'bg-gray-100 text-gray-700'}`} | ||
> | ||
{flag.status} | ||
</span> | ||
</div> | ||
</div> | ||
<p className="text-gray-600 mb-6 line-clamp-2"> | ||
{flag.description} | ||
</p> | ||
<div className="border-t pt-4 mt-auto"> | ||
<div className="text-sm text-gray-500 space-y-2"> | ||
<div className="flex items-center"> | ||
<FaRegCalendarAlt className="w-4 h-4 mr-2" /> | ||
<span>Created: {formatTimestamp(flag.createdAt)}</span> | ||
</div> | ||
<div className="flex items-center"> | ||
<MdUpdate className="w-4 h-4 mr-2" /> | ||
<span>Updated: {formatTimestamp(flag.updatedAt)}</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FeatureFlagCard; |
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,13 @@ | ||
import React from 'react'; | ||
|
||
const Spinner: React.FC = () => { | ||
return ( | ||
<div className="flex items-center justify-center h-full"> | ||
<div | ||
className="w-10 h-10 border-4 border-primary border-t-transparent rounded-full animate-spin" | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Spinner; |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { getConfig } from '../config'; | ||
import axios from 'axios'; | ||
|
||
export interface FeatureFlag { | ||
id: string; | ||
name: string; | ||
description: string; | ||
status: 'ENABLED' | 'DISABLED'; | ||
createdAt: number; | ||
createdBy: string; | ||
updatedAt: number; | ||
updatedBy: string; | ||
} | ||
|
||
const apiClient = axios.create({ | ||
baseURL: getConfig().rdsBackendBaseUrl, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
credentials: 'include', | ||
}, | ||
withCredentials: true, | ||
}); | ||
|
||
export const getAllFeatureFlags = async () => { | ||
const response = await apiClient.get<{data: FeatureFlag[]}>('/feature-flag/getAllFeatureFlags'); | ||
return response.data.data; | ||
}; |
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,11 @@ | ||
export const formatTimestamp = (timestamp: number): string => { | ||
const date = new Date(timestamp * 1000); | ||
return date.toLocaleString('en-US', { | ||
year: 'numeric', | ||
month: 'long', | ||
day: 'numeric', | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
hour12: true | ||
}); | ||
}; |
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,10 @@ | ||
import { formatTimestamp } from '../../src/utils/format-timestamp'; | ||
|
||
describe('formatTimestamp', () => { | ||
it('should format timestamp correctly', () => { | ||
const timestamp = 1718140371; | ||
const formattedDate = formatTimestamp(timestamp); | ||
|
||
expect(formattedDate).toBe('June 12, 2024 at 02:42 AM'); | ||
}); | ||
}); |