-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable contact details to be set through configuration
- Loading branch information
Showing
7 changed files
with
84 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Request, Response } from "express"; | ||
import { config } from "@gram/core/dist/config/index.js"; | ||
|
||
export const getContact = async (req: Request, res: Response) => { | ||
res.json({ contact: config.contact }); | ||
}; |
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,12 @@ | ||
import { api } from "./api"; | ||
|
||
const contactApi = api.injectEndpoints({ | ||
endpoints: (build) => ({ | ||
getContact: build.query({ | ||
query: () => `/contact`, | ||
transformResponse: (response) => response.contact, | ||
}), | ||
}), | ||
}); | ||
|
||
export const { useGetContactQuery } = contactApi; |
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,42 @@ | ||
import { Chip, IconButton } from "@mui/material"; | ||
import EmailIcon from "@mui/icons-material/Email"; | ||
import ChatIcon from "@mui/icons-material/Chat"; | ||
import { useGetContactQuery } from "../../api/gram/contact"; | ||
|
||
export function ContactChip(props) { | ||
const { data: contact } = useGetContactQuery(); | ||
|
||
return ( | ||
<Chip | ||
variant="outlined" | ||
label={contact?.name || "Your Gram Admins"} | ||
icon={ | ||
<> | ||
{contact?.slackUrl && ( | ||
<IconButton | ||
href={contact?.slackUrl} | ||
target="_blank" | ||
rel="noreferrer" | ||
color="inherit" | ||
size="small" | ||
> | ||
<ChatIcon /> | ||
</IconButton> | ||
)} | ||
{contact?.mail && ( | ||
<IconButton | ||
href={`mailto:${contact?.mail}`} | ||
target="_blank" | ||
rel="noreferrer" | ||
color="inherit" | ||
size="small" | ||
> | ||
<EmailIcon /> | ||
</IconButton> | ||
)} | ||
</> | ||
} | ||
{...props} | ||
/> | ||
); | ||
} |
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