-
Notifications
You must be signed in to change notification settings - Fork 8
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 #67 from Lorg0n/feature/add-rules-for-collections
feat: add collection rules alert
- Loading branch information
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
features/collections/collection-edit/collection-rules-alert.component.tsx
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,53 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import { useEffect } from 'react'; | ||
import MaterialSymbolsInfoRounded from '~icons/material-symbols/info-rounded'; | ||
|
||
import MDViewer from '@/components/markdown/viewer/MD-viewer'; | ||
import { Button } from '@/components/ui/button'; | ||
|
||
import { useModalContext } from '@/services/providers/modal-provider'; | ||
|
||
const CollectionRulesAlert = () => { | ||
const [rules, setRules] = React.useState(''); | ||
const { openModal } = useModalContext(); | ||
|
||
useEffect(() => { | ||
fetch( | ||
'https://raw.githubusercontent.com/hikka-io/rules/main/COLLECTION_RULES.md', | ||
) | ||
.then((res) => res.text()) | ||
.then((res) => setRules(res)); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<div className="flex items-center gap-4 rounded-md border border-secondary/60 bg-secondary/30 p-4"> | ||
<MaterialSymbolsInfoRounded className="text-xl" /> | ||
<span className="flex-1 text-sm"> | ||
Перш ніж створювати колекції, рекомендуємо ознайомитись з{' '} | ||
<Button | ||
onClick={() => | ||
openModal({ | ||
content: ( | ||
<MDViewer className="overflow-scroll px-6 py-4 md:overflow-hidden md:p-0"> | ||
{rules} | ||
</MDViewer> | ||
), | ||
title: 'Правила колекцій', | ||
}) | ||
} | ||
variant="link" | ||
className="h-auto p-0 text-primary hover:underline" | ||
> | ||
нашими правилами | ||
</Button>{' '} | ||
створення колекцій. | ||
</span> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CollectionRulesAlert; |
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