-
Notifications
You must be signed in to change notification settings - Fork 6
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 #45 from HunnySajid/feat/integration
Feat/integration
- Loading branch information
Showing
23 changed files
with
633 additions
and
178 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
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,34 @@ | ||
interface ICustomRadio { | ||
id?: string; | ||
component?: JSX.Element; | ||
checked: boolean; | ||
onClick: () => void; | ||
} | ||
|
||
export function CustomRadio({ | ||
id, | ||
component, | ||
checked, | ||
onClick, | ||
}: ICustomRadio): JSX.Element { | ||
return ( | ||
<div | ||
onClick={onClick} | ||
className={`flex cursor-pointer items-center border ${ | ||
checked ? "border-green" : "" | ||
}`} | ||
> | ||
<input | ||
checked={checked} | ||
id={id} | ||
type="radio" | ||
value="" | ||
name="bordered-radio" | ||
className="w-4 h-4 dark:ring-offset-green " | ||
/> | ||
<label htmlFor={id} className="w-full ms-1 font-medium"> | ||
{component} | ||
</label> | ||
</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
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,22 @@ | ||
interface ILoader { | ||
color?: string; | ||
size?: number; | ||
} | ||
|
||
export const Loader = ({ color = "currentColor", size = 3 }: ILoader) => { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
viewBox="0 0 32 32" | ||
id="Loading" | ||
className={`animate-spin h-${size} w-${size}`} | ||
> | ||
<g data-name="Loader"> | ||
<path | ||
fill={color} | ||
d="M29.89 15.81a2.51 2.51 0 1 0-5 .45 9.65 9.65 0 0 1-1.68 6.34 10.24 10.24 0 0 1-5.74 4 10.71 10.71 0 0 1-7.38-.7 11.44 11.44 0 0 1-5.48-5.62A12.07 12.07 0 0 0 9.46 27 12.58 12.58 0 0 0 17.9 29a13.31 13.31 0 0 0 8.18-4 14 14 0 0 0 3.81-8.75v-.08A2.29 2.29 0 0 0 29.89 15.81zM7.11 15.74A9.65 9.65 0 0 1 8.79 9.4a10.24 10.24 0 0 1 5.74-4 10.71 10.71 0 0 1 7.38.7 11.44 11.44 0 0 1 5.48 5.62A12.07 12.07 0 0 0 22.54 5 12.58 12.58 0 0 0 14.1 3 13.31 13.31 0 0 0 5.92 7a14 14 0 0 0-3.81 8.75v.08a2.29 2.29 0 0 0 0 .37 2.51 2.51 0 1 0 5-.45z" | ||
></path> | ||
</g> | ||
</svg> | ||
); | ||
}; |
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,66 @@ | ||
import { useState, useEffect } from "react"; | ||
import { CustomRadio } from "@components/customRadio"; | ||
import { IdentifierCard } from "@components/identifierCard"; | ||
import { IMessage } from "@pages/background/types"; | ||
import { APP_STATE } from "@pages/popup/constants"; | ||
|
||
export function SelectIdentifier(): JSX.Element { | ||
const [aids, setAids] = useState([]); | ||
const [selectedAid, setSelectedAid] = useState(null); | ||
|
||
const fetchIdentifiers = async () => { | ||
const { data } = await chrome.runtime.sendMessage<IMessage<void>>({ | ||
type: "fetch-resource", | ||
subtype: "identifiers", | ||
}); | ||
console.log("data", data); | ||
setAids(data.aids); | ||
}; | ||
|
||
const createSigninWithIdentifiers = async () => { | ||
const { data } = await chrome.runtime.sendMessage<IMessage<void>>({ | ||
type: "create-resource", | ||
subtype: "signin", | ||
data: { | ||
identifier: selectedAid, | ||
}, | ||
}); | ||
await chrome.runtime.sendMessage({ | ||
type: "tab", | ||
subtype: "set-tab-state", | ||
data: { | ||
appState: APP_STATE.DEFAULT, | ||
}, | ||
}); | ||
console.log("data.signins", data.signins); | ||
window.close(); | ||
}; | ||
|
||
useEffect(() => { | ||
fetchIdentifiers(); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
{aids.map((aid, index) => ( | ||
<div key={index} className="my-2 mx-4"> | ||
<CustomRadio | ||
id={aid.name} | ||
checked={selectedAid?.prefix === aid?.prefix} | ||
onClick={() => setSelectedAid(aid)} | ||
component={<IdentifierCard aid={aid} />} | ||
/> | ||
</div> | ||
))} | ||
<button | ||
disabled={!selectedAid} | ||
onClick={createSigninWithIdentifiers} | ||
className={`fixed bottom-0 right-4 text-white ${ | ||
selectedAid ? "bg-green" : " bg-gray" | ||
} focus:outline-none font-medium rounded-full text-sm px-5 py-2.5 text-center me-2 mb-2`} | ||
> | ||
Select | ||
</button> | ||
</> | ||
); | ||
} |
Oops, something went wrong.