Skip to content

Commit

Permalink
bug(fixing TTL Page): Removing literal string (#297)
Browse files Browse the repository at this point in the history
- use enum instead of literal string
  • Loading branch information
AbdulKhaliq59 authored and Muhet committed Oct 2, 2023
1 parent c58a33f commit 53650c3
Show file tree
Hide file tree
Showing 24 changed files with 5,113 additions and 8,096 deletions.
12,117 changes: 4,529 additions & 7,588 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
"jwt-decode": "^3.1.2",
"moment": "^2.29.4",
"pnpm": "^8.6.11",
"react": "^18.2.0",
"react-apexcharts": "^1.4.1",
"react-calendar": "^3.9.0",
"react-chartjs-2": "^5.2.0",
Expand Down
10 changes: 7 additions & 3 deletions src/components/ProfileCoverpage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function ProfileCoverpage({
/* istanbul ignore next */
setSpinner(true);
/* istanbul ignore if */
/* istanbul ignore next */
/* istanbul ignore next */
if (updated) {
setSpinner(false);
setProfileImage(updated?.data?.updateAvatar?.avatar);
Expand Down Expand Up @@ -185,14 +185,18 @@ export default function ProfileCoverpage({
</div>
{currentPage !== 'editProfile' ? (
<Button
/* istanbul ignore next */
/* istanbul ignore next */
onClick={() => handleEdit()}
variant="default"
size="md"
style="text-center ml-auto mr-4 mt-40 md:mt-24 rounded-lg bg-primary text-white hover:bg-[#7a5edc] focus:outline-none p-1 md:p-2 flex flex-row"
>
<PencilIcon className="w-6 mr-1 md:mr-2 dark:text-dark-text-fill " />
<span className="hidden md:block"> {t('Edit Profile')} </span>
<span className="hidden md:block">
{' '}
{t('Edit Profile')}
{spinnerCover ? <Spinner /> : ''}
</span>
</Button>
) : (
<div className="flex items-center justify-center w-full h-screen mt-24 ml-auto bg-grey-lighter">
Expand Down
80 changes: 36 additions & 44 deletions src/components/Resume.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* istanbul ignore file */
import React, { useState, useContext,useEffect } from 'react';
import React, { useState, useContext, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { gql, useMutation } from '@apollo/client';
import axios from 'axios';
Expand All @@ -13,6 +13,7 @@ import Spinner from './Spinner';
const UPLOAD_RESUME = gql`
mutation UploadResume($userId: ID!, $resume: String!) {
uploadResume(userId: $userId, resume: $resume) {
kindly
resume
}
}
Expand All @@ -26,7 +27,7 @@ interface UploadFormProps {
saveFile: () => void;
closeModal: () => void;
t: (key: string) => string;
loading:boolean;
loading: boolean;
}

function UploadForm({
Expand All @@ -37,7 +38,7 @@ function UploadForm({
saveFile,
closeModal,
t,
loading
loading,
}: UploadFormProps) {
return (
<form action="">
Expand Down Expand Up @@ -71,7 +72,7 @@ function UploadForm({
</div>
)}
<Button variant="primary" size="lg" style="mt-5" onClick={saveFile}>
{loading ? <Spinner /> : t('upload')}
{loading ? <Spinner /> : t('upload')}
</Button>
</form>
);
Expand All @@ -90,11 +91,11 @@ function Resume() {
const [spinner, setSpinner] = useState(false);
const [spinnerLink, setSpinnerLink] = useState(false);
const [isPdfDisplayed, setIsPdfDisplayed] = useState(false);
const [display,setDisplay] = useState("Preview");
const [display, setDisplay] = useState('Preview');

const [previewPdf, setPreviewPdf] = useState<string | null>(null);
const [isPreviewVisible, setIsPreviewVisible] = useState(false);
const [buttonLoading, setButtonLoading] = useState(false);
const [previewPdf, setPreviewPdf] = useState<string | null>(null);
const [isPreviewVisible, setIsPreviewVisible] = useState(false);
const [buttonLoading, setButtonLoading] = useState(false);

const { t } = useTranslation();

Expand All @@ -117,27 +118,23 @@ const [buttonLoading, setButtonLoading] = useState(false);
};

const saveFile = async () => {

if (uploadType === 0 && file) {
const formData = new FormData();
formData.append('file', file);
formData.append('upload_preset', 'mydocs');
formData.append('resource_type', 'raw');


try {
if (file && file.type === 'application/pdf') {
setButtonLoading(true);
setButtonLoading(true);
const resume = await axios.post(

`https://api.cloudinary.com/v1_1/dkgq3at71/raw/upload`,
`https://api.cloudinary.com/v1_1/dta2axdpw/raw/upload`,

formData,

);

setSpinner(true);

const updated = await UploadResume({
variables: {
userId: user.userId,
Expand All @@ -150,7 +147,7 @@ const [buttonLoading, setButtonLoading] = useState(false);
setUploadedResumeLink(resume?.data?.secure_url);

setPreviewPdf(resume?.data?.secure_url);

toast.success('Resume uploaded successfully!');
setButtonLoading(false);
setFile(null);
Expand All @@ -161,7 +158,6 @@ const [buttonLoading, setButtonLoading] = useState(false);
const typedError = error as Error;
toast.error(`Error uploading resume: ${typedError.message}`);
setButtonLoading(false);

}
}

Expand Down Expand Up @@ -253,39 +249,35 @@ const [buttonLoading, setButtonLoading] = useState(false);
closeModal={closeModal}
loading={buttonLoading}
t={t}

/>
</div>
)}


{uploadedResumeLink && (
<div>
<div className="mt-5">
<Button
variant="secondary"
size="md"
style="mt-3"
onClick={() => {
setPreviewPdf(null);
setIsPdfDisplayed(!isPdfDisplayed);
}}
>
{isPdfDisplayed ? <h2>Close</h2> : <h2>{display}</h2>}
</Button>


<div className="mt-5">
<Button
variant="secondary"
size="md"
style="mt-3"
onClick={() => {
setPreviewPdf(null);
setIsPdfDisplayed(!isPdfDisplayed);
}}
>
{isPdfDisplayed ? <h2>Close</h2> : <h2>{display}</h2>}
</Button>


{isPdfDisplayed && (
<div className="mt-3">
<embed src={uploadedResumeLink} className='w-full' style={{height:"1000px"}} />
</div>
)}


</div>

{isPdfDisplayed && (
<div className="mt-3">
<embed
src={uploadedResumeLink}
className="w-full"
style={{ height: '1000px' }}
/>
</div>
)}
</div>
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,20 @@ Array [
>
program
</th>
<th
className=" thead"
colSpan={1}
onClick={[Function]}
role="columnheader"
style={
Object {
"cursor": "pointer",
}
}
title="Toggle SortBy"
>
View
</th>
<th
className=" thead"
colSpan={1}
Expand Down Expand Up @@ -979,6 +993,21 @@ Array [
className="data-cell"
role="cell"
/>
<td
className="data-cell"
role="cell"
>
<div
className=" items-center hidden"
>
<button
className="bg-black text-white rounded-xl px-3"
onClick={[Function]}
>
View
</button>
</div>
</td>
<td
className="data-cell"
role="cell"
Expand All @@ -994,7 +1023,7 @@ Array [
</tr>
<tr>
<td
colSpan={7}
colSpan={8}
style={
Object {
"textAlign": "center",
Expand All @@ -1017,7 +1046,7 @@ Array [
className="w-full py-2"
>
<td
colSpan={7}
colSpan={8}
>
<div
className="w-full justify-center flex mx-auto flex-row items-center overflow-x-auto"
Expand Down
20 changes: 12 additions & 8 deletions src/components/tests/__snapshots__/ButtonLoading.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@

exports[`Button Loading Renders the button 1`] = `
<div
className="flex btn w-fit py-1 px-3 bg-primary font-bold md"
className="flex w-fit py-1 px-3 bg-primary justify-center font-bold md"
>
<div
className="loader mr-1"
/>
<button
className="ml-1 text-white font-bold"
disabled={true}
className="flex w-full gap-2 justify-center items-center"
>
Processing...
</button>
<div
className="loader"
/>
<button
className=" text-white font-bold"
disabled={true}
>
Processing...
</button>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ exports[`DashHeader test Should render DashHeader 1`] = `
onClick={[Function]}
>
<svg
className="w-full cursor-pointer mr-2"
className="w-full cursor-pointer mr-2 "
fill="none"
height="36"
viewBox="0 0 59 36"
Expand Down
2 changes: 1 addition & 1 deletion src/components/tests/__snapshots__/Footer.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports[`<Footer/> Renders Header 1`] = `
className="flex mb-2 ml-10 text-dark dark:text-dark-text-fill"
>
<svg
className="w-full cursor-pointer mr-2"
className="w-full cursor-pointer mr-2 "
fill="none"
height="36"
viewBox="0 0 59 36"
Expand Down
12 changes: 6 additions & 6 deletions src/components/tests/__snapshots__/Header.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`Header Tests Should render the header with home 1`] = `
onClick={[Function]}
>
<svg
className="w-full cursor-pointer mr-2"
className="w-full cursor-pointer mr-2 "
fill="none"
height="36"
viewBox="0 0 59 36"
Expand Down Expand Up @@ -286,7 +286,7 @@ exports[`Header Tests Should render the header with no active 1`] = `
onClick={[Function]}
>
<svg
className="w-full cursor-pointer mr-2"
className="w-full cursor-pointer mr-2 "
fill="none"
height="36"
viewBox="0 0 59 36"
Expand Down Expand Up @@ -555,7 +555,7 @@ exports[`Header Tests Should render the header with no active 2`] = `
onClick={[Function]}
>
<svg
className="w-full cursor-pointer mr-2"
className="w-full cursor-pointer mr-2 "
fill="none"
height="36"
viewBox="0 0 59 36"
Expand Down Expand Up @@ -795,7 +795,7 @@ exports[`Header Tests Should render the header with no active 3`] = `
onClick={[Function]}
>
<svg
className="w-full cursor-pointer mr-2"
className="w-full cursor-pointer mr-2 "
fill="none"
height="36"
viewBox="0 0 59 36"
Expand Down Expand Up @@ -1065,7 +1065,7 @@ exports[`Header Tests Should render the header with pricing active 1`] = `
onClick={[Function]}
>
<svg
className="w-full cursor-pointer mr-2"
className="w-full cursor-pointer mr-2 "
fill="none"
height="36"
viewBox="0 0 59 36"
Expand Down Expand Up @@ -1335,7 +1335,7 @@ exports[`Header Tests Should render the header with product active 1`] = `
onClick={[Function]}
>
<svg
className="w-full cursor-pointer mr-2"
className="w-full cursor-pointer mr-2 "
fill="none"
height="36"
viewBox="0 0 59 36"
Expand Down
1 change: 1 addition & 0 deletions src/containers/admin-dashBoard/Programs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function AdminPrograms() {
{ Header: t('Manager'), accessor: 'manager' },
{ Header: t('Organization'), accessor: 'organization' },
{ Header: t('Description'), accessor: 'description' },

{
Header: t('Actions'),
accessor: '',
Expand Down
Loading

0 comments on commit 53650c3

Please sign in to comment.